Add replication autotest (#4406)

This commit is contained in:
sigsbee 2018-03-20 13:25:03 +08:00 committed by Yan
parent 28f0e6cd02
commit 80e39c39d3
6 changed files with 342 additions and 33 deletions

View File

@ -49,13 +49,14 @@ Push image
${rc}= Run And Return Rc docker logout ${ip}
Push Image With Tag
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag}
#tag1 is tag of image on docker hub,default latest,use a version existing if you do not want to use latest
[Arguments] ${ip} ${user} ${pwd} ${project} ${image} ${tag} ${tag1}=latest
Log To Console \nRunning docker push ${image}...
${rc}= Run And Return Rc docker pull ${image}
${rc}= Run And Return Rc docker pull ${image}:${tag1}
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
Log ${output}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc docker tag ${image} ${ip}/${project}/${image}:${tag}
${rc}= Run And Return Rc docker tag ${image}:${tag1} ${ip}/${project}/${image}:${tag}
${rc} ${output}= Run And Return Rc And Output docker push ${ip}/${project}/${image}:${tag}
Log ${output}
Should Be Equal As Integers ${rc} 0
@ -146,4 +147,4 @@ Docker Login Fail
${rc} ${output}= Run And Return Rc And Output docker login -u ${user} -p ${pwd} ${ip}
Should Not Be Equal As Integers ${rc} 0
Should Contain ${output} unauthorized: authentication required
Should Not Contain ${output} 500 Internal Server Error
Should Not Contain ${output} 500 Internal Server Error

View File

@ -20,25 +20,158 @@ Resource ../../resources/Util.robot
${HARBOR_VERSION} v1.1.1
*** Keywords ***
Create An New Rule With New Endpoint
[Arguments] ${policy_name} ${policy_description} ${destination_name} ${destination_url} ${destination_username} ${destination_password}
Check New Rule UI Without Endpoint
Click Element ${new_replication-rule_button}
Page Should Contain Please add an endpoint first
Click Element ${link_to_registries}
Page Should Contain Endpoint Name
Click element ${new_name_xpath}
Sleep 2
Input Text xpath=${policy_name_xpath} ${policy_name}
Input Text xpath=${policy_description_xpath} ${policy_description}
Create A New Endpoint
[Arguments] ${name} ${url} ${username} ${pwd} ${save}=Y
#click new button
Click Element xpath=${new_endpoint_button}
#input necessary info
Input Text xpath=${destination_name_xpath} ${name}
Input Text xpath=${destination_url_xpath} ${url}
Input Text xpath=${destination_username_xpath} ${username}
Input Text xpath=${destination_password_xpath} ${pwd}
#cancel verify cert since we use a selfsigned cert
Click Element ${destination_insecure_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Click Element ${replicaton_save_xpath}
Run Keyword If '${save}' == 'N' No Operation
#Click element xpath=${policy_enable_checkbox}
#enable attribute is droped in new ui
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
Click Element ${new_name_xpath}
#input name
Input Text ${rule_name} ${name}
#input descripiton,here skip, leave it blank
#source projects, input
Input Text ${source_project} ${project_name}
#set filter
Click Element ${source_image_filter_add}
Input Text ${source_iamge_repo_filter} *
Click Element ${source_image_filter_add}
Input Text ${source_image_tag_filter} *
#select endpoint
Click Element ${rule_target_select}
Wait Until Element Is Visible //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
Click Element //select[@id='ruleTarget']//option[contains(.,'${endpoint}')]
#set trigger
Click Element ${rule_trigger_select}
Wait Until Element Is Visible //select[@id="ruleTrigger"]//option[contains(.,'${mode}')]
Click Element //select[@id="ruleTrigger"]//option[contains(.,'${mode}')]
Run Keyword If '${mode}' == 'Scheduled' Setting Replicaiton Schedule ${plan} ${weekday} ${time}
#click save
Click Element ${rule_save_button}
Click element xpath=${policy_endpoint_checkbox}
Setting Replication Schedule
[Arguments] ${plan} ${weekday}=1 ${time}=0800a
Click Element ${schedule_type_select}
Wait Until Element Is Visible //select[@name="scheduleType"]/option[@value="${plan}"]
Click Element //select[@name="scheduleType"]/option[@value="${plan}"]
Run Keyword If '${plan}' == 'Weekly' Setting Replication Weekday ${weekday}
Input Text ${shcedule_time} ${time}
Click element xpath=//*[@id="ruleBtnOk"]
Sleep 5
Capture Page Screenshot rule_${policy_name}.png
Wait Until Page Contains ${policy_name}
Setting Replication Weekday
[arguments] ${day}
Click Element ${schedule_day_select}
Wait Until Element Is Visible //select[@name="scheduleDay"]/option[@value='${day}']
Click Element //select[@name="scheduleDay"]/option[@value='${day}']
Wait Until Page Contains ${policy_description}
Wait Until Page Contains ${destination_name}
Endpoint Is Unpingable
Click Element ${ping_test_button}
Wait Until Page Contains Failed
Endpoint Is Pingable
Click Element ${ping_test_button}
Wait Until Page Contains successfully
Disable Certificate Verification
Checkbox Should Be Selected ${destination_insecure_checkbox}
Click Element ${destination_insecure_xpath}
Sleep 1
Enable Certificate Verification
Checkbox Should Not Be Selected ${destination_insecure_checkbox}
Click Element ${destination_insecure_xpath}
Sleep 1
Switch To Registries
Click Element ${nav_to_registries}
Sleep 1
Switch To Replication Manage
Click Element ${nav_to_replications}
Sleep 1
Trigger Replication Manual
[Arguments] ${rule}
Click Element ${rule_filter_search}
Input Text ${rule_filter_input} ${rule}
Sleep 1
Click Element //clr-dg-row[contains(.,'${rule}')]//label
Click Element ${action_bar_replicate}
Wait Until Page Contains Element ${dialog_replicate}
Click Element ${dialog_replicate}
Wait Until Page Contains successfully
Click Element ${dialog_close}
Rename Rule
[Arguments] ${rule} ${newname}
Click Element ${rule_filter_search}
Input Text ${rule_filter_input} ${rule}
Sleep 1
Click Element //clr-dg-row[contains(.,'${rule}')]//label
Click Element ${action_bar_edit}
Input Text ${rule_name} ${newname}
Click Element ${rule_save_button}
Delete Rule
[Arguments] ${rule}
Click Element ${rule_filter_search}
Input Text ${rule_filter_input} ${rule}
Sleep 1
Click Element //clr-dg-row[contains(.,'${rule}')]//label
Click Element ${action_bar_delete}
Wait Until Page Contains Element ${dialog_delete}
Click Element ${dialog_delete}
Wait Until Page Contains Element ${dialog_close}
Click Element ${dialog_close}
Stop Jobs
Click Element ${stop_jobs_button}
View Job Log
[arguments] ${job}
Click Element ${job_filter_search}
Input Text ${job_filter_input} ${job}
Click Element //clr-dg-row[contains(.,'${job}')]//a
Wait Until Page Contains View Replication Job Log
Click Element ${dialog_close}
Sleep 1
Rename Endpoint
[arguments] ${name} ${newname}
Filter Object ${name}
Select Object ${name}
Click Element ${action_bar_edit}
Wait Until Page Contains Element ${destination_name_xpath}
Input Text ${destination_name_xpath} ${newname}
Click Element ${replicaton_save_xpath}
Delete Endpoint
[Arguments] ${name}
Click Element ${endpoint_filter_search}
Input Text ${endpoint_filter_input} ${name}
Sleep 1
#click checkbox before target endpoint
Click Element //clr-dg-row[contains(.,'${name}')]//label
Click Element ${action_bar_delete}
Wait Until Page Contains Element ${dialog_delete}
Click Element ${dialog_delete}
Wait Until Page Contains success
Click Element ${dialog_close}

View File

@ -26,4 +26,37 @@ ${destination_url_xpath} //*[@id='destination_url']
${destination_username_xpath} //*[@id='destination_username']
${destination_password_xpath} //*[@id='destination_password']
${replicaton_save_xpath} //button[contains(.,'OK')]
${replication_xpath} //clr-vertical-nav-group-children/a[contains(.,'Replication')]
${replication_xpath} //clr-vertical-nav-group-children/a[contains(.,'Replication')]
${destination_insecure_xpath} //clr-checkbox[@id="destination_insecure"]//label
${new_replication-rule_button} //button[contains(.,'New Replication Rule')]
${link_to_registries} //clr-modal//span[contains(.,'Registries')]
${new_endpoint_button} //hbr-endpoint//button[contains(.,'New')]
${rule_name} //input[@id='ruleName']
${source_project} //input[@value='name']
${source_image_filter_add} //hbr-create-edit-rule/clr-modal/div/div[1]/div/div[1]/div/div[2]/form/section/div[4]/clr-icon
${source_iamge_repo_filter} //hbr-create-edit-rule//section/div[4]/div/div[1]/div/label/input
${source_image_tag_filter} //hbr-create-edit-rule//section/div[4]/div/div[2]/div/label/input
${rule_target_select} //select[@id='ruleTarget']
${rule_trigger_select} //select[@id="ruleTrigger"]
${schedule_type_select} //select[@name="scheduleType"]
${schedule_day_select} //select[@name="scheduleDay"]
${shcedule_time} //input[@type="time"]
${destination_insecure_checkbox} //hbr-create-edit-endpoint/clr-modal//clr-checkbox/input[@id="clr-checkbox-destination_insecure"]
${ping_test_button} //button[contains(.,'Test')]
${nav_to_registries} //clr-vertical-nav//span[contains(.,'Registries')]
${nav_to_replications} //clr-vertical-nav//span[contains(.,'Replications')]
${rule_filter_search} //hbr-replication/div/div[1]//hbr-filter/span/clr-icon
${rule_filter_input} //hbr-replication/div/div[1]//hbr-filter/span//input
${job_filter_search} //hbr-replication/div/div[3]//hbr-filter/span/clr-icon
${job_filter_input} //hbr-replication/div/div[3]//hbr-filter/span//input
${endpoint_filter_search} //hbr-filter/span/clr-icon
${endpoint_filter_input} //hbr-filter/span//input
${action_bar_edit} //button[contains(.,'Edit')]
${action_bar_delete} //button[contains(.,'Delete')]
${stop_jobs_button} //button[contains(.,'Stop Jobs')]
${dialog_close} //clr-modal//button[contains(.,'CLOSE')]
${dialog_delete} //clr-modal//button[contains(.,'DELETE')]
${dialog_replicate} //clr-modal//button[contains(.,'REPLICATE')]
${action_bar_replicate} //button[contains(.,'Replicate')]
${rule_save_button} //button[contains(.,'SAVE')]

View File

@ -35,6 +35,7 @@ Scan Is Disabled
Page Should Contain Element //button[contains(.,'Scan') and @disabled='']
Move To Summary Chart
Sleep 2
Mouse Over //hbr-vulnerability-summary-chart
Sleep 1
@ -44,8 +45,8 @@ Scan Repo
#select one tag
Click Element //clr-dg-row[contains(.,"${tagname}")]//label
Click Element //button[contains(.,'Scan')]
Run Keyword If '${status}' == 'Succeed' Wait Until Page Contains Element //hbr-vulnerability-bar//hbr-vulnerability-summary-chart
Run Keyword If '${status}' == 'Fail' Wait Until Page Contains Element //hbr-vulnerability-bar//a
Run Keyword If '${status}' == 'Succeed' Wait Until Element Is Visible //hbr-vulnerability-bar//hbr-vulnerability-summary-chart
Run Keyword If '${status}' == 'Fail' Wait Until Element Is Visible //hbr-vulnerability-bar//a
Summary Chart Should Display

View File

@ -254,16 +254,6 @@ Test Case - Edit Token Expire
Modify Token Expiration 30
Close Browser
#Test Case - Create An Replication Rule New Endpoint
# 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}
# Go Into Project project${d}
# Switch To Replication
# Create An New Rule With New Endpoint policy_name=test_policy_${d} policy_description=test_description destination_name=test_destination_name_${d} destination_url=test_destination_url_${d} destination_username=test_destination_username destination_password=test_destination_password
# Close Browser
Test Case - Scan A Tag In The Repo
Init Chrome Driver
${d}= get current date result_format=%m%s

View File

@ -0,0 +1,151 @@
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// 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
Resource ../../resources/Util.robot
Suite Setup Nightly Test Setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} ${ip1}
Suite Teardown Collect Nightly Logs ${ip} ${SSH_PWD} ${ip1}
Default Tags Replication
*** Variables ***
${HARBOR_URL} https://${ip}
${SSH_USER} root
${HARBOR_ADMIN} admin
*** Test Cases ***
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 #Temp disable for ui is unstable
# 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
# Wait Until Page Does Not Contain 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
Wait Until Page Does Not Contain 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 - 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
Wait Until Page Contains transfer
# Stop Jobs #temp disable
# Wait Until Page Contains stopped
View Job Log busybox
Close Browser