Merge pull request #14998 from danfengliu/fix-replication-namespace-level-issue

Fix replication namespace level issue
This commit is contained in:
danfengliu 2021-06-09 14:15:44 +08:00 committed by GitHub
commit 896327a845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 14 deletions

View File

@ -49,6 +49,12 @@ Select Source Registry
Retry Element Click ${src_registry_dropdown_list} Retry Element Click ${src_registry_dropdown_list}
Retry Element Click ${src_registry_dropdown_list}//option[contains(.,'${endpoint}')] 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 Select Trigger
[Arguments] ${mode} [Arguments] ${mode}
Retry Element Click ${rule_trigger_select} Retry Element Click ${rule_trigger_select}
@ -84,8 +90,8 @@ Create A New Endpoint
Run Keyword If '${save}' == 'N' No Operation Run Keyword If '${save}' == 'N' No Operation
Create A Rule With Existing Endpoint Create A Rule With Existing Endpoint
[Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace} [Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace}
... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false} ... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag}=${false} ${flattening}=Flatten 1 Level
#click new #click new
Retry Element Click ${new_name_xpath} Retry Element Click ${new_name_xpath}
#input name #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 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} Run Keyword And Ignore Error Select From List By Value ${rule_resource_selector} ${resource_type}
Retry Text Input ${dest_namespace_xpath} ${dest_namespace} Retry Text Input ${dest_namespace_xpath} ${dest_namespace}
Select flattening ${flattening}
#set trigger #set trigger
Select Trigger ${mode} Select Trigger ${mode}
Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron} Run Keyword If '${mode}' == 'Scheduled' Retry Text Input ${targetCron_id} ${cron}

View File

@ -89,9 +89,4 @@ ${filter_rules_input} //*[@id='filter-rules']//input
${del_remote_checkbox} //label[@for='ruleDeletion'] ${del_remote_checkbox} //label[@for='ruleDeletion']
${filter_registry_btn} //hbr-filter ${filter_registry_btn} //hbr-filter
${filter_registry_input} //input[contains(@class,'filter-input')] ${filter_registry_input} //input[contains(@class,'filter-input')]
${flattening_select} //select[@id='dest_namespace_replace_count']

View File

@ -14,6 +14,8 @@
*** Settings *** *** Settings ***
Documentation This resource wrap test case body Documentation This resource wrap test case body
Library ../apitests/python/testutils.py
Library ../apitests/python/library/repository.py
*** Variables *** *** 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 Executions Result Count Should Be Succeeded event_based 2
Body Of Replication Of Pull Images from Registry To Self 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 Init Chrome Driver
${d}= Get Current Date result_format=%m%s ${d}= Get Current Date result_format=%m%s
${_des_pro_name}= Set Variable If '${des_project_name}'=='${null}' project${d} ${des_project_name} ${_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 Switch To Registries
Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y Create A New Endpoint ${provider} e${d} ${endpoint} ${username} ${pwd} Y
Switch To Replication Manage 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} Select Rule And Replicate rule${d}
Run Keyword If '${verify_verbose}'=='Y' Verify Artifact Display Verbose ${_des_pro_name} @{target_images} Run Keyword If '${verify_verbose}'=='Y' Verify Artifact Display Verbose ${_des_pro_name} @{target_images}
... ELSE Verify Artifact Display ${_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 Verify Artifact Display Verbose
[Arguments] ${pro_name} @{target_images} [Arguments] ${pro_name} @{target_images}
${count}= Get length ${target_images}
Should Be True ${count} > 0
FOR ${item} IN @{target_images} FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1 ${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item} ${item}= Evaluate ${item}
@ -392,9 +396,41 @@ Verify Artifact Display Verbose
Verify Artifact Display Verify Artifact Display
[Arguments] ${pro_name} @{target_images} [Arguments] ${pro_name} @{target_images}
${count}= Get length ${target_images}
Should Be True ${count} > 0
FOR ${item} IN @{target_images} FOR ${item} IN @{target_images}
${item}= Get Substring ${item} 1 -1 ${item}= Get Substring ${item} 1 -1
${item}= Evaluate ${item} ${item}= Evaluate ${item}
${image}= Get From Dictionary ${item} image ${image}= Get From Dictionary ${item} image
Image Should Be Replicated To Project ${pro_name} ${image} times=2 Image Should Be Replicated To Project ${pro_name} ${image} times=2
END 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}

View File

@ -285,7 +285,7 @@ Test Case - User View Logs
Create An New Project And Go Into Project project${d} Create An New Project And Go Into Project project${d}
Logout Harbor 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} Push image ${ip} ${user} ${pwd} project${d} ${img}:${tag}
Pull image ${ip} ${user} ${pwd} project${d} ${replication_image}:${replication_tag} Pull image ${ip} ${user} ${pwd} project${d} ${replication_image}:${replication_tag}

View File

@ -157,7 +157,7 @@ Test Case - Replication Of Pull Images from DockerHub To Self
Log All image1:${image1} Log All image1:${image1}
${image2}= Get From Dictionary ${image2_with_tag} image ${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' @{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 Test Case - Replication Of Push Images from Self To Harbor
Init Chrome Driver 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 ${image1}= Get From Dictionary ${image1_with_tag} image
${image2}= Get From Dictionary ${image2_with_tag} image ${image2}= Get From Dictionary ${image2_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' @{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 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 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 ${image2}= Get From Dictionary ${image2_with_tag} image
${image3}= Get From Dictionary ${image3_with_tag} image ${image3}= Get From Dictionary ${image3_with_tag} image
@{target_images}= Create List '&{image1_with_tag}' '&{image2_with_tag}' '&{image3_with_tag}' @{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 <Flatten All Levels>
&{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 <Flatten 1 Level>
&{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 <Flatten 2 Levels>
&{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 <Flatten 3 Levels>
&{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}