2020-05-22 04:56:03 +02:00
# 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
Resource ../../resources/Util.robot
*** Variables ***
*** Keywords ***
2020-07-21 03:45:13 +02:00
Filter Replication Rule
2020-10-14 10:36:47 +02:00
[Arguments] ${ruleName} ${exist}=${true}
2020-05-22 04:56:03 +02:00
${rule_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${ruleName}')]
Retry Element Click ${filter_rules_btn}
2020-10-14 10:36:47 +02:00
Retry Clear Element Text ${filter_rules_input}
2020-05-22 04:56:03 +02:00
Retry Text Input ${filter_rules_input} ${ruleName}
2020-10-14 10:36:47 +02:00
Run Keyword If ${exist}==${true} Retry Wait Until Page Contains Element ${rule_name_element}
... ELSE Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")]
2020-05-22 04:56:03 +02:00
2020-07-28 08:56:52 +02:00
Filter Registry
[Arguments] ${registry_name}
${registry_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${registry_name}')]
2020-07-30 10:04:14 +02:00
Switch To Replication Manage
Switch To Registries
2020-07-28 08:56:52 +02:00
Retry Element Click ${filter_registry_btn}
2020-07-30 10:04:14 +02:00
Retry Text Input ${filter_registry_input} ${registry_name}
2020-07-28 08:56:52 +02:00
Retry Wait Until Page Contains Element ${registry_name_element}
2020-05-22 04:56:03 +02:00
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}')]
Select Destination URL
[Arguments] ${type}
Retry Element Click ${destination_url_xpath}
Retry Element Click //div[contains(@class, 'selectBox')]//li[contains(.,'${type}')]
Check New Rule UI Without Endpoint
Retry Element Click ${new_replication-rule_button}
Page Should Contain Please add an endpoint first
Retry Element Click ${link_to_registries}
Retry Wait Until Page Contains Endpoint URL
Retry Wait Element ${new_endpoint_button}
Create A New Endpoint
[Arguments] ${provider} ${name} ${url} ${username} ${pwd} ${save}=Y
#click new button
Retry Element Click xpath=${new_endpoint_button}
#input necessary info
Select From List By Value ${provider_selector} ${provider}
Retry Text Input xpath=${destination_name_xpath} ${name}
2020-10-14 10:32:50 +02:00
Run Keyword If '${provider}' == 'harbor' or '${provider}' == 'gitlab' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url}
2020-05-22 04:56:03 +02:00
Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url}
2020-11-10 10:33:09 +01:00
Run Keyword If '${provider}' != 'google-gcr' and '${username}' != '${null}' Retry Text Input xpath=${destination_username_xpath} ${username}
Run Keyword If '${pwd}' != '${null}' Retry Text Input xpath=${destination_password_xpath} ${pwd}
2020-05-22 04:56:03 +02:00
#cancel verify cert since we use a selfsigned cert
Retry Element Click ${destination_insecure_xpath}
Run Keyword If '${save}' == 'Y' Run keyword Retry Double Keywords When Error Retry Element Click ${replication_save_xpath} Retry Wait Until Page Not Contains Element ${replication_save_xpath}
2020-07-28 08:56:52 +02:00
Run Keyword If '${save}' == 'Y' Run keyword Filter Registry ${name}
2020-05-22 04:56:03 +02:00
Run Keyword If '${save}' == 'N' No Operation
Create A Rule With Existing Endpoint
2020-07-21 03:45:13 +02:00
[Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false}
2020-05-22 04:56:03 +02:00
#click new
Retry Element Click ${new_name_xpath}
#input name
Retry Text Input ${rule_name} ${name}
2020-07-16 12:08:10 +02:00
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}
2020-05-22 04:56:03 +02:00
#set filter
2020-07-21 03:45:13 +02:00
Retry Text Input ${filter_name_id} ${filter_project_name}
Run Keyword If '${filter_tag}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag}
2020-05-22 04:56:03 +02:00
Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
#set trigger
Select Trigger ${mode}
2020-07-16 12:08:10 +02:00
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}
Run Keyword If '${mode}' == 'Event Based' and '${del_remote}' == '${true}' Retry Element Click ${del_remote_checkbox}
2020-05-22 04:56:03 +02:00
#click save
Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button}
Sleep 2
Endpoint Is Unpingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains Failed
Endpoint Is Pingable
Retry Element Click ${ping_test_button}
Wait Until Page Contains successfully
Disable Certificate Verification
Checkbox Should Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Enable Certificate Verification
Checkbox Should Not Be Selected ${destination_insecure_checkbox}
Retry Element Click ${destination_insecure_xpath}
Sleep 1
Switch To Registries
Retry Element Click ${nav_to_registries}
Sleep 1
Switch To Replication Manage
Retry Element Click ${nav_to_replications}
Sleep 1
Trigger Replication Manual
[Arguments] ${rule}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
Retry Element Click ${action_bar_replicate}
Retry Wait Until Page Contains Element ${dialog_replicate}
#change from click to mouse down and up
Mouse Down ${dialog_replicate}
Mouse Up ${dialog_replicate}
Sleep 2
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${rule}')]/../div/clr-icon[@shape='success-standard']
Sleep 1
Rename Rule
[Arguments] ${rule} ${newname}
Retry Element Click ${rule_filter_search}
Retry Text Input ${rule_filter_input} ${rule}
Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label
2020-11-04 03:13:12 +01:00
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
2020-05-22 04:56:03 +02:00
Retry Text Input ${rule_name} ${newname}
Retry Element Click ${rule_save_button}
Select Rule
[Arguments] ${rule}
2020-11-04 03:13:12 +01:00
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${rule}')]/div/div[1]/div Retry Wait Element ${replication_rule_exec_id}
2020-05-22 04:56:03 +02:00
Stop Jobs
Retry Element Click ${stop_jobs_button}
View Job Log
[arguments] ${job}
Retry Element Click ${job_filter_search}
Retry Text Input ${job_filter_input} ${job}
Retry Link Click //clr-dg-row[contains(.,'${job}')]//a
2020-11-04 03:13:12 +01:00
Find Registry And Click Edit Button
2020-05-22 04:56:03 +02:00
[Arguments] ${name}
Filter Object ${name}
Retry Select Object ${name}
2020-11-04 03:13:12 +01:00
Retry Element Click ${registry_edit_btn}
2020-05-22 04:56:03 +02:00
2020-10-14 10:36:47 +02:00
Switch To Replication Manage Page
Switch To Registries
Switch To Replication Manage
Click Edit Button
2020-11-04 03:13:12 +01:00
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_edit}
2020-09-28 04:37:43 +02:00
2020-10-14 10:36:47 +02:00
Click Delete Button
2020-11-04 03:13:12 +01:00
Retry Element Click ${replication_rule_action}
Retry Element Click ${replication_rule_action_bar_delete}
2020-05-22 04:56:03 +02:00
2020-10-14 10:36:47 +02:00
Edit Replication Rule
2020-05-22 04:56:03 +02:00
[Arguments] ${name}
2020-10-14 10:36:47 +02:00
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Edit Button
Retry Wait Until Page Contains Edit Replication Rule
2020-05-22 04:56:03 +02:00
2020-10-14 10:36:47 +02:00
Delete Replication Rule
[Arguments] ${name}
Switch To Replication Manage Page
Filter Replication Rule ${name}
Select Rule ${name}
Click Delete Button
Wait Until Page Contains Element ${dialog_delete}
Retry Double Keywords When Error Retry Element Click ${dialog_delete} Retry Wait Until Page Not Contains Element ${dialog_delete}
Filter Replication Rule ${name} exist=${false}
2020-05-22 04:56:03 +02:00
Rename Endpoint
[arguments] ${name} ${newname}
2020-11-04 03:13:12 +01:00
Find Registry And Click Edit Button ${name}
2020-05-22 04:56:03 +02:00
Retry Wait Until Page Contains Element ${destination_name_xpath}
Retry Text Input ${destination_name_xpath} ${newname}
Retry Element Click ${replication_save_xpath}
Delete Endpoint
[Arguments] ${name}
Retry Element Click ${endpoint_filter_search}
Retry Text Input ${endpoint_filter_input} ${name}
#click checkbox before target endpoint
2020-11-04 03:13:12 +01:00
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${name}')]//clr-checkbox-wrapper Retry Wait Element ${registry_del_btn}
Retry Element Click ${registry_del_btn}
2020-05-22 04:56:03 +02:00
Wait Until Page Contains Element ${dialog_delete}
Retry Element Click ${dialog_delete}
Select Rule And Replicate
[Arguments] ${rule_name}
2020-07-17 11:21:22 +02:00
Select Rule ${rule_name}
2020-11-04 03:13:12 +01:00
Retry Element Click ${replication_rule_exec_id}
2020-05-22 04:56:03 +02:00
Retry Double Keywords When Error Retry Element Click xpath=${dialog_replicate} Retry Wait Until Page Not Contains Element xpath=${dialog_replicate}
Image Should Be Replicated To Project
2021-01-04 12:17:51 +01:00
[Arguments] ${project} ${image} ${period}=60 ${times}=3 ${tag}=${null} ${expected_image_size_in_regexp}=${null}
2020-07-30 10:04:14 +02:00
FOR ${n} IN RANGE 0 ${times}
Sleep ${period}
Go Into Project ${project}
Switch To Project Repo
#In AWS-ECR, under repository a, there're only several images: httpd,alpine,hello-world.
${out} Run Keyword And Ignore Error Retry Wait Until Page Contains ${project}/${image}
Log To Console Return value is ${out[0]}
Exit For Loop If '${out[0]}'=='PASS'
Sleep 5
END
2020-05-22 04:56:03 +02:00
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
2020-07-16 12:08:10 +02:00
Should Be Equal As Strings '${out[0]}' 'PASS'
2021-01-04 12:17:51 +01:00
Go Into Repo ${project}/${image}
${size}= Run Keyword If '${tag}'!='${null}' and '${expected_image_size_in_regexp}'!='${null}' Get Text //clr-dg-row[contains(., '${tag}')]//clr-dg-cell[4]/div
Run Keyword If '${tag}'!='${null}' and '${expected_image_size_in_regexp}'!='${null}' Should Match Regexp '${size}' '${expected_image_size_in_regexp}'
2020-07-17 11:21:22 +02:00
Executions Result Count Should Be
[Arguments] ${expected_status} ${expected_trigger_type} ${expected_result_count}
Sleep 10
${count}= Get Element Count xpath=//clr-dg-row[contains(.,'${expected_status}') and contains(.,'${expected_trigger_type}')]
Should Be Equal As Integers ${count} ${expected_result_count}