From 9b51123bd316933b093c5db1ba798f344b3c8058 Mon Sep 17 00:00:00 2001 From: "Danfeng Liu (c)" Date: Fri, 29 Nov 2019 14:28:51 +0800 Subject: [PATCH] 1. Add nightly test case of Robot-Account; 2. In Go Into Repo keyword, filter element should not be clicked since list in loading state, so add some sleep and waiting for the cirlce icon is gone; 3. Move read-only test case in the end of common.robot. Signed-off-by: Danfeng Liu (c) --- tests/resources/Docker-Util.robot | 7 +- tests/resources/Harbor-Pages/Project.robot | 7 +- .../Harbor-Pages/Project_Elements.robot | 1 + .../Harbor-Pages/Project_Robot_Account.robot | 23 +++++ .../Project_Robot_Account_Elements.robot | 9 ++ tests/resources/Util.robot | 2 + tests/robot-cases/Group1-Nightly/Common.robot | 89 +++++++++++-------- 7 files changed, 95 insertions(+), 43 deletions(-) create mode 100644 tests/resources/Harbor-Pages/Project_Robot_Account.robot create mode 100644 tests/resources/Harbor-Pages/Project_Robot_Account_Elements.robot diff --git a/tests/resources/Docker-Util.robot b/tests/resources/Docker-Util.robot index f8e18e1dc..038246c6b 100644 --- a/tests/resources/Docker-Util.robot +++ b/tests/resources/Docker-Util.robot @@ -23,17 +23,18 @@ Run Docker Info Wait Unitl Command Success docker ${docker-params} info Pull image - [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} + [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}=${null} ${is_robot}=${false} Log To Console \nRunning docker pull ${image}... ${image_with_tag}= Set Variable If '${tag}'=='${null}' ${image} ${image}:${tag} - Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip} + Run Keyword If ${is_robot}==${false} Wait Unitl Command Success docker login -u ${user} -p ${pwd} ${ip} + ... ELSE Wait Unitl Command Success docker login -u robot\\\$${user} -p ${pwd} ${ip} ${output}= Wait Unitl Command Success docker pull ${ip}/${project}/${image_with_tag} Should Contain ${output} Digest: Should Contain ${output} Status: Should Not Contain ${output} No such image: Push image - [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${sha256}=${null} + [Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${sha256}=${null} ${is_robot}=${false} ${image_with_sha256}= Set Variable If '${sha256}'=='${null}' ${image} ${image}@sha256:${sha256} ${image_with_tag}= Set Variable If '${sha256}'=='${null}' ${image} ${image}:${sha256} Log To Console \nRunning docker push ${image}... diff --git a/tests/resources/Harbor-Pages/Project.robot b/tests/resources/Harbor-Pages/Project.robot index 2e6c8b628..0518fc73f 100644 --- a/tests/resources/Harbor-Pages/Project.robot +++ b/tests/resources/Harbor-Pages/Project.robot @@ -177,6 +177,8 @@ Do Log Advanced Search Go Into Repo [Arguments] ${repoName} + Sleep 2 + Retry Wait Until Page Not Contains Element ${repo_list_spinner} ${repo_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${repoName}')]/a Retry Element Click ${repo_search_icon} :For ${n} IN RANGE 1 10 @@ -184,12 +186,13 @@ Go Into Repo \ Retry Text Input ${repo_search_input} ${repoName} \ ${out} Run Keyword And Ignore Error Retry Wait Until Page Contains Element ${repo_name_element} \ Exit For Loop If '${out[0]}'=='PASS' - \ Capture Page Screenshot gointo_${repoName}.png \ Sleep 2 + Capture Page Screenshot Retry Double Keywords When Error Retry Element Click ${repo_name_element} Retry Wait Until Page Not Contains Element ${repo_name_element} + Capture Page Screenshot Retry Wait Element ${tag_table_column_pull_command} Retry Wait Element ${tag_images_btn} - Capture Page Screenshot gointo_${repoName}.png + Capture Page Screenshot Switch To CardView Retry Element Click xpath=//hbr-repository-gridview//span[@class='card-btn']/clr-icon diff --git a/tests/resources/Harbor-Pages/Project_Elements.robot b/tests/resources/Harbor-Pages/Project_Elements.robot index 5cb8c9543..4386f1f7e 100644 --- a/tests/resources/Harbor-Pages/Project_Elements.robot +++ b/tests/resources/Harbor-Pages/Project_Elements.robot @@ -42,6 +42,7 @@ ${tag_delete_btn} xpath=//tag-repository//clr-datagrid//button[contains(.,'Dele ${user_delete_btn} xpath=/clr-dropdown-menu//button[contains(.,'Delete')] #${repo_search_icon} xpath=//hbr-filter//clr-icon #${repo_search_input} xpath=//hbr-filter//input +${repo_list_spinner} xpath=//clr-datagrid//clr-spinner ${repo_search_icon} xpath=//hbr-repository-gridview//clr-datagrid//clr-dg-column[contains(.,'Name')]//clr-dg-string-filter//button//clr-icon ${repo_search_input} xpath=//div[@class[contains(.,'datagrid-filter')]]//input ${repo_tag_1st_checkbox} xpath=//clr-datagrid//clr-dg-row//clr-checkbox-wrapper diff --git a/tests/resources/Harbor-Pages/Project_Robot_Account.robot b/tests/resources/Harbor-Pages/Project_Robot_Account.robot new file mode 100644 index 000000000..44e0ef285 --- /dev/null +++ b/tests/resources/Harbor-Pages/Project_Robot_Account.robot @@ -0,0 +1,23 @@ +*** Settings *** + +Resource ../../resources/Util.robot + +*** Variables *** + +*** Keywords *** +Switch To Project Robot Account + Switch To Project Tab Overflow + Retry Element Click ${project_robot_account_tabpage} + Retry Wait Until Page Contains Element ${project_robot_account_create_btn} + +Create A Robot Account And Return Token + [Arguments] ${projectname} ${robot_account_name} ${project_has_image}=${false} + Go Into Project ${projectname} has_image=${project_has_image} + Switch To Project Robot Account + Retry Element Click ${project_robot_account_create_btn} + Retry Text Input ${project_robot_account_create_name_input} ${robot_account_name} + Retry Double Keywords When Error Retry Element Click ${project_robot_account_create_save_btn} Retry Wait Until Page Not Contains Element ${project_robot_account_create_save_btn} + ${token}= Get Value ${project_robot_account_token_input} + [Return] ${token} + + diff --git a/tests/resources/Harbor-Pages/Project_Robot_Account_Elements.robot b/tests/resources/Harbor-Pages/Project_Robot_Account_Elements.robot new file mode 100644 index 000000000..0e8cac590 --- /dev/null +++ b/tests/resources/Harbor-Pages/Project_Robot_Account_Elements.robot @@ -0,0 +1,9 @@ +*** Settings *** +Documentation This resource provides any keywords related to the Harbor robot-account feature + +*** Variables *** +${project_robot_account_tabpage} xpath=//project-detail//a[contains(.,'Robot Accounts')] +${project_robot_account_create_btn} xpath=//project-detail/app-robot-account//button +${project_robot_account_token_input} xpath=//app-robot-account//hbr-copy-input//input +${project_robot_account_create_name_input} //input[@id='robot_name'] +${project_robot_account_create_save_btn} //add-robot//button[contains(.,'SAVE')] diff --git a/tests/resources/Util.robot b/tests/resources/Util.robot index a55eb2d5f..89df63036 100644 --- a/tests/resources/Util.robot +++ b/tests/resources/Util.robot @@ -47,6 +47,8 @@ Resource Harbor-Pages/Project-Retag.robot Resource Harbor-Pages/Project-Retag_Elements.robot Resource Harbor-Pages/Project-Tag-Retention.robot Resource Harbor-Pages/Project-Tag-Retention_Elements.robot +Resource Harbor-Pages/Project_Robot_Account.robot +Resource Harbor-Pages/Project_Robot_Account_Elements.robot Resource Harbor-Pages/Replication.robot Resource Harbor-Pages/Replication_Elements.robot Resource Harbor-Pages/UserProfile.robot diff --git a/tests/robot-cases/Group1-Nightly/Common.robot b/tests/robot-cases/Group1-Nightly/Common.robot index 7a6e57042..ea7f063bd 100644 --- a/tests/robot-cases/Group1-Nightly/Common.robot +++ b/tests/robot-cases/Group1-Nightly/Common.robot @@ -42,20 +42,6 @@ Test Case - Delete A Project Delete A Project Without Sign In Harbor Close Browser -Test Case - Read Only Mode - Init Chrome Driver - ${d}= Get Current Date result_format=%m%s - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} - Create An New Project project${d} - - Enable Read Only - Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest - - Disable Read Only - Sleep 5 - Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest - Close Browser - Test Case - Repo Size Init Chrome Driver ${d}= Get Current Date result_format=%m%s @@ -571,30 +557,6 @@ Test Case - Project Quotas Control Under GC 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 -Test Case - Can Not Retag Image In ReadOnly Mode - Init Chrome Driver - ${random_num1}= Get Current Date result_format=%m%s - ${random_num2}= Evaluate str(random.randint(1000,9999)) modules=random - - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} - Create An New Project project${random_num1} - Create An New Project project${random_num1}${random_num2} - - Go Into Project project${random_num1} has_image=${false} - Sleep 1 - Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${random_num1} redis ${image_tag} - Sleep 1 - Enable Read Only - Go Into Repo project${random_num1}/redis - Retag Image ${image_tag} project${random_num1}${random_num2} ${target_image_name} ${target_tag_value} - Retry Wait Element Not Visible ${repo_retag_confirm_dlg} - Navigate To Projects - Go Into Project project${random_num1}${random_num2} has_image=${false} - Sleep 10 - Go Into Project project${random_num1}${random_num2} has_image=${false} - Disable Read Only - Close Browser - Test Case - Create New Webhook Init Chrome Driver ${d}= Get Current Date result_format=%m%s @@ -646,3 +608,54 @@ Test Case - Tag Retention Execute Dry Run Execute Run Close Browser + +Test Case - Robot Account + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${d} + ${token}= Create A Robot Account And Return Token project${d} robot${d} + Log To Console ${token} + Log ${token} + Push image ${ip} robot${d} ${token} project${d} hello-world:latest is_robot=${true} + Pull image ${ip} robot${d} ${token} project${d} hello-world:latest is_robot=${true} + +Test Case - Read Only Mode + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${d} + + Enable Read Only + Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest + + Disable Read Only + Sleep 5 + Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest + Close Browser + +Test Case - Can Not Retag Image In ReadOnly Mode + Init Chrome Driver + ${random_num1}= Get Current Date result_format=%m%s + ${random_num2}= Evaluate str(random.randint(1000,9999)) modules=random + + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${random_num1} + Create An New Project project${random_num1}${random_num2} + + Go Into Project project${random_num1} has_image=${false} + Sleep 1 + Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${random_num1} redis ${image_tag} + Sleep 1 + Enable Read Only + Go Into Repo project${random_num1}/redis + Retag Image ${image_tag} project${random_num1}${random_num2} ${target_image_name} ${target_tag_value} + Retry Wait Element Not Visible ${repo_retag_confirm_dlg} + Navigate To Projects + Go Into Project project${random_num1}${random_num2} has_image=${false} + Sleep 10 + Go Into Project project${random_num1}${random_num2} has_image=${false} + Disable Read Only + Close Browser + +