diff --git a/tests/resources/Harbor-Pages/Replication.robot b/tests/resources/Harbor-Pages/Replication.robot index 812d82fd5..65336d9fb 100644 --- a/tests/resources/Harbor-Pages/Replication.robot +++ b/tests/resources/Harbor-Pages/Replication.robot @@ -49,6 +49,12 @@ Select Source Registry Retry Element Click ${src_registry_dropdown_list} Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')] +Select flattening + [Arguments] ${type} + Retry Element Click ${flattening_select} + Retry Element Click ${flattening_select}//option[contains(.,'${type}')] + + Select Trigger [Arguments] ${mode} Retry Element Click ${rule_trigger_select} @@ -84,8 +90,8 @@ Create A New Endpoint Run Keyword If '${save}' == 'N' No Operation 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} + [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 #click new Retry Element Click ${new_name_xpath} #input name @@ -98,6 +104,7 @@ Create A Rule With Existing Endpoint Run Keyword If '${filter_tag}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag} 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} #set trigger Select Trigger ${mode} Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron} diff --git a/tests/resources/Harbor-Pages/Replication_Elements.robot b/tests/resources/Harbor-Pages/Replication_Elements.robot index d5fae6491..d914f2fdb 100644 --- a/tests/resources/Harbor-Pages/Replication_Elements.robot +++ b/tests/resources/Harbor-Pages/Replication_Elements.robot @@ -89,9 +89,4 @@ ${filter_rules_input} //*[@id='filter-rules']//input ${del_remote_checkbox} //label[@for='ruleDeletion'] ${filter_registry_btn} //hbr-filter ${filter_registry_input} //input[contains(@class,'filter-input')] - - - - - - +${flattening_select} //select[@id='dest_namespace_replace_count'] diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index 484426184..bd2cba973 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -14,6 +14,8 @@ *** Settings *** Documentation This resource wrap test case body +Library ../apitests/python/testutils.py +Library ../apitests/python/library/repository.py *** Variables *** @@ -361,7 +363,7 @@ Body Of Replication Of Push Images to Registry Triggered By Event Executions Result Count Should Be Succeeded event_based 2 Body Of Replication Of Pull Images from Registry To Self - [Arguments] ${provider} ${endpoint} ${username} ${pwd} ${src_project_name} ${des_project_name} ${verify_verbose} @{target_images} + [Arguments] ${provider} ${endpoint} ${username} ${pwd} ${src_project_name} ${des_project_name} ${verify_verbose} ${flattening} @{target_images} Init Chrome Driver ${d}= Get Current Date result_format=%m%s ${_des_pro_name}= Set Variable If '${des_project_name}'=='${null}' project${d} ${des_project_name} @@ -371,7 +373,7 @@ Body Of Replication Of Pull Images from Registry To Self Switch To Registries Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y Switch To Replication Manage - Create A Rule With Existing Endpoint rule${d} pull ${src_project_name} all e${d} ${_des_pro_name} + Create A Rule With Existing Endpoint rule${d} pull ${src_project_name} all e${d} ${_des_pro_name} flattening=${flattening} Select Rule And Replicate rule${d} Run Keyword If '${verify_verbose}'=='Y' Verify Artifact Display Verbose ${_des_pro_name} @{target_images} ... ELSE Verify Artifact Display ${_des_pro_name} @{target_images} @@ -379,6 +381,8 @@ Body Of Replication Of Pull Images from Registry To Self Verify Artifact Display Verbose [Arguments] ${pro_name} @{target_images} + ${count}= Get length ${target_images} + Should Be True ${count} > 0 FOR ${item} IN @{target_images} ${item}= Get Substring ${item} 1 -1 ${item}= Evaluate ${item} @@ -392,9 +396,41 @@ Verify Artifact Display Verbose Verify Artifact Display [Arguments] ${pro_name} @{target_images} + ${count}= Get length ${target_images} + Should Be True ${count} > 0 FOR ${item} IN @{target_images} ${item}= Get Substring ${item} 1 -1 ${item}= Evaluate ${item} ${image}= Get From Dictionary ${item} image Image Should Be Replicated To Project ${pro_name} ${image} times=2 END + +Replication With Flattening + [Arguments] ${src_endpoint} ${image_size} ${flattening_type} ${trimmed_namespace} @{src_images} + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + ${src_project}= Set Variable project${d} + Sign In Harbor https://${src_endpoint} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project And Go Into Project ${src_project} + Close Browser + FOR ${item} IN @{src_images} + ${item}= Get Substring ${item} 1 -1 + ${item}= Evaluate ${item} + ${image}= Get From Dictionary ${item} image + ${tag}= Get From Dictionary ${item} tag + @{tags} Create List ${tag} + Push Special Image To Project ${src_project} ${src_endpoint} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=${image_size} + END + @{target_images}= Create List + FOR ${item} IN @{src_images} + ${item}= Get Substring ${item} 1 -1 + ${item}= Evaluate ${item} + ${image}= Get From Dictionary ${item} image + ${tag}= Get From Dictionary ${item} tag + ${image}= Fetch From Right ${image} ${trimmed_namespace} + Log All ${image} + &{image_with_tag}= Create Dictionary image=${image} tag=${tag} + Append To List ${target_images} '&{image_with_tag}' + END + Log All ${target_images} + Body Of Replication Of Pull Images from Registry To Self harbor https://${src_endpoint} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${src_project}/** ${null} N ${flattening_type} @{target_images} diff --git a/tests/robot-cases/Group1-Nightly/Common.robot b/tests/robot-cases/Group1-Nightly/Common.robot index 249c5b826..1e1126240 100644 --- a/tests/robot-cases/Group1-Nightly/Common.robot +++ b/tests/robot-cases/Group1-Nightly/Common.robot @@ -285,7 +285,7 @@ Test Case - User View Logs Create An New Project And Go Into Project project${d} Logout Harbor - Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net ${null} ${null} nightly/${replication_image} project${d} N @{target_images} + Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net ${null} ${null} nightly/${replication_image} project${d} N Flatten 1 Level @{target_images} Push image ${ip} ${user} ${pwd} project${d} ${img}:${tag} Pull image ${ip} ${user} ${pwd} project${d} ${replication_image}:${replication_tag} diff --git a/tests/robot-cases/Group1-Nightly/Replication.robot b/tests/robot-cases/Group1-Nightly/Replication.robot index 68f886a4c..29b7a9033 100644 --- a/tests/robot-cases/Group1-Nightly/Replication.robot +++ b/tests/robot-cases/Group1-Nightly/Replication.robot @@ -157,7 +157,7 @@ Test Case - Replication Of Pull Images from DockerHub To Self Log All image1:${image1} ${image2}= Get From Dictionary ${image2_with_tag} image @{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' - Body Of Replication Of Pull Images from Registry To Self docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N @{target_images} + Body Of Replication Of Pull Images from Registry To Self docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER}/{${image1}*,${image2}} ${null} N Flatten 1 Level @{target_images} Test Case - Replication Of Push Images from Self To Harbor Init Chrome Driver @@ -292,7 +292,7 @@ Test Case - Replication Of Pull Images from Gitlab To Self ${image1}= Get From Dictionary ${image1_with_tag} image ${image2}= Get From Dictionary ${image2_with_tag} image @{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' - Body Of Replication Of Pull Images from Registry To Self gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication/{${image1},${image2}} ${null} N @{target_images} + Body Of Replication Of Pull Images from Registry To Self gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication/{${image1},${image2}} ${null} N Flatten All Levels @{target_images} Test Case - Replication Of Push Images to Gitlab Triggered By Event Body Of Replication Of Push Images to Registry Triggered By Event gitlab https://registry.gitlab.com ${gitlab_id} ${gitlab_key} dannylunsa/test_replication @@ -305,4 +305,36 @@ Test Case - Replication Of Pull Manifest List and CNAB from Harbor To Self ${image2}= Get From Dictionary ${image2_with_tag} image ${image3}= Get From Dictionary ${image3_with_tag} image @{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' - Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net admin qA5ZgV nightly/{${image1},${image2},${image3}} ${null} Y @{target_images} + Body Of Replication Of Pull Images from Registry To Self harbor https://cicd.harbor.vmwarecna.net admin qA5ZgV nightly/{${image1},${image2},${image3}} ${null} Y Flatten 1 Level @{target_images} + +Test Case - Image Namespace Level Flattening + [tags] flattening + ${src_endpoint}= Set Variable ${ip1} + + #Test only for + &{image1_with_tag}= Create Dictionary image=test_image_1 tag=tag.1 total_artifact_count=1 archive_count=0 + &{image2_with_tag}= Create Dictionary image=level_1/test_image_2 tag=tag.2 total_artifact_count=1 archive_count=0 + &{image3_with_tag}= Create Dictionary image=level_1/level_2/test_image_3 tag=tag.3 total_artifact_count=1 archive_count=0 + @{src_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' + Replication With Flattening ${src_endpoint} 10 Flatten All Levels / @{src_images} + + #Test only for + &{image1_with_tag}= Create Dictionary image=test_image_1 tag=tag.1 total_artifact_count=1 archive_count=0 + &{image2_with_tag}= Create Dictionary image=level_1/test_image_2 tag=tag.2 total_artifact_count=1 archive_count=0 + &{image3_with_tag}= Create Dictionary image=level_1/level_2/test_image_3 tag=tag.3 total_artifact_count=1 archive_count=0 + @{src_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' + Replication With Flattening ${src_endpoint} 10 Flatten 1 Level ${null} @{src_images} + + #Test only for + &{image1_with_tag}= Create Dictionary image=level_1/test_image_1 tag=tag.1 total_artifact_count=1 archive_count=0 + &{image2_with_tag}= Create Dictionary image=level_1/level_2/test_image_2 tag=tag.2 total_artifact_count=1 archive_count=0 + &{image3_with_tag}= Create Dictionary image=level_1/level_2/level_3/test_image_3 tag=tag.3 total_artifact_count=1 archive_count=0 + @{src_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' + Replication With Flattening ${src_endpoint} 10 Flatten 2 Levels level_1/ @{src_images} + + #Test only for + &{image1_with_tag}= Create Dictionary image=level_1/level_2/test_image_1 tag=tag.1 total_artifact_count=1 archive_count=0 + &{image2_with_tag}= Create Dictionary image=level_1/level_2/level_3/test_image_2 tag=tag.2 total_artifact_count=1 archive_count=0 + &{image3_with_tag}= Create Dictionary image=level_1/level_2/level_3/level_4/test_image_3 tag=tag.3 total_artifact_count=1 archive_count=0 + @{src_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' + Replication With Flattening ${src_endpoint} 20 Flatten 3 Levels level_1/level_2/ @{src_images}