From 921aa2a27c49c64a3b534398b971dc4b72aecb70 Mon Sep 17 00:00:00 2001 From: Yang Jiao <72076317+YangJiao0817@users.noreply.github.com> Date: Thu, 26 Oct 2023 11:49:50 +0800 Subject: [PATCH] [cherry-pick]Add GC details and GC workers UI test case (#19488) Add GC details and GC workers UI test case Fix #19277 Signed-off-by: Yang Jiao --- tests/resources/Harbor-Pages/GC.robot | 15 +++++- .../resources/Harbor-Pages/GC_Elements.robot | 1 + .../Group1-Nightly/Common_GC.robot | 53 +++++++++++++------ 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/tests/resources/Harbor-Pages/GC.robot b/tests/resources/Harbor-Pages/GC.robot index 25a3ff21f51..c9a99b1bbbd 100644 --- a/tests/resources/Harbor-Pages/GC.robot +++ b/tests/resources/Harbor-Pages/GC.robot @@ -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} @@ -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}'] diff --git a/tests/resources/Harbor-Pages/GC_Elements.robot b/tests/resources/Harbor-Pages/GC_Elements.robot index a87cc02be64..24c601e4b24 100644 --- a/tests/resources/Harbor-Pages/GC_Elements.robot +++ b/tests/resources/Harbor-Pages/GC_Elements.robot @@ -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'] diff --git a/tests/robot-cases/Group1-Nightly/Common_GC.robot b/tests/robot-cases/Group1-Nightly/Common_GC.robot index c94d59c3f9a..53befb63f61 100644 --- a/tests/robot-cases/Group1-Nightly/Common_GC.robot +++ b/tests/robot-cases/Group1-Nightly/Common_GC.robot @@ -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 @@ -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 @@ -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 @@ -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} @@ -115,9 +125,12 @@ 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} @@ -125,10 +138,13 @@ Test Case - Garbage Collection Accessory 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} @@ -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