From 7862870c45408eaef2d99252950f38c776aeed72 Mon Sep 17 00:00:00 2001 From: Yang Jiao <72076317+YangJiao0817@users.noreply.github.com> Date: Tue, 25 Jul 2023 15:06:04 +0800 Subject: [PATCH] Update webhook and replication testcase (#18998) Sync test case updates because of changes to webhook and replication 1. #18923 2. #18906 Signed-off-by: Yang Jiao --- .../Harbor-Pages/Project-P2P-Preheat.robot | 5 +-- tests/resources/TestCaseBody.robot | 32 +++++++++---------- .../Group1-Nightly/Common_GC.robot | 4 +-- .../Group1-Nightly/Replication.robot | 2 +- .../robot-cases/Group1-Nightly/Webhook.robot | 16 +++++----- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/tests/resources/Harbor-Pages/Project-P2P-Preheat.robot b/tests/resources/Harbor-Pages/Project-P2P-Preheat.robot index 2467bc2f2..22963a15d 100644 --- a/tests/resources/Harbor-Pages/Project-P2P-Preheat.robot +++ b/tests/resources/Harbor-Pages/Project-P2P-Preheat.robot @@ -88,6 +88,7 @@ Delete A P2P Preheat Policy [Arguments] ${name} Switch To P2P Preheat Retry Double Keywords When Error Select P2P Preheat Policy ${name} Wait Until Element Is Visible ${p2p_execution_header} + Retry Wait Until Page Not Contains Element //clr-datagrid[contains(.,'ID')]//div//clr-dg-row[1]//clr-dg-cell[2][text()=' Running '] Retry Double Keywords When Error Retry Element Click ${p2p_preheat_action_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_del_btn_id} Retry Double Keywords When Error Retry Element Click ${p2p_preheat_del_btn_id} Wait Until Element Is Visible And Enabled ${delete_confirm_btn} Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn} @@ -138,8 +139,8 @@ Verify Artifact Is Pushed Event Verify Artifact Is Scanned Event [Arguments] ${project_name} ${policy_name} ${image} ${tag} - Go Into Project ${project_name} - Scan Artifact ${project_name} ${image} //clr-dg-row[contains(.,'${tag}')]//label[1] + Go Into Repo ${project_name} ${image} + Scan Repo ${tag} Succeed Back Project Home ${project_name} Switch To P2P Preheat ${contain} Create List ${project_name}/${image}:${tag} diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index be20b4cc0..55c018671 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -480,10 +480,10 @@ Verify Webhook By Artifact Deleted Event Verify Request &{artifact_deleted_property} Verify Webhook By Scanning Finished Event - [Arguments] ${project_name} ${webhook_name} ${image} ${tag} ${harbor_handle} ${webhook_handle} ${payload_format}=Default + [Arguments] ${project_name} ${webhook_name} ${image} ${tag} ${user} ${harbor_handle} ${webhook_handle} ${payload_format}=Default &{scanning_finished_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${scanning_finished_property} type=SCANNING_COMPLETED scan_status=Success namespace=${project_name} tag=${tag} name=${image} - ... ELSE Set To Dictionary ${scanning_finished_property} specversion=1.0 type=harbor.scan.completed datacontenttype=application/json namespace=${project_name} name=${image} repo_full_name=${project_name}/${image} tag=${tag} scan_status=Success + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${scanning_finished_property} type=SCANNING_COMPLETED operator=${user} scan_status=Success namespace=${project_name} tag=${tag} name=${image} + ... ELSE Set To Dictionary ${scanning_finished_property} specversion=1.0 type=harbor.scan.completed datacontenttype=application/json operator=${user} namespace=${project_name} name=${image} repo_full_name=${project_name}/${image} tag=${tag} scan_status=Success Switch Window ${webhook_handle} Delete All Requests Switch Window ${harbor_handle} @@ -499,10 +499,10 @@ Verify Webhook By Scanning Finished Event Verify Request &{scanning_finished_property} Verify Webhook By Scanning Stopped Event - [Arguments] ${project_name} ${webhook_name} ${image} ${tag} ${harbor_handle} ${webhook_handle} ${payload_format}=Default + [Arguments] ${project_name} ${webhook_name} ${image} ${tag} ${user} ${harbor_handle} ${webhook_handle} ${payload_format}=Default &{scanning_stopped_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${scanning_stopped_property} type=SCANNING_STOPPED scan_status=Stopped namespace=${project_name} tag=${tag} name=${image} - ... ELSE Set To Dictionary ${scanning_stopped_property} specversion=1.0 type=harbor.scan.stopped datacontenttype=application/json namespace=${project_name} name=${image} repo_full_name=${project_name}/${image} tag=${tag} scan_status=Stopped + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${scanning_stopped_property} type=SCANNING_STOPPED operator=${user} scan_status=Stopped namespace=${project_name} tag=${tag} name=${image} + ... ELSE Set To Dictionary ${scanning_stopped_property} specversion=1.0 type=harbor.scan.stopped datacontenttype=application/json operator=${user} namespace=${project_name} name=${image} repo_full_name=${project_name}/${image} tag=${tag} scan_status=Stopped Switch Window ${webhook_handle} Delete All Requests Switch Window ${harbor_handle} @@ -519,10 +519,10 @@ Verify Webhook By Scanning Stopped Event Verify Request &{scanning_stopped_property} Verify Webhook By Tag Retention Finished Event - [Arguments] ${project_name} ${webhook_name} ${image} ${tag1} ${tag2} ${harbor_handle} ${webhook_handle} ${payload_format}=Default + [Arguments] ${project_name} ${webhook_name} ${image} ${tag1} ${tag2} ${user} ${harbor_handle} ${webhook_handle} ${payload_format}=Default &{tag_retention_finished_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${tag_retention_finished_property} type=TAG_RETENTION operator=MANUAL project_name=${project_name} name_tag=${image}:${tag2} status=SUCCESS - ... ELSE Set To Dictionary ${tag_retention_finished_property} specversion=1.0 type=harbor.tag_retention.finished datacontenttype=application/json project_name=${project_name} name_tag=${image}:${tag2} status=SUCCESS + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${tag_retention_finished_property} type=TAG_RETENTION operator=${user} project_name=${project_name} name_tag=${image}:${tag2} status=SUCCESS + ... ELSE Set To Dictionary ${tag_retention_finished_property} specversion=1.0 type=harbor.tag_retention.finished datacontenttype=application/json operator=${user} project_name=${project_name} name_tag=${image}:${tag2} status=SUCCESS Switch Window ${webhook_handle} Delete All Requests Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${project_name} ${image} ${tag1} ${tag1} @@ -543,10 +543,10 @@ Verify Webhook By Tag Retention Finished Event Wait Until Page Contains "retained":1 Verify Webhook By Replication Status Changed Event - [Arguments] ${project_name} ${webhook_name} ${project_dest_name} ${replication_rule_name} ${harbor_handle} ${webhook_handle} ${payload_format}=Default + [Arguments] ${project_name} ${webhook_name} ${project_dest_name} ${replication_rule_name} ${user} ${harbor_handle} ${webhook_handle} ${payload_format}=Default &{replication_finished_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${replication_finished_property} type=REPLICATION operator=MANUAL registry_type=harbor harbor_hostname=${ip} - ... ELSE Set To Dictionary ${replication_finished_property} specversion=1.0 type=harbor.replication.status.changed datacontenttype=application/json trigger_type=MANUAL namespace=${project_name} + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${replication_finished_property} type=REPLICATION operator=${user} registry_type=harbor harbor_hostname=${ip} + ... ELSE Set To Dictionary ${replication_finished_property} specversion=1.0 type=harbor.replication.status.changed datacontenttype=application/json operator=${user} trigger_type=MANUAL namespace=${project_name} Switch Window ${webhook_handle} Delete All Requests Switch Window ${harbor_handle} @@ -574,8 +574,8 @@ Verify Webhook By Quota Near Threshold Event And Quota Exceed Event ${event_type} Create List Quota near threshold Create A New Webhook webhook${d} ${webhook_endpoint_url} ${payload_format} ${event_type} &{quota_near_threshold_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${quota_near_threshold_property} type=QUOTA_WARNING name=nginx namespace=project${d} - ... ELSE Set To Dictionary ${quota_near_threshold_property} specversion=1.0 type=harbor.quota.warned datacontenttype=application/json name=${image} repo_full_name=project${d}/${image} namespace=project${d} + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${quota_near_threshold_property} type=QUOTA_WARNING operator=${HARBOR_ADMIN} name=nginx namespace=project${d} + ... ELSE Set To Dictionary ${quota_near_threshold_property} specversion=1.0 type=harbor.quota.warned datacontenttype=application/json operator=${HARBOR_ADMIN} name=${image} repo_full_name=project${d}/${image} namespace=project${d} Switch Window ${webhook_handle} Delete All Requests # Quota near threshold @@ -592,8 +592,8 @@ Verify Webhook By Quota Near Threshold Event And Quota Exceed Event Verify Webhook By Quota Exceed Event [Arguments] ${project_name} ${webhook_name} ${image} ${tag} ${webhook_endpoint_url} ${storage_quota} ${harbor_handle} ${webhook_handle} ${payload_format}=Default &{quota_exceed_property}= Create Dictionary - Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${quota_exceed_property} type=QUOTA_EXCEED name=${image} namespace=${project_name} - ... ELSE Set To Dictionary ${quota_exceed_property} specversion=1.0 type=harbor.quota.exceeded datacontenttype=application/json name=${image} repo_full_name=${project_name}/${image} namespace=${project_name} + Run Keyword If '${payload_format}' == 'Default' Set To Dictionary ${quota_exceed_property} type=QUOTA_EXCEED operator=${HARBOR_ADMIN} name=${image} namespace=${project_name} + ... ELSE Set To Dictionary ${quota_exceed_property} specversion=1.0 type=harbor.quota.exceeded datacontenttype=application/json operator=${HARBOR_ADMIN} name=${image} repo_full_name=${project_name}/${image} namespace=${project_name} # Quota exceed Switch Window ${harbor_handle} Go Into Project ${project_name} diff --git a/tests/robot-cases/Group1-Nightly/Common_GC.robot b/tests/robot-cases/Group1-Nightly/Common_GC.robot index 140f46db2..0fcd98bb0 100644 --- a/tests/robot-cases/Group1-Nightly/Common_GC.robot +++ b/tests/robot-cases/Group1-Nightly/Common_GC.robot @@ -79,13 +79,13 @@ Test Case - Project Quotas Control Under GC Create An New Project And Go Into Project project${d} storage_quota=${storage_quota} storage_quota_unit=${storage_quota_unit} Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=will exceed the configured upper limit of 200.0 MiB @{param} Create List project${d} - FOR ${n} IN RANGE 1 3 + FOR ${n} IN RANGE 1 10 ${out1} Run Keyword And Ignore Error GC Now ${latest_job_id}= Get Text ${latest_job_id_xpath} Retry GC Should Be Successful ${latest_job_id} ${null} ${out2} Run Keyword And Ignore Error Retry Keyword When Return Value Mismatch Get Project Storage Quota Text From Project Quotas List 0Byte of ${storage_quota}${storage_quota_unit} 2 @{param} Exit For Loop If '${out2[0]}'=='PASS' - Sleep 1 + Sleep 5 END Should Be Equal As Strings '${out2[0]}' 'PASS' Close Browser diff --git a/tests/robot-cases/Group1-Nightly/Replication.robot b/tests/robot-cases/Group1-Nightly/Replication.robot index a30577ae5..1b1ec7e10 100644 --- a/tests/robot-cases/Group1-Nightly/Replication.robot +++ b/tests/robot-cases/Group1-Nightly/Replication.robot @@ -90,7 +90,7 @@ Test Case - Replication Rule Edit ${resource_type}= Set Variable image ${dest_namespace}= Set Variable dest_namespace${d} ${mode}= Set Variable Scheduled - ${cron_str}= Set Variable 10 10 10 * * * + ${cron_str}= Set Variable 0 0 0 * * 0 Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Switch To Registries Create A New Endpoint harbor ${endpoint1} https://cicd.harbor.vmwarecna.net ${null} ${null} Y diff --git a/tests/robot-cases/Group1-Nightly/Webhook.robot b/tests/robot-cases/Group1-Nightly/Webhook.robot index 20b9478d3..4b9201d43 100644 --- a/tests/robot-cases/Group1-Nightly/Webhook.robot +++ b/tests/robot-cases/Group1-Nightly/Webhook.robot @@ -84,9 +84,9 @@ Test Case - Scan Event Type Webhook Functionality ${webhook_handle}= Set Variable ${handles}[0] ${harbor_handle}= Set Variable ${handles}[1] # Scanning finished - Retry Action Keyword Verify Webhook By Scanning Finished Event project${d} webhook${d} ${image1} ${tag1} ${harbor_handle} ${webhook_handle} + Retry Action Keyword Verify Webhook By Scanning Finished Event project${d} webhook${d} ${image1} ${tag1} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} # Scanning stopped - Retry Action Keyword Verify Webhook By Scanning Stopped Event project${d} webhook${d} ${image2} ${tag2} ${harbor_handle} ${webhook_handle} + Retry Action Keyword Verify Webhook By Scanning Stopped Event project${d} webhook${d} ${image2} ${tag2} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} Close Browser Test Case - Tag Retention And Replication Event Type Webhook Functionality @@ -116,9 +116,9 @@ Test Case - Tag Retention And Replication Event Type Webhook Functionality ${webhook_handle}= Set Variable ${handles}[0] ${harbor_handle}= Set Variable ${handles}[1] # Tag retention finished - Retry Action Keyword Verify Webhook By Tag Retention Finished Event project${d} webhook${d} ${image} ${tag1} ${tag2} ${harbor_handle} ${webhook_handle} + Retry Action Keyword Verify Webhook By Tag Retention Finished Event project${d} webhook${d} ${image} ${tag1} ${tag2} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} # Replication status changed - Retry Action Keyword Verify Webhook By Replication Status Changed Event project${d} webhook${d} project_push_dest${d} rule_push_${d} ${harbor_handle} ${webhook_handle} + Retry Action Keyword Verify Webhook By Replication Status Changed Event project${d} webhook${d} project_push_dest${d} rule_push_${d} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} Close Browser Test Case - Tag Quota Event Type Webhook Functionality @@ -183,9 +183,9 @@ Test Case - Scan Event Type Webhook Functionality By CloudEvents Format ${webhook_handle}= Set Variable ${handles}[0] ${harbor_handle}= Set Variable ${handles}[1] # Scanning finished - Retry Action Keyword Verify Webhook By Scanning Finished Event project${d} webhook${d} ${image1} ${tag1} ${harbor_handle} ${webhook_handle} ${payload_format} + Retry Action Keyword Verify Webhook By Scanning Finished Event project${d} webhook${d} ${image1} ${tag1} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} ${payload_format} # Scanning stopped - Retry Action Keyword Verify Webhook By Scanning Stopped Event project${d} webhook${d} ${image2} ${tag2} ${harbor_handle} ${webhook_handle} ${payload_format} + Retry Action Keyword Verify Webhook By Scanning Stopped Event project${d} webhook${d} ${image2} ${tag2} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} ${payload_format} Close Browser Test Case - Tag Retention And Replication Event Type Webhook Functionality By CloudEvents Format @@ -216,9 +216,9 @@ Test Case - Tag Retention And Replication Event Type Webhook Functionality By Cl ${webhook_handle}= Set Variable ${handles}[0] ${harbor_handle}= Set Variable ${handles}[1] # Tag retention finished - Retry Action Keyword Verify Webhook By Tag Retention Finished Event project${d} webhook${d} ${image} ${tag1} ${tag2} ${harbor_handle} ${webhook_handle} ${payload_format} + Retry Action Keyword Verify Webhook By Tag Retention Finished Event project${d} webhook${d} ${image} ${tag1} ${tag2} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} ${payload_format} # Replication status changed - Retry Action Keyword Verify Webhook By Replication Status Changed Event project${d} webhook${d} project_push_dest${d} rule_push_${d} ${harbor_handle} ${webhook_handle} ${payload_format} + Retry Action Keyword Verify Webhook By Replication Status Changed Event project${d} webhook${d} project_push_dest${d} rule_push_${d} ${HARBOR_ADMIN} ${harbor_handle} ${webhook_handle} ${payload_format} Close Browser Test Case - Tag Quota Event Type Webhook Functionality By CloudEvents Format