Skip to content

Commit

Permalink
Add GC details and GC workers UI test case (#19487)
Browse files Browse the repository at this point in the history
Fix #19277

Signed-off-by: Yang Jiao <[email protected]>
  • Loading branch information
YangJiao0817 authored Oct 26, 2023
1 parent 61fdf25 commit 58557d3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
15 changes: 14 additions & 1 deletion tests/resources/Harbor-Pages/GC.robot
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click xpath=${gc_page_xpath} Retry Wait Until Page Contains Element ${gc_now_button}

GC Now
[Arguments] ${untag}=${false} ${dry_run}=${false}
[Arguments] ${untag}=${false} ${dry_run}=${false} ${workers}=${null}
Switch To Garbage Collection
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
${button}= Run Keyword If ${dry_run}==${false} Set Variable ${gc_now_button} ELSE Set Variable ${dry_run_button}
Run Keyword If '${workers}' != '${null}' Select From List By Value ${gc_workers_select} ${workers}
Retry Double Keywords When Error Retry Element Click ${button} Retry Wait Until Page Contains Running
${execution_id}= Get Text ${gc_latest_execution_id}
[Return] ${execution_id}
Expand Down Expand Up @@ -74,3 +75,15 @@ Check GC Log
Wait Until Page Does Not Contain ${log}
END
Switch Window locator=MAIN

Check GC History
[Arguments] ${gc_job_id} ${details} ${trigger_type}=Manual ${dry_run}=No ${status}=SUCCESS
${row}= Set Variable //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]
Wait Until Element Is Visible And Enabled ${row}//clr-dg-cell[2][text()='${trigger_type}']
Wait Until Element Is Visible And Enabled ${row}//clr-dg-cell[3][text()='${dry_run}']
Wait Until Element Is Visible And Enabled ${row}//clr-dg-cell[4][text()='${status}']
Wait Until Element Is Visible And Enabled ${row}//clr-dg-cell[5]//span[contains(text(),'${details}')]

Wait Until GC Complete
[Arguments] ${gc_job_id} ${status}=SUCCESS
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='${status}']
1 change: 1 addition & 0 deletions tests/resources/Harbor-Pages/GC_Elements.robot
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ${gc_schedule_edit_btn} //*[@id='editSchedule']
${gc_schedule_select} //*[@id='selectPolicy']
${gc_schedule_save_btn} //*[@id='config-save']
${gc_latest_execution_id} //clr-dg-row[1]//clr-dg-cell[1]
${gc_workers_select} //*[@id='workers']
53 changes: 37 additions & 16 deletions tests/robot-cases/Group1-Nightly/Common_GC.robot
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Test Case - Garbage Collection
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} redis sha256=e4b315ad03a1d1d9ff0c111e648a1a91066c09ead8352d3d6a48fa971a82922c
Delete Repo project${d} redis
GC Now
GC Now workers=5
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} 7 blobs and 1 manifests eligible for deletion
Retry GC Should Be Successful ${latest_job_id} The GC job actual frees up 34 MB space
Expand All @@ -41,7 +41,7 @@ Test Case - GC Untagged Images
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
GC Now
GC Now workers=4
Create An New Project And Go Into Project project${d}
Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world latest
# make hello-world untagged
Expand All @@ -51,14 +51,14 @@ Test Case - GC Untagged Images
Delete A Tag latest
Should Not Contain Tag latest
# run gc without param delete untagged artifacts checked, should not delete hello-world:latest
GC Now
GC Now workers=3
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} ${null}
Go Into Repo project${d} hello-world
Should Contain Artifact
# run gc with param delete untagged artifacts checked, should delete hello-world
Switch To Garbage Collection
GC Now untag=${true}
GC Now untag=${true} workers=2
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} ${null}
Go Into Repo project${d} hello-world
Expand Down Expand Up @@ -95,18 +95,28 @@ Test Case - Garbage Collection Accessory
${d}= Get Current Date result_format=%m%s
${image}= Set Variable hello-world
${tag}= Set Variable latest
${workers}= Set Variable 1
${deleted_prefix}= Set Variable delete blob from storage:
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
GC Now
${gc_job_id}= GC Now
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 0 blob(s) and 0 manifest(s) deleted, 0 space freed up
${log_containing}= Create List workers: ${workers}
${log_excluding}= Create List
Check GC Log ${gc_job_id} ${log_containing} ${log_excluding}

Create An New Project And Go Into Project project${d}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image}

${sbom_digest} ${signature_digest} ${signature_of_sbom_digest} ${signature_of_signature_digest}= Prepare Accessory project${d} ${image} ${tag} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
# Delete the Signature of Signature
Delete Accessory By Aeecssory XPath ${artifact_cosign_cosign_accessory_action_btn}
${gc_job_id}= GC Now
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='SUCCESS']
${workers}= Set Variable 2
${gc_job_id}= GC Now workers=${workers}
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 2 blob(s) and 1 manifest(s) deleted
${log_containing}= Create List ${deleted_prefix} ${signature_of_signature_digest}
... workers: ${workers}
${log_excluding}= Create List ${deleted_prefix} ${sbom_digest}
... ${deleted_prefix} ${signature_of_sbom_digest}
... ${deleted_prefix} ${signature_digest}
Expand All @@ -115,20 +125,26 @@ Test Case - Garbage Collection Accessory
Retry Button Click ${artifact_list_accessory_btn}
# Delete the Signature
Delete Accessory By Aeecssory XPath ${artifact_cosign_accessory_action_btn}
${gc_job_id}= GC Now
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='SUCCESS']
${workers}= Set Variable 3
${gc_job_id}= GC Now workers=${workers}
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 2 blob(s) and 1 manifest(s) deleted
${log_containing}= Create List ${deleted_prefix} ${signature_digest}
... workers: ${workers}
${log_excluding}= Create List ${deleted_prefix} ${sbom_digest}
... ${deleted_prefix} ${signature_of_sbom_digest}
Check GC Log ${gc_job_id} ${log_containing} ${log_excluding}
Go Into Repo project${d} ${image}
Retry Button Click ${artifact_list_accessory_btn}
# Delete the SBOM
Delete Accessory By Aeecssory XPath ${artifact_sbom_accessory_action_btn}
${gc_job_id}= GC Now
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='SUCCESS']
${workers}= Set Variable 4
${gc_job_id}= GC Now workers=${workers}
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 4 blob(s) and 2 manifest(s) deleted
${log_containing}= Create List ${deleted_prefix} ${sbom_digest}
... ${deleted_prefix} ${signature_of_sbom_digest}
... workers: ${workers}
${log_excluding}= Create List
Check GC Log ${gc_job_id} ${log_containing} ${log_excluding}

Expand All @@ -138,20 +154,25 @@ Test Case - Garbage Collection Accessory
Go Into Artifact ${tag}
Should Contain Tag ${tag}
Delete A Tag ${tag}
${gc_job_id}= GC Now
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='SUCCESS']
${log_containing}= Create List
${workers}= Set Variable 5
${gc_job_id}= GC Now workers=${workers}
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 0 blob(s) and 0 manifest(s) deleted, 0 space freed up
${log_containing}= Create List workers: ${workers}
${log_excluding}= Create List ${deleted_prefix} ${sbom_digest}
... ${deleted_prefix} ${signature_digest}
... ${deleted_prefix} ${signature_of_sbom_digest}
... ${deleted_prefix} ${signature_of_signature_digest}
Check GC Log ${gc_job_id} ${log_containing} ${log_excluding}
${gc_job_id}= GC Now untag=${true}
Wait Until Element Is Visible And Enabled //clr-dg-row[.//clr-dg-cell[text()='${gc_job_id}']]//clr-dg-cell[text()='SUCCESS']
${workers}= Set Variable 5
${gc_job_id}= GC Now workers=${workers} untag=${true}
Wait Until GC Complete ${gc_job_id}
Check GC History ${gc_job_id} 10 blob(s) and 5 manifest(s) deleted
${log_containing}= Create List ${deleted_prefix} ${sbom_digest}
... ${deleted_prefix} ${signature_digest}
... ${deleted_prefix} ${signature_of_sbom_digest}
... ${deleted_prefix} ${signature_of_signature_digest}
... workers: ${workers}
${log_excluding}= Create List
Check GC Log ${gc_job_id} ${log_containing} ${log_excluding}
Close Browser

0 comments on commit 58557d3

Please sign in to comment.