Update GC UI Testcase (#16975)

This PR #16941 modifies the GC UI, so update the test cases.
1 Update GC web element xpath.
2 Migrate GC content from Configuration.robot to GC.robot for classification.

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
This commit is contained in:
Yang Jiao 2022-06-13 14:19:32 +08:00 committed by GitHub
parent a2829850b8
commit 9b7289d862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 67 deletions

View File

@ -297,37 +297,6 @@ Delete A Label
Retry Element Click xpath=//clr-modal//div//button[contains(.,'DELETE')]
Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${labelname}')]/../div/clr-icon[@shape='success-standard']
## Garbage Collection
Switch To Garbage Collection
Switch To Configure
Sleep 1
Retry Element Click xpath=${gc_config_page}
Wait Until Page Contains Element ${garbage_collection_xpath}
Retry Element Click xpath=${garbage_collection_xpath}
Set GC Schedule
[Arguments] ${type} ${value}=${null}
Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click ${GC_schedule_edit_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_edit_btn}
Retry Element Click ${GC_schedule_select}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
... ELSE Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${GC_schedule_save_btn} Retry Wait Until Page Not Contains Element ${GC_schedule_save_btn}
Capture Page Screenshot
Click GC Now
Sleep 1
Retry Element Click xpath=${gc_now_xpath}
Sleep 2
View GC Details
Retry Element Click xpath=${gc_log_details_xpath}
Sleep 2
Switch To GC History
Retry Element Click xpath=${gc_log_xpath}
Retry Wait Until Page Contains Job
Add Items To System CVE Allowlist
[Arguments] ${cve_id}
Retry Element Click ${configuration_system_wl_add_btn}

View File

@ -26,11 +26,6 @@ ${config_system_save_button_xpath} //*[@id='config_system_save']
${config_security_save_button_xpath} //*[@id='security_save']
${vulnerbility_save_button_xpath} //*[@id='config-save']
${configuration_xpath} //clr-main-container//clr-vertical-nav//a[contains(.,' Configuration ')]
${garbage_collection_xpath} //*[@id='config-gc']
${gc_log_xpath} //*[@id='gc-log']
${gc_config_page} //clr-vertical-nav-group-children/a[contains(.,'Garbage')]
${gc_now_xpath} //*[@id='gc']/gc-config//button[contains(.,'GC')]
${gc_log_details_xpath} //*[@id='clr-dg-row26']/clr-dg-cell[6]/a
${configuration_system_tabsheet_id} //*[@id='config-system']
${configuration_security_tabsheet_id} //*[@id='config-security']
${configuration_authentication_tabsheet_id} //*[@id="config-auth"]
@ -40,7 +35,6 @@ ${configuration_system_wl_textarea} //*[@id='allowlist-textarea']
${configuration_system_wl_add_confirm_btn} //*[@id='add-to-system']
${configuration_system_wl_delete_a_cve_id_icon} //app-security//form/section//ul/li[1]/a[2]/clr-icon
${configuration_sys_repo_readonly_chb_id} //*[@id='repo_read_only_lbl']
${checkbox_delete_untagged_artifacts} //gc-config//clr-toggle-wrapper/label[contains(@for,'delete_untagged')]
${cfg_auth_automatic_onboarding_checkbox} //clr-checkbox-wrapper//label[contains(@for,'oidcAutoOnboard')]
${cfg_auth_user_name_claim_input} //*[@id='oidcUserClaim']
@ -63,7 +57,3 @@ ${distribution_del_btn_id} //*[@id='distribution-delete']
${distribution_edit_btn_id} //*[@id='distribution-edit']
${filter_dist_btn} //hbr-filter//clr-icon[contains(@class,'search-btn')]
${filter_dist_input} //hbr-filter//input
${GC_schedule_edit_btn} //*[@id='editSchedule']
${GC_schedule_select} //*[@id='selectPolicy']
${GC_schedule_save_btn} //*[@id='config-save']

View File

@ -19,18 +19,14 @@ Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
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] ${harbor_url} ${login_user} ${login_pwd} ${untag}=${false}
[Arguments] ${untag}=${false}
Switch To Garbage Collection
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
Click GC Now
Logout Harbor
Sleep 2
Sign In Harbor ${harbor_url} ${login_user} ${login_pwd}
Switch To Garbage Collection
Sleep 1
#Switch To GC History
#Retry Keyword N Times When Error 60 Retry Wait Until Page Contains Finished
Retry Double Keywords When Error Retry Element Click ${gc_now_button} Retry Wait Until Page Contains Running
Retry GC Should Be Successful
[Arguments] ${history_id} ${expected_msg}
@ -45,9 +41,18 @@ GC Should Be Successful
Should Contain ${output} success to run gc in job.
Get GC Logs
[Arguments]
${cmd}= Set Variable curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/system/gc"
Log All cmd:${cmd}
${rc} ${output}= Run And Return Rc And Output ${cmd}
Log All ${output}
[Return] ${output}
Set GC Schedule
[Arguments] ${type} ${value}=${null}
Switch To Garbage Collection
Retry Double Keywords When Error Retry Element Click ${gc_schedule_edit_btn} Retry Wait Until Page Not Contains Element ${gc_schedule_edit_btn}
Retry Element Click ${GC_schedule_select}
Run Keyword If '${type}'=='custom' Run Keywords Retry Element Click ${vulnerability_dropdown_list_item_custom} AND Retry Text Input ${targetCron_id} ${value}
... ELSE Retry Element Click ${vulnerability_dropdown_list_item_none}
Retry Double Keywords When Error Retry Element Click ${GC_schedule_save_btn} Retry Wait Until Page Not Contains Element ${gc_schedule_save_btn}
Capture Page Screenshot

View File

@ -0,0 +1,25 @@
# Copyright Project Harbor Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
*** Settings ***
Documentation This resource provides any keywords related to the Harbor private registry appliance
*** Variables ***
${gc_page_xpath} //clr-main-container//clr-vertical-nav-group//span[contains(.,'Clean Up')]
${gc_now_button} //*[@id='gc-now']
${checkbox_delete_untagged_artifacts} //gc-config//clr-toggle-wrapper/label[contains(@for,'delete_untagged')]
${latest_job_id_xpath} //clr-datagrid//div//clr-dg-row[1]//clr-dg-cell[1]
${gc_schedule_edit_btn} //*[@id='editSchedule']
${gc_schedule_select} //*[@id='selectPolicy']
${gc_schedule_save_btn} //*[@id='config-save']

View File

@ -55,6 +55,7 @@ Resource Harbor-Pages/UserProfile_Elements.robot
Resource Harbor-Pages/Administration-Users.robot
Resource Harbor-Pages/Administration-Users_Elements.robot
Resource Harbor-Pages/GC.robot
Resource Harbor-Pages/GC_Elements.robot
Resource Harbor-Pages/Configuration.robot
Resource Harbor-Pages/Configuration_Elements.robot
Resource Harbor-Pages/ToolKit.robot

View File

@ -26,23 +26,22 @@ ${HARBOR_ADMIN} admin
Test Case - Garbage Collection
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
GC Now
Create An New Project And Go Into Project project${d}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} redis sha256=e4b315ad03a1d1d9ff0c111e648a1a91066c09ead8352d3d6a48fa971a82922c
Sleep 2
Go Into Project project${d}
Delete Repo project${d} redis
Sleep 2
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry GC Should Be Successful 1 7 blobs and 1 manifests eligible for deletion
Retry GC Should Be Successful 1 The GC job actual frees up 34 MB space
GC Now
${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
Close Browser
Test Case - GC Untagged Images
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
GC Now
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
@ -53,16 +52,18 @@ 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 ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry GC Should Be Successful 2 ${null}
GC Now
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} ${null}
Go Into Project project${d}
Switch To Project Repo
Go Into Repo hello-world
Should Contain Artifact
# run gc with param delete untagged artifacts checked, should delete hello-world
Switch To Garbage Collection
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} untag=${true}
Retry GC Should Be Successful 3 ${null}
GC Now untag=${true}
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} ${null}
Go Into Project project${d}
Switch To Project Repo
Go Into Repo hello-world
@ -79,10 +80,12 @@ Test Case - Project Quotas Control Under GC
${image_a_size}= Set Variable 321.03MiB
${image_a_ver}= Set Variable 6.8.3
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
GC Now
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
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry GC Should Be Successful 4 ${null}
GC Now
${latest_job_id}= Get Text ${latest_job_id_xpath}
Retry GC Should Be Successful ${latest_job_id} ${null}
@{param} Create List project${d}
Retry Keyword When Return Value Mismatch Get Project Storage Quota Text From Project Quotas List 0Byte of ${storage_quota}${storage_quota_unit} 60 @{param}
Close Browser

View File

@ -80,7 +80,6 @@ Test Case - GC Schedule Job
Sleep 50
Go Into Repo ${project_name}/${image}
Switch To Garbage Collection
Switch To GC History
Set GC Schedule custom value=0 */2 * * * *
Sleep 480
Set GC Schedule none