Add 2 UI test cases which is replication rule edit and delete. (#7904)

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2019-06-03 16:58:24 +08:00 committed by GitHub
parent 9d78038940
commit d8b76c482a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 145 additions and 278 deletions

View File

@ -20,6 +20,21 @@ Resource ../../resources/Util.robot
${HARBOR_VERSION} v1.1.1
*** Keywords ***
Select Dest Registry
[Arguments] ${endpoint}
Retry Element Click ${dest_registry_dropdown_list}
Retry Element Click ${dest_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Source Registry
[Arguments] ${endpoint}
Retry Element Click ${src_registry_dropdown_list}
Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')]
Select Trigger
[Arguments] ${mode}
Retry Element Click ${rule_trigger_select}
Retry Element Click ${rule_trigger_select}//option[contains(.,'${mode}')]
Check New Rule UI Without Endpoint
Retry Element Click ${new_replication-rule_button}
Page Should Contain Please add an endpoint first
@ -44,69 +59,26 @@ Create A New Endpoint
Run Keyword If '${save}' == 'N' No Operation
Create A Rule With Existing Endpoint
[Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace_input}
[Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push}
... AND Retry Element Click //select[@id='dest_registry']
... AND Retry Element Click //select[@id='dest_registry']//option[contains(.,'${endpoint}')]
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull}
... AND Retry Element Click //select[@id='src_registry_id']
... AND Retry Element Click //select[@id='src_registry_id']//option[contains(.,'${endpoint}')]
Run Keyword If '${replication_mode}' == 'push' Run Keywords Retry Element Click ${replication_mode_radio_push}
... AND Select Dest Registry ${endpoint}
... ELSE Run Keywords Retry Element Click ${replication_mode_radio_pull}
... AND Select Source Registry ${endpoint}
#set filter
Retry Text Input ${source_project} ${project_name}
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace_input}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
#set trigger
Retry Element Click //select[@id='ruleTrigger']
Retry Element Click //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
Select Trigger ${mode}
Run Keyword If '${mode}' == 'Scheduled' Log To Console Scheduled
#click save
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
Project Create A Rule With Existing Endpoint
# day 1=Monday..7=Sunday timeformat 12hour+am/pm
[Arguments] ${name} ${project_name} ${endpoint} ${mode} ${plan}=Daily ${weekday}=1 ${time}=0800a
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
#input descripiton,here skip, leave it blank
#in this keyword, source project is not need to input
#set filter
Retry Element Click ${source_image_filter_add}
Retry Text Input ${source_iamge_repo_filter} *
Retry Element Click ${source_image_filter_add}
Retry Text Input ${source_image_tag_filter} *
#select endpoint
Retry Element Click ${rule_target_select}
Wait Until Element Is Visible //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
Retry Element Click //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
#set trigger
Retry Element Click ${rule_trigger_select}
Wait Until Element Is Visible //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
Retry Element Click //select[@id='ruleTrigger']//option[contains(.,'${mode}')]
Run Keyword If '${mode}' == 'Scheduled' Setting Replication Schedule ${plan} ${weekday} ${time}
#click save
Retry Element Click ${rule_save_button}
Setting Replication Schedule
[Arguments] ${plan} ${weekday}=1 ${time}=0800a
Retry Element Click ${schedule_type_select}
Wait Until Element Is Visible //select[@name='scheduleType']/option[@value='${plan}']
Retry Element Click //select[@name='scheduleType']/option[@value='${plan}']
Run Keyword If '${plan}' == 'Weekly' Setting Replication Weekday ${weekday}
Retry Text Input ${shcedule_time} ${time}
Setting Replication Weekday
[arguments] ${day}
Retry Element Click ${schedule_day_select}
Wait Until Element Is Visible //select[@name='scheduleDay']/option[@value='${day}']
Retry Element Click //select[@name='scheduleDay']/option[@value='${day}']
Endpoint Is Unpingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains Failed
@ -187,11 +159,39 @@ View Job Log
Retry Text Input ${job_filter_input} ${job}
Retry Link Click //clr-dg-row[contains(.,'${job}')]//a
Find Item And Click Edit Button
[Arguments] ${name}
Filter Object ${name}
Retry Select Object ${name}
Retry Element Click ${action_bar_edit}
Find Item And Click Delete Button
[Arguments] ${name}
Filter Object ${name}
Retry Select Object ${name}
Retry Element Click ${action_bar_delete}
Edit Replication Rule By Name
[Arguments] ${name}
Switch To Registries
Switch To Replication Manage
Find Item And Click Edit Button ${name}
Delete Replication Rule By Name
[Arguments] ${name}
Switch To Registries
Switch To Replication Manage
Find Item And Click Delete Button ${name}
Ensure Delete Replication Rule By Name
[Arguments] ${name}
Delete Replication Rule By Name ${name}
Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn}
Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")]
Rename Endpoint
[arguments] ${name} ${newname}
Filter Object ${name}
Select Object ${name}
Retry Element Click ${action_bar_edit}
Find Item And Click Edit Button ${name}
Retry Wait Until Page Contains Element ${destination_name_xpath}
Retry Text Input ${destination_name_xpath} ${newname}
Retry Element Click ${replication_save_xpath}

View File

@ -75,6 +75,13 @@ ${filter_tag} //*[@id='filter_tag']
${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')]
${enable_rule_xpath} //label[contains(.,'Enable rule')]
${targetCron_id} //*[@id='targetCron']
${rule_name_input} //*[@id='ruleName']
${src_registry_dropdown_list} //select[@id='src_registry_id']
${dest_registry_dropdown_list} //select[@id='dest_registry']
${rule_confirm_btn} //*[@id='ruleBtnOk']
${rule_cancel_btn} //*[@id='ruleBtnCancel']

View File

@ -131,9 +131,32 @@ Retry Wait Until Page Not Contains Element
@{param} Create List ${element_xpath}
Retry Action Keyword Wait Until Page Does Not Contain Element @{param}
Retry Select Object
[Arguments] ${obj_name}
@{param} Create List ${obj_name}
Retry Action Keyword Select Object @{param}
Retry Textfield Value Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And Textfield Value Should Be @{param}
Retry List Selection Should Be
[Arguments] ${element} ${text}
@{param} Create List ${element} ${text}
Retry Action Keyword Wait And List Selection Should Be @{param}
Link Click
[Arguments] ${element_xpath}
Click Link ${element_xpath}
Wait And List Selection Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
List Selection Should Be ${element} ${text}
Wait And Textfield Value Should Be
[Arguments] ${element} ${text}
Wait Until Element Is Visible And Enabled ${element}
Textfield Value Should Be ${element} ${text}
Element Click
[Arguments] ${element_xpath}
@ -150,6 +173,12 @@ Text Input
Wait Until Element Is Visible And Enabled ${element_xpath}
Input Text ${element_xpath} ${text}
Clear Field Of Characters
[Arguments] ${field} ${character count}
[Documentation] This keyword pushes the delete key (ascii: \8) a specified number of times in a specified field.
: FOR ${index} IN RANGE ${character count}
\ Press Key ${field} \\8
Wait Unitl Vul Data Ready
[Arguments] ${url} ${timeout} ${interval}
${n}= Evaluate ${timeout}/${interval}

View File

@ -90,6 +90,61 @@ Test Case - Harbor Endpoint Delete
Delete Success deletea
Close Browser
Test Case - Replication Rule Edit
Init Chrome Driver
${d}= Get Current Date result_format=%M%S
${endpoint1}= Set Variable e1${d}
${endpoint2}= Set Variable e2${d}
${rule_name_old}= Set Variable rule_testabc${d}
${rule_name_new}= Set Variable rule_abctest${d}
${resource_type}= Set Variable chart
${dest_namespace}= Set Variable dest_namespace${d}
${mode}= Set Variable Scheduled
${cron_str}= Set Variable 10 10 10 * * *
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y
Create A New Endpoint harbor ${endpoint2} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name_old} pull danfengliu/* image ${endpoint1} project${d}
Edit Replication Rule By Name ${rule_name_old}
# Change rule-name, source-registry, filter, trigger-mode for edition verification
Clear Field Of Characters ${rule_name_input} 30
Retry Text Input ${rule_name_input} ${rule_name_new}
Select Source Registry ${endpoint2}
#Source Resource Filter
Retry Text Input ${source_project} project${d}
Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
Select Trigger ${mode}
Retry Text Input ${targetCron_id} ${cron_str}
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
# verify all items were changed as expected
Edit Replication Rule By Name ${rule_name_new}
Retry Textfield Value Should Be ${rule_name_input} ${rule_name_new}
Retry List Selection Should Be ${src_registry_dropdown_list} ${endpoint2}-https://${ip}
Retry Textfield Value Should Be ${source_project} project${d}
Retry Textfield Value Should Be ${dest_namespace_xpath} ${dest_namespace}
Retry List Selection Should Be ${rule_resource_selector} ${resource_type}
Retry List Selection Should Be ${rule_trigger_select} ${mode}
Retry Textfield Value Should Be ${targetCron_id} ${cron_str}
Retry Element Click ${rule_cancel_btn}
Ensure Delete Replication Rule By Name ${rule_name_new}
Close Browser
Test Case - Replication Rule Delete
Init Chrome Driver
${d}= Get Current Date result_format=%M%S
${endpoint1}= Set Variable e1${d}
${rule_name}= Set Variable rule_testabc${d}
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y
Switch To Replication Manage
Create A Rule With Existing Endpoint ${rule_name} pull danfengliu/* image ${endpoint1} project${d}
Ensure Delete Replication Rule By Name ${rule_name}
Close Browser
Test Case - Replication Of Pull Images from DockerHub To Self
Init Chrome Driver
${d}= Get Current Date result_format=%M%S
@ -192,4 +247,4 @@ Test Case - Replication Of Push Images from Self To Harbor By Push Event
Go Into Project project_dest${d}
Switch To Project Repo
Retry Wait Until Page Contains project_dest${d}/centos
Close Browser
Close Browser

View File

@ -1,224 +0,0 @@
// 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 Harbor BATs
Library ../../apitests/python/library/Harbor.py ${SERVER_CONFIG}
Resource ../../resources/Util.robot
Default Tags Replication
*** Variables ***
${HARBOR_URL} https://${ip}
${SSH_USER} root
${HARBOR_ADMIN} admin
${SERVER} ${ip}
${SERVER_URL} https://${SERVER}
${SERVER_API_ENDPOINT} ${SERVER_URL}/api
&{SERVER_CONFIG} endpoint=${SERVER_API_ENDPOINT} verify_ssl=False
${REMOTE_SERVER} ${ip1}
${REMOTE_SERVER_URL} https://${REMOTE_SERVER}
${REMOTE_SERVER_API_ENDPOINT} ${REMOTE_SERVER_URL}/api
*** Test Cases ***
Test Case - Get Harbor Version
#Just get harbor version and log it
Get Harbor Version
Test Case - Pro Replication Rules Add
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Check New Rule UI Without Endpoint
Close Browser
Test Case - Endpoint Verification
#This case need vailid info and selfsign cert
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint edp1${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} N
Endpoint Is Pingable
Enable Certificate Verification
Endpoint Is Unpingable
Close Browser
Test Case - Endpoint Add
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint testabc https://${d} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Wait Until Page Contains testabc
Close Browser
Test Case - Endpoint Edit
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Rename Endpoint testabc deletea
Wait Until Page Contains deletea
Close Browser
Test Case - Endpoint Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Delete Endpoint deletea
Delete Success deletea
Close Browser
Test Case - Rule Edit
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}
Switch To Registries
Create A New Endpoint e${d} https://ip ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} project${d} e${d} Immediate
Rename Rule rule${d} newname
Wait Until Page Contains newname
Close Browser
Test Case - Rule Delete
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Delete Rule newname
Delete Success newname
Close Browser
Test Case - Trigger Immediate
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}
Switch To Registries
Create A New Endpoint edp${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} project${d} edp${d} Immediate
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
Logout Harbor
#logout and login target
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project project${d}
Page Should Contain hello-world
Go Into Repo hello-world
Page Should Contain latest
Close Browser
Test Case - Trigger Manual
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}
#using existing endpoint added before for only one replication endpoint
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} project${d} edp Manual
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
Trigger Replication Manual rule${d}
Logout Harbor
#logout and login target
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project project${d}
Page Should Contain hello-world
Go Into Repo hello-world
Page Should Contain latest
Close Browser
Test Case - Large Image Replicate
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}
Push Image with tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ubuntu 16.04 16.04
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} project${d} edp Immediate
Logout Harbor
#logout and login target
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project project${d}
Page Should Contain ubuntu
Go Into Repo ubuntu
Page Should Contain 16.04
Close Browser
Test Case - Proj Replication Jobs Log View
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}
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox
Switch To Registries
Create A New Endpoint edp${d} aaa ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Replication Manage
Create A Rule With Existing Endpoint rule${d} project${d} edp${d} Immediate
Filter Rule rule${d}
Select Rule rule${d}
Wait Until Page Contains transfer
Wait Until Page Contains error
View Job Log busybox
Close Browser
Test Case - Project LeveL Replication Operation
Init Chrome Driver
${d} = Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project proj${d}
Go Into Project proj${d} has_image=${false}
Switch To Replication
Project Create A Rule With Existing Endpoint rule${d} proj${d} edp Manual
Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} proj${d} hello-world
Trigger Replication Manual rule${d}
Logout Harbor
Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Go Into Project proj${d}
Page Should Contain hello-world
Go Into Repo hello-world
Page Should Contain latest
Close Browser
Test Case - Replicate based on label
${project_id} ${project_name} = Create Project
Docker Pull hello-world:latest
Docker Login ${SERVER} admin Harbor12345
Docker Tag hello-world:latest ${SERVER}/${project_name}/hello-world:1.0
Docker Push ${SERVER}/${project_name}/hello-world:1.0
Docker Tag hello-world:latest ${SERVER}/${project_name}/hello-world:2.0
Docker Push ${SERVER}/${project_name}/hello-world:2.0
${label_id} ${label_name} = Create Label
Add Label To Image ${label_id} ${project_name}/hello-world 1.0
${registry_id} = Get Registry Id By Endpoint ${REMOTE_SERVER_URL}
${projects} = Create List ${project_id}
${registries} = Create List ${registry_id}
${label_filter} = Create Dictionary kind=label value=${label_id}
${filters} = Create List ${label_filter}
${rule_id} ${rule_name} = Create Replication Rule ${projects} ${registries} filters=${filters}
Start Replication ${rule_id}
Wait Until Jobs Finish ${rule_id}
Image Should Exist ${project_name}/hello-world 1.0 endpoint=${REMOTE_SERVER_API_ENDPOINT} verify_ssl=False
Image Should Not Exist ${project_name}/hello-world 2.0 endpoint=${REMOTE_SERVER_API_ENDPOINT} verify_ssl=False