From e9c5b3e75981e13cf204fcf0f1f608ae9f1c530f Mon Sep 17 00:00:00 2001 From: Yang Jiao Date: Thu, 18 Nov 2021 15:02:21 +0800 Subject: [PATCH] Add replication testcase for exclude and bandwidth Signed-off-by: Yang Jiao --- .../resources/Harbor-Pages/Replication.robot | 31 ++++++++++- .../Harbor-Pages/Replication_Elements.robot | 5 ++ .../Group1-Nightly/Replication.robot | 51 +++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/tests/resources/Harbor-Pages/Replication.robot b/tests/resources/Harbor-Pages/Replication.robot index 5ccd0377c..c2f6a425c 100644 --- a/tests/resources/Harbor-Pages/Replication.robot +++ b/tests/resources/Harbor-Pages/Replication.robot @@ -49,6 +49,27 @@ Select Source Registry Retry Element Click ${src_registry_dropdown_list} Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')] +Select Filter Tag Model + [Arguments] ${type} + Retry Element Click ${filter_tag_model_select} + Retry Element Click ${filter_tag_model_select}//option[contains(.,'${type}')] + +Select Filter Label Model + [Arguments] ${type} + Retry Element Click ${filter_label_model_select} + Retry Element Click ${filter_label_model_select}//option[contains(.,'${type}')] + +Select Filter Label + [Arguments] ${label} + Retry Element Click ${filter_label_button} + Retry Element Click //div[@class='filterSelect ng-star-inserted'][3]//label[contains(text(), '${label}')] + Retry Element Click ${filter_label_button} + +Select Bandwidth Unit + [Arguments] ${unit} + Retry Element Click ${bandwidth_unit_select} + Retry Element Click ${bandwidth_unit_select}//option[contains(.,'${unit}')] + Select flattening [Arguments] ${type} Retry Element Click ${flattening_select} @@ -91,7 +112,8 @@ Create A New Endpoint Create A Rule With Existing Endpoint [Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace} - ... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false} ${flattening}=Flatten 1 Level + ... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false} ${filter_tag_model}=matching ${filter_label}=${false} ${filter_label_model}=matching + ... ${flattening}=Flatten 1 Level ${bandwidth}=-1 ${bandwidth_unit}=Kbps #click new Retry Element Click ${new_name_xpath} #input name @@ -101,7 +123,10 @@ Create A Rule With Existing Endpoint #set filter Retry Text Input ${filter_name_id} ${filter_project_name} + Run Keyword If '${filter_tag_model}' != 'matching' Select Filter Tag Model ${filter_tag_model} Run Keyword If '${filter_tag}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag} + Run Keyword If '${filter_label_model}' != 'matching' Select Filter Label Model ${filter_label_model} + Run Keyword If '${filter_label}' != '${false}' Select Filter Label ${filter_label} Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type} Retry Text Input ${dest_namespace_xpath} ${dest_namespace} Select flattening ${flattening} @@ -109,6 +134,10 @@ Create A Rule With Existing Endpoint Select Trigger ${mode} 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} + #set bandwidth + Run Keyword If '${bandwidth}' != '-1' Retry Text Input ${bandwidth_input} ${bandwidth} + Run Keyword If '${bandwidth_unit}' != 'Kbps' Select Bandwidth Unit ${bandwidth_unit} + #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 diff --git a/tests/resources/Harbor-Pages/Replication_Elements.robot b/tests/resources/Harbor-Pages/Replication_Elements.robot index 7904f022e..4144f396a 100644 --- a/tests/resources/Harbor-Pages/Replication_Elements.robot +++ b/tests/resources/Harbor-Pages/Replication_Elements.robot @@ -62,11 +62,16 @@ ${provider_selector} //*[@id='adapter'] ${replication_mode_radio_push} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Push-based')] ${replication_mode_radio_pull} //clr-main-container//hbr-create-edit-rule//label[contains(.,'Pull-based')] ${filter_name_id} //input[@id='filter_name'] +${filter_tag_model_select} //div[@class='filterSelect ng-star-inserted'][2]//select ${filter_tag_id} //input[@id='filter_tag'] +${filter_label_button} //div[@class='filterSelect ng-star-inserted'][3]//button +${filter_label_model_select} //div[@class='filterSelect ng-star-inserted'][3]//select ${rule_resource_selector} //*[@id='select_resource'] ${trigger_mode_selector} //*[@id='ruleTrigger'] ${dest_namespace_xpath} //*[@id='dest_namespace'] ${new_replication_rule_id} //*[@id='new_replication_rule_id'] +${bandwidth_input} //*[@id='speed'] +${bandwidth_unit_select} //*[@id='speed_unit'] ${registry_edit_btn} //button[contains(.,'Edit')] ${registry_del_btn} //button[contains(.,'Delete')] diff --git a/tests/robot-cases/Group1-Nightly/Replication.robot b/tests/robot-cases/Group1-Nightly/Replication.robot index 1d77ed7ce..be616422d 100644 --- a/tests/robot-cases/Group1-Nightly/Replication.robot +++ b/tests/robot-cases/Group1-Nightly/Replication.robot @@ -188,6 +188,57 @@ Test Case - Replication Of Push Images from Self To Harbor Image Should Be Replicated To Project project_dest${d} busybox Close Browser +Test Case - Replication Exclusion Mode And Set Bandwidth + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + # login source + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project And Go Into Project project${d} + Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world:latest + Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest + Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} alpine:3.10 + + # push mode + Switch To System Labels + Create New Labels bad_${d} + Go Into Project project${d} + Go Into Repo project${d}/busybox + Add Labels To Tag latest bad_${d} + Switch To Registries + Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Replication Manage + Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d} filter_tag=3.10 filter_tag_model=excluding filter_label=bad_${d} filter_label_model=excluding bandwidth=100 bandwidth_unit=Kbps + # logout and login target + Logout Harbor + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project And Go Into Project project_dest${d} + # logout and login source + Logout Harbor + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Replication Manage + Select Rule And Replicate rule${d} + Retry Wait Until Page Contains Succeeded + Logout Harbor + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Image Should Be Replicated To Project project_dest${d} hello-world period=0 + # make sure the excluded image is not replication + Retry Wait Until Page Contains 1 - 1 of 1 items + + # pull mode + Create An New Project And Go Into Project project${d} + Switch To System Labels + Create New Labels bad_${d} + Switch To Registries + Create A New Endpoint harbor e${d} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Replication Manage + Create A Rule With Existing Endpoint rule${d} pull project${d}/* image e${d} project${d} filter_tag=3.10 filter_tag_model=excluding filter_label=bad_${d} filter_label_model=excluding bandwidth=2 bandwidth_unit=Mbps + Select Rule And Replicate rule${d} + Retry Wait Until Page Contains Succeeded + Image Should Be Replicated To Project project${d} hello-world period=0 + # make sure the excluded image is not replication + Retry Wait Until Page Contains 1 - 1 of 1 items + Close Browser + Test Case - Replication Of Push Chart from Self To Harbor Init Chrome Driver ${d}= Get Current Date result_format=%m%s