Skip to content

Commit

Permalink
Update webhook and replication testcase
Browse files Browse the repository at this point in the history
Sync test case updates because of changes to webhook and replication
1. goharbor#18923
2. goharbor#18906

Signed-off-by: Yang Jiao <[email protected]>
  • Loading branch information
Yang Jiao committed Jul 24, 2023
1 parent b380b78 commit 43259fd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions tests/resources/Harbor-Pages/Project-P2P-Preheat.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
Expand Down
32 changes: 16 additions & 16 deletions tests/resources/TestCaseBody.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand Down Expand Up @@ -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
Expand All @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions tests/robot-cases/Group1-Nightly/Common_GC.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/robot-cases/Group1-Nightly/Replication.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions tests/robot-cases/Group1-Nightly/Webhook.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 43259fd

Please sign in to comment.