From 0e752d8cf856763e936d3ae424b182c7cae5772c Mon Sep 17 00:00:00 2001 From: danfengliu Date: Wed, 25 Nov 2020 18:49:49 +0800 Subject: [PATCH] Add docker credential for harbor 1.10.0 and fix docker api issue 1. Move LDAP API test out of robot script, LDAP API test will be triggered in Jenkins job independently; 2. Docker api returned from function before analyze the return message for expected error. Signed-off-by: danfengliu --- .github/workflows/CI.yml | 2 +- tests/apitests/python/library/docker_api.py | 150 ++++++++++-------- tests/apitests/python/library/repository.py | 7 + .../python/test_assign_role_to_ldap_group.py | 7 +- tests/apitests/python/test_ldap_admin_role.py | 3 +- tests/resources/Docker-Util.robot | 33 ++++ tests/resources/Harbor-Pages/Project.robot | 1 - .../resources/Harbor-Pages/Replication.robot | 142 ++++++++--------- .../Harbor-Pages/Replication_Elements.robot | 58 ++++--- .../resources/Harbor-Pages/UserProfile.robot | 1 + tests/resources/Harbor-Pages/Verify.robot | 6 +- tests/resources/Nightly-Util.robot | 1 + tests/resources/TestCaseBody.robot | 31 +++- tests/resources/Util.robot | 4 +- tests/robot-cases/Group1-Nightly/LDAP.robot | 5 - tests/robot-cases/Group1-Nightly/Notary.robot | 1 + .../Group1-Nightly/Replication.robot | 108 +++++++------ 17 files changed, 327 insertions(+), 233 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6c61239d5..99a5f1b19 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -287,4 +287,4 @@ jobs: uses: codecov/codecov-action@v1 with: file: ./src/github.com/goharbor/harbor/src/portal/coverage/lcov.info - flags: unittests + flags: unittests \ No newline at end of file diff --git a/tests/apitests/python/library/docker_api.py b/tests/apitests/python/library/docker_api.py index 7ee2c8319..73c58efa6 100644 --- a/tests/apitests/python/library/docker_api.py +++ b/tests/apitests/python/library/docker_api.py @@ -8,127 +8,151 @@ except ImportError: import pip pip.main(['install', 'docker']) import docker - class DockerAPI(object): def __init__(self): self.DCLIENT = docker.APIClient(base_url='unix://var/run/docker.sock',version='auto',timeout=10) self.DCLIENT2 = docker.from_env() def docker_login(self, registry, username, password, expected_error_message = None): - if expected_error_message is "": + ret = "" + err_message = "" + if username == "" or password == "": + print("[Warnig]: No docker credential was provided.") + return + if expected_error_message == "": expected_error_message = None + if registry == "docker": + registry = None try: - self.DCLIENT.login(registry = registry, username=username, password=password) - except docker.errors.APIError as err: + print("Docker login: {}:{}:{}".format(registry,username,password)) + ret = self.DCLIENT.login(registry = registry, username=username, password=password) + except Exception as err: + print( "Docker image pull catch exception:", str(err)) + err_message = str(err) + if expected_error_message is None: + raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err))) + else: + print("Docker image login did not catch exception and return message is:", ret) + err_message = ret + finally: if expected_error_message is not None: - print( "docker login error:", str(err)) - if str(err).lower().find(expected_error_message.lower()) < 0: - raise Exception(r"Docker login: Return message {} is not as expected {}".format(str(err), expected_error_message)) + if str(err_message).lower().find(expected_error_message.lower()) < 0: + raise Exception(r" Failed to catch error [{}] when login image {}, return message: {}".format (expected_error_message, image, err_message)) + else: + print(r"Docker image login got expected error message:{}".format(expected_error_message)) else: - raise Exception(r" Docker login failed, error is [{}]".format (err.message)) + if str(err_message).lower().find("error".lower()) >= 0: + raise Exception(r" It's was not suppose to catch error when login image {}, return message is [{}]".format (image, err_message)) def docker_image_pull(self, image, tag = None, expected_error_message = None): + ret = "" + err_message = "" if tag is not None: _tag = tag else: _tag = "latest" if expected_error_message is "": expected_error_message = None - ret = "" try: ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag)) - return ret except Exception as err: - if expected_error_message is not None: - print( "docker image pull error:", str(err)) - if str(err).lower().find(expected_error_message.lower()) < 0: - raise Exception(r"Pull image: Return message {} is not as expected {}".format(str(err), expected_error_message)) - else: - raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, err.message)) + print( "Docker image pull catch exception:", str(err)) + err_message = str(err) + if expected_error_message is None: + raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err))) else: + print("Docker image pull did not catch exception and return message is:", ret) + err_message = ret + finally: if expected_error_message is not None: - if str(ret).lower().find(expected_error_message.lower()) < 0: - raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, str(ret))) + if str(err_message).lower().find(expected_error_message.lower()) < 0: + raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, err_message)) + else: + print(r"Docker image pull got expected error message:{}".format(expected_error_message)) else: - if str(ret).lower().find("error".lower()) >= 0: - raise Exception(r" It's was not suppose to catch error when pull image {}, return message is [{}]".format (image, ret)) + if str(err_message).lower().find("error".lower()) >= 0: + raise Exception(r" It's was not suppose to catch error when pull image {}, return message is [{}]".format (image, err_message)) def docker_image_tag(self, image, harbor_registry, tag = None): _tag = base._random_name("tag") if tag is not None: _tag = tag + ret = "" try: - self.DCLIENT.tag(image, harbor_registry, _tag, force=True) + ret = self.DCLIENT.tag(image, harbor_registry, _tag, force=True) + print("Docker image tag commond return:", ret) return harbor_registry, _tag - except docker.errors.APIError as e: - raise Exception(r" Docker tag image {} failed, error is [{}]".format (image, e.message)) + except docker.errors.APIError as err: + raise Exception(r" Docker tag image {} failed, error is [{}]".format (image, str(err))) def docker_image_push(self, harbor_registry, tag, expected_error_message = None): - caught_err = False ret = "" + err_message = "" if expected_error_message is "": expected_error_message = None try: - self.DCLIENT.push(harbor_registry, tag) - return ret + ret = self.DCLIENT.push(harbor_registry, tag) except Exception as err: - caught_err = True + print( "Docker image push catch exception:", str(err)) + err_message = str(err) + if expected_error_message is None: + raise Exception(r" Docker push image {} failed, error is [{}]".format (image, str(err))) + else: + print("Docker image push did not catch exception and return message is:", ret) + err_message = ret + finally: if expected_error_message is not None: - print( "docker image push error:", str(err)) - if str(err).lower().find(expected_error_message.lower()) < 0: - raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message)) + if str(err_message).lower().find(expected_error_message.lower()) < 0: + raise Exception(r" Failed to catch error [{}] when push image {}, return message: {}".format (expected_error_message, harbor_registry, err_message)) + else: + print(r"Docker image push got expected error message:{}".format(expected_error_message)) else: - raise Exception(r" Docker push image {} failed, error is [{}]".format (harbor_registry, err.message)) - if caught_err == False: - if expected_error_message is not None: - if str(ret).lower().find(expected_error_message.lower()) < 0: - raise Exception(r" Failed to catch error [{}] when push image {}, return message: {}". - format (expected_error_message, harbor_registry, str(ret))) - else: - if str(ret).lower().find("errorDetail".lower()) >= 0: - raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]". - format (harbor_registry, ret)) + if str(err_message).lower().find("error".lower()) >= 0: + raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]".format (harbor_registry, err_message)) def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None): - caught_err = False ret = "" + err_message = "" try: baseimage='busybox:latest' if not self.DCLIENT.images(name=baseimage): + print( "Docker pull is triggered when building {}".format(harbor_registry)) self.DCLIENT.pull(baseimage) - c=self.DCLIENT.create_container(image='busybox:latest',command='dd if=/dev/urandom of=test bs=1M count=%d' % size ) + c=self.DCLIENT.create_container(image='busybox:latest', + command='dd if=/dev/urandom of=test bs=1M count={}'.format(size)) self.DCLIENT.start(c) self.DCLIENT.wait(c) if not tags: tags=['latest'] - firstrepo="%s:%s" % (harbor_registry, tags[0]) + firstrepo="{}:{}".format(harbor_registry, tags[0]) #self.DCLIENT.commit(c, firstrepo) self.DCLIENT2.containers.get(c).commit(harbor_registry, tags[0]) for tag in tags[1:]: - repo="%s:%s" % (harbor_registry, tag) + repo="{}:{}".format(harbor_registry, tag) self.DCLIENT.tag(firstrepo, repo) for tag in tags: - repo="%s:%s" % (harbor_registry, tag) - self.DCLIENT.push(repo) - print("build image %s with size %d" % (repo, size)) + repo="{}:{}".format(harbor_registry, tag) + ret = self.DCLIENT.push(repo) + print("docker_image_push ret:", ret) + print("build image {} with size {}".format(repo, size)) self.DCLIENT.remove_image(repo) self.DCLIENT.remove_container(c) - self.DCLIENT.pull(repo) - image = self.DCLIENT2.images.get(repo) - return repo, image.id + #self.DCLIENT.pull(repo) + #image = self.DCLIENT2.images.get(repo) except Exception as err: - caught_err = True + print( "Docker image build catch exception:", str(err)) + err_message = str(err) + if expected_error_message is None: + raise Exception(r" Docker push image {} failed, error is [{}]".format (harbor_registry, str(err))) + else: + print("Docker image build did not catch exception and return message is:", ret) + err_message = ret + finally: if expected_error_message is not None: - print( "docker image build error:", str(err)) - if str(err).lower().find(expected_error_message.lower()) < 0: - raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message)) + if str(err_message).lower().find(expected_error_message.lower()) < 0: + raise Exception(r" Failed to catch error [{}] when build image {}, return message: {}".format (expected_error_message, harbor_registry, err_message)) + else: + print(r"Docker image build got expected error message:{}".format(expected_error_message)) else: - raise Exception(r" Docker build image {} failed, error is [{}]".format (harbor_registry, err.message)) - if caught_err == False: - if expected_error_message is not None: - if str(ret).lower().find(expected_error_message.lower()) < 0: - raise Exception(r" Failed to catch error [{}] when build image {}, return message: {}". - format (expected_error_message, harbor_registry, str(ret))) - else: - if str(ret).lower().find("errorDetail".lower()) >= 0: - raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]".format (harbor_registry, ret)) + if str(err_message).lower().find("error".lower()) >= 0: + raise Exception(r" It's was not suppose to catch error when build image {}, return message is [{}]".format (harbor_registry, err_message)) diff --git a/tests/apitests/python/library/repository.py b/tests/apitests/python/library/repository.py index 497adc818..c436fd2a0 100644 --- a/tests/apitests/python/library/repository.py +++ b/tests/apitests/python/library/repository.py @@ -123,9 +123,16 @@ class Repository(base.Base): def repository_should_exist(self, project_id, repo_name, **kwargs): repositories = self.get_repository(project_id, **kwargs) + print("repositories:", repositories) if is_repo_exist_in_project(repositories, repo_name) == False: raise Exception("Repository {} is not exist.".format(repo_name)) + def repository_should_not_exist(self, project_id, repo_name, **kwargs): + repositories = self.get_repository(project_id, **kwargs) + print("repositories:", repositories) + if is_repo_exist_in_project(repositories, repo_name) == True: + raise Exception("Repository {} should not exist.".format(repo_name)) + def signature_should_exist(self, repo_name, tag, **kwargs): signatures = self.get_repo_signatures(repo_name, **kwargs) for each_sign in signatures: diff --git a/tests/apitests/python/test_assign_role_to_ldap_group.py b/tests/apitests/python/test_assign_role_to_ldap_group.py index 4de00c28b..753ed86b3 100644 --- a/tests/apitests/python/test_assign_role_to_ldap_group.py +++ b/tests/apitests/python/test_assign_role_to_ldap_group.py @@ -55,12 +55,13 @@ class TestAssignRoleToLdapGroup(unittest.TestCase): self.assertEqual(1, projects[0].current_user_role_id) repo_name_admin, tag_name_admin = push_image_to_project(project_name, harbor_server, USER_ADMIN["username"], USER_ADMIN["password"], USER_ADMIN["repo"], "latest") + self.repo.repository_should_exist(project_id, project_name+"/"+USER_ADMIN["repo"], **USER_ADMIN) self.repo.image_should_exist(repo_name_admin, tag_name_admin, **USER_ADMIN) repo_name_dev, tag_name_dev = push_image_to_project(project_name, harbor_server, USER_DEV["username"], USER_DEV["password"], USER_DEV["repo"], "latest") + self.repo.repository_should_exist(project_id, project_name+"/"+USER_DEV["repo"], **USER_ADMIN) self.repo.image_should_exist(repo_name_dev, tag_name_dev, **USER_DEV) - repo_name_guest, tag_name_guest = push_image_to_project(project_name, harbor_server, USER_GUEST["username"], USER_GUEST["password"], USER_GUEST["repo"], "latest") - self.repo.image_should_not_exist(repo_name_guest, tag_name_guest, **USER_GUEST) - + push_image_to_project(project_name, harbor_server, USER_GUEST["username"], USER_GUEST["password"], USER_GUEST["repo"], "latest", expected_error_message = "requested access to the resource is denied") + self.repo.repository_should_not_exist(project_id, project_name+"/"+USER_GUEST["repo"], **USER_ADMIN) self.assertTrue(self.project.query_user_logs(project_id, **USER_ADMIN)>0, "admin user can see logs") self.assertTrue(self.project.query_user_logs(project_id, **USER_DEV)>0, "dev user can see logs") diff --git a/tests/apitests/python/test_ldap_admin_role.py b/tests/apitests/python/test_ldap_admin_role.py index 681bea40b..23b75f838 100644 --- a/tests/apitests/python/test_ldap_admin_role.py +++ b/tests/apitests/python/test_ldap_admin_role.py @@ -54,7 +54,8 @@ class TestLdapAdminRole(unittest.TestCase): # query project with ldap user mike projects = self.mike_product_api.projects_get(name="test_private") - self.assertTrue(projects.count>1) + print(projects) + self.assertTrue(len(projects) == 1) self.project_id = projects[0].project_id pass diff --git a/tests/resources/Docker-Util.robot b/tests/resources/Docker-Util.robot index dc76ceb1b..4027ff3e0 100644 --- a/tests/resources/Docker-Util.robot +++ b/tests/resources/Docker-Util.robot @@ -154,3 +154,36 @@ Docker Tag Docker Push [Arguments] ${image} Wait Unitl Command Success docker push ${image} + +Docker Push Index + [Arguments] ${ip} ${user} ${pwd} ${index} ${image1} ${image2} + ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/docker_push_manifest_list.sh ${ip} ${user} ${pwd} ${index} ${image1} ${image2} + Log ${output} + Should Be Equal As Integers ${rc} 0 + +Docker Image Can Not Be Pulled + [Arguments] ${image} + :FOR ${idx} IN RANGE 0 30 + \ ${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD} + \ Log To Console Return value is ${out} + \ ${out}= Run Keyword And Ignore Error Command Should be Failed docker pull ${image} + \ Exit For Loop If '${out[0]}'=='PASS' + \ Log To Console Docker pull return value is ${out} + \ Sleep 3 + + Log To Console Cannot Pull Image From Docker - Pull Log: ${out[1]} + Should Be Equal As Strings '${out[0]}' 'PASS' + +Docker Image Can Be Pulled + [Arguments] ${image} ${period}=60 ${times}=2 + :FOR ${n} IN RANGE 1 ${times} + \ Sleep ${period} + \ ${out}= Run Keyword And Ignore Error Docker Login "" ${DOCKER_USER} ${DOCKER_PWD} + \ Log To Console Return value is ${out} + \ ${out}= Run Keyword And Ignore Error Docker Pull ${image} + \ Log To Console Return value is ${out[0]} + \ Exit For Loop If '${out[0]}'=='PASS' + \ Sleep 5 + + Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot + Should Be Equal As Strings '${out[0]}' 'PASS' \ No newline at end of file diff --git a/tests/resources/Harbor-Pages/Project.robot b/tests/resources/Harbor-Pages/Project.robot index 926a2a0d0..2727999b1 100644 --- a/tests/resources/Harbor-Pages/Project.robot +++ b/tests/resources/Harbor-Pages/Project.robot @@ -313,4 +313,3 @@ Input Storage Quota Select Storage Quota unit [Arguments] ${unit} Select From List By Value ${project_add_storage_quota_unit_id} ${unit} - diff --git a/tests/resources/Harbor-Pages/Replication.robot b/tests/resources/Harbor-Pages/Replication.robot index 69244a1db..26148db01 100644 --- a/tests/resources/Harbor-Pages/Replication.robot +++ b/tests/resources/Harbor-Pages/Replication.robot @@ -19,13 +19,25 @@ Resource ../../resources/Util.robot *** Variables *** *** Keywords *** -Filter Replicatin Rule - [Arguments] ${ruleName} +Filter Replication Rule + [Arguments] ${ruleName} ${exist}=${true} ${rule_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${ruleName}')] Retry Element Click ${filter_rules_btn} + Retry Clear Element Text ${filter_rules_input} Retry Text Input ${filter_rules_input} ${ruleName} - Retry Wait Until Page Contains Element ${rule_name_element} - Capture Page Screenshot filter_replic_${ruleName}.png + 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!\")] + + + +Filter Registry + [Arguments] ${registry_name} + ${registry_name_element}= Set Variable xpath=//clr-dg-cell[contains(.,'${registry_name}')] + Switch To Replication Manage + Switch To Registries + Retry Element Click ${filter_registry_btn} + Retry Text Input ${filter_registry_input} ${registry_name} + Retry Wait Until Page Contains Element ${registry_name_element} Select Dest Registry [Arguments] ${endpoint} @@ -63,32 +75,33 @@ Create A New Endpoint Retry Text Input xpath=${destination_name_xpath} ${name} Run Keyword If '${provider}' == 'harbor' Run keyword Retry Text Input xpath=${destination_url_xpath} ${url} Run Keyword If '${provider}' == 'aws-ecr' or '${provider}' == 'google-gcr' Run keyword Select Destination URL ${url} - Run Keyword If '${provider}' != 'google-gcr' Retry Text Input xpath=${destination_username_xpath} ${username} - Retry Text Input xpath=${destination_password_xpath} ${pwd} + 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} #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} - Run Keyword If '${save}' == 'Y' Run keyword Retry Wait Until Page Contains ${name} + Run Keyword If '${save}' == 'Y' Run keyword Filter Registry ${name} Run Keyword If '${save}' == 'N' No Operation Create A Rule With Existing Endpoint - [Arguments] ${name} ${replication_mode} ${project_name} ${resource_type} ${endpoint} ${dest_namespace} - ... ${mode}=Manual + [Arguments] ${name} ${replication_mode} ${filter_project_name} ${resource_type} ${endpoint} ${dest_namespace} + ... ${mode}=Manual ${cron}="* */59 * * * *" ${del_remote}=${false} ${filter_tag_id}=${false} #click new Retry Element Click ${new_name_xpath} #input name Retry Text Input ${rule_name} ${name} - 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} + 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} + #set filter - Retry Text Input ${source_project} ${project_name} + Retry Text Input ${filter_name_id} ${filter_project_name} + Run Keyword If '${filter_tag_id}' != '${false}' Retry Text Input ${filter_tag_id} ${filter_tag_id} 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} - Run Keyword If '${mode}' == 'Scheduled' Log To Console Scheduled + 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} #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 @@ -142,27 +155,9 @@ Rename Rule Retry Text Input ${rule_name} ${newname} Retry Element Click ${rule_save_button} -Delete Rule - [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_delete} - Retry Wait Until Page Contains Element ${dialog_delete} - #change from click to mouse down and up - Mouse Down ${dialog_delete} - Mouse Up ${dialog_delete} - Sleep 2 - -Filter Rule - [Arguments] ${rule} - Retry Element Click ${rule_filter_search} - Retry Text Input ${rule_filter_input} ${rule} - Sleep 1 - Select Rule [Arguments] ${rule} - Retry Element Click //clr-dg-row[contains(.,'${rule}')]//label + Retry Double Keywords When Error Retry Element Click //clr-dg-cell[contains(.,'${rule}')] Retry Wait Element ${replication_rule_exec_id} Stop Jobs Retry Element Click ${stop_jobs_button} @@ -173,42 +168,37 @@ View Job Log Retry Text Input ${job_filter_input} ${job} Retry Link Click //clr-dg-row[contains(.,'${job}')]//a -Find Item And Click Edit Button +Find Registry And Click Edit Button [Arguments] ${name} Filter Object ${name} Retry Select Object ${name} - Retry Element Click ${action_bar_edit} - -Find Item And Click Delete Button - [Arguments] ${name} - Filter Object ${name} - Retry Select Object ${name} - Retry Element Click ${action_bar_delete} + Retry Element Click ${registry_edit_btn} Switch To Replication Manage Page - [Arguments] ${name} Switch To Registries Switch To Replication Manage -Edit Replication Rule By Name +Edit Replication Rule [Arguments] ${name} - Retry Double Keywords When Error Switch To Replication Manage Page "NULL" Find Item And Click Edit Button ${name} + Switch To Replication Manage Page + Filter Replication Rule ${name} + Select Rule ${name} + Retry Double Keywords When Error Retry Element Click ${replication_rule_action_bar_edit} Retry Wait Until Page Contains Edit Replication Rule -Delete Replication Rule By Name - [Arguments] ${name} - Switch To Registries - Switch To Replication Manage - Find Item And Click Delete Button ${name} - -Ensure Delete Replication Rule By Name - [Arguments] ${name} - Delete Replication Rule By Name ${name} - Retry Double Keywords When Error Retry Element Click ${delete_confirm_btn} Retry Wait Until Page Not Contains Element ${delete_confirm_btn} - Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any replication rules!\")] +Delete Replication Rule + [Arguments] ${name} + Reload Page + Switch To Replication Manage Page + Filter Replication Rule ${name} + Select Rule ${name} + Retry Double Keywords When Error Retry Element Click ${replication_rule_action_bar_delete} 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} + Reload Page + Filter Replication Rule ${name} exist=${false} Rename Endpoint [arguments] ${name} ${newname} - Find Item And Click Edit Button ${name} + Find Registry And Click Edit Button ${name} Retry Wait Until Page Contains Element ${destination_name_xpath} Retry Text Input ${destination_name_xpath} ${newname} Retry Element Click ${replication_save_xpath} @@ -225,28 +215,16 @@ Delete Endpoint Select Rule And Replicate [Arguments] ${rule_name} - Retry Element Click //hbr-list-replication-rule//clr-dg-cell[contains(.,'${rule_name}')] - Retry Element Click ${replication_exec_id} - Retry Double Keywords When Error Retry Element Click xpath=${dialog_replicate} Retry Wait Until Page Not Contains Element xpath=${dialog_replicate} - -Select Rule And Click Edit Button - [Arguments] ${rule_name} - Retry Element Click //clr-dg-row[contains(.,'${rule_name}')]//clr-radio-wrapper/label - Retry Element Click ${edit_replication_rule_id} - -Delete Replication Rule - [Arguments] ${name} - Retry Element Click ${endpoint_filter_search} - Retry Text Input ${endpoint_filter_input} ${name} - #click checkbox before target endpoint - Retry Element Click //clr-dg-row[contains(.,'${name}')]//label - Retry Element Click ${action_bar_delete} - Wait Until Page Contains Element ${dialog_delete} - Retry Element Click ${dialog_delete} + Reload Page + Switch To Replication Manage Page + Filter Replication Rule ${rule_name} + Select Rule ${rule_name} + Retry Double Keywords When Error Retry Element Click ${replication_rule_exec_id} Retry Wait Until Page Contains Element xpath=${dialog_replicate} + 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 - [Arguments] ${project} ${image} ${period}=60 ${times}=10 - :For ${n} IN RANGE 1 ${times} + [Arguments] ${project} ${image} ${period}=60 ${times}=3 + :FOR ${n} IN RANGE 0 ${times} \ Sleep ${period} \ Go Into Project ${project} \ Switch To Project Repo @@ -255,5 +233,13 @@ Image Should Be Replicated To Project \ Log To Console Return value is ${out[0]} \ Exit For Loop If '${out[0]}'=='PASS' \ Sleep 5 + Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot - Should Be Equal As Strings '${out[0]}' 'PASS' \ No newline at end of file + Should Be Equal As Strings '${out[0]}' 'PASS' + +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} + diff --git a/tests/resources/Harbor-Pages/Replication_Elements.robot b/tests/resources/Harbor-Pages/Replication_Elements.robot index 9ffd76096..ee05b22b2 100644 --- a/tests/resources/Harbor-Pages/Replication_Elements.robot +++ b/tests/resources/Harbor-Pages/Replication_Elements.robot @@ -23,7 +23,7 @@ ${policy_enable_checkbox} //input[@id='policy_enable']/../label ${policy_endpoint_checkbox} //input[@id='check_new']/../label ${destination_name_xpath} //*[@id='destination_name'] ${destination_url_xpath} //*[@id='destination_url'] -${destination_username_xpath} //*[@id='destination_access_key'] +${destination_username_xpath} //*[@id='destination_access_key'] ${destination_password_xpath} //*[@id='destination_password'] ${replication_save_xpath} //button[contains(.,'OK')] ${replication_xpath} //clr-vertical-nav-group-children/a[contains(.,'Replication')] @@ -41,7 +41,7 @@ ${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//input[@id='destination_insecure'] +${destination_insecure_checkbox} //hbr-create-edit-endpoint/clr-modal//input[@id='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')] @@ -59,29 +59,39 @@ ${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')] -${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')] -${source_project} //input[@id='filter_name'] -${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'] -${edit_replication_rule_id} //*[@id='edit_replication_rule_id'] -${delete_replication_rule_id} //*[@id='delete_replication_rule_id'] -${replication_exec_id} //*[@id='replication_exe_id'] -${replication_task_line_1} //clr-datagrid//clr-dg-row/div/div[2]//clr-checkbox-wrapper/label[1] -${filter_tag} //*[@id='filter_tag'] -${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')] -${enable_rule_xpath} //label[contains(.,'Enable rule')] -${targetCron_id} //*[@id='targetCron'] -${rule_name_input} //*[@id='ruleName'] -${src_registry_dropdown_list} //select[@id='src_registry_id'] -${dest_registry_dropdown_list} //select[@id='dest_registry'] -${rule_confirm_btn} //*[@id='ruleBtnOk'] -${rule_cancel_btn} //*[@id='ruleBtnCancel'] -${filter_rules_btn} //*[@id='filter-rules'] +${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_id} //input[@id='filter_tag'] +${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'] + +${registry_edit_btn} //button[contains(.,'Edit')] +${registry_del_btn} //button[contains(.,'Delete')] + +${replication_rule_action} //*[@id='rule-action'] +${replication_rule_action_bar_edit} //*[@id='edit_replication_rule_id'] +${replication_rule_action_bar_delete} //*[@id='delete_replication_rule_id'] +${replication_rule_exec_id} //*[@id='replication_exe_id'] +${replication_task_line_1} //clr-datagrid//clr-dg-row/div/div[2]//clr-checkbox-wrapper/label[1] +${is_overide_xpath} //label[contains(.,'Replace the destination resources if name exists')] +${enable_rule_xpath} //label[contains(.,'Enable rule')] +${targetCron_id} //*[@id='targetCron'] +${rule_name_input} //*[@id='ruleName'] +${src_registry_dropdown_list} //select[@id='src_registry_id'] +${dest_registry_dropdown_list} //select[@id='dest_registry'] +${rule_confirm_btn} //*[@id='ruleBtnOk'] +${rule_cancel_btn} //*[@id='ruleBtnCancel'] +${filter_rules_btn} //*[@id='filter-rules'] ${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')] +${event_log_tag} //a[contains(@class,'toolBar') and contains(.,'EVENT LOG')] + diff --git a/tests/resources/Harbor-Pages/UserProfile.robot b/tests/resources/Harbor-Pages/UserProfile.robot index 8525fcca7..1f7b857b0 100644 --- a/tests/resources/Harbor-Pages/UserProfile.robot +++ b/tests/resources/Harbor-Pages/UserProfile.robot @@ -39,6 +39,7 @@ Update User Comment Sleep 2 Logout Harbor + Reload Page Retry Element Click ${head_admin_xpath} Retry Link Click Log Out Capture Page Screenshot Logout.png diff --git a/tests/resources/Harbor-Pages/Verify.robot b/tests/resources/Harbor-Pages/Verify.robot index f113f3ca7..492d6bc34 100644 --- a/tests/resources/Harbor-Pages/Verify.robot +++ b/tests/resources/Harbor-Pages/Verify.robot @@ -152,7 +152,7 @@ Verify Replicationrule \ Log To Console -----replicationrule-----"${replicationrule}"------------ \ Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} \ Switch To Replication Manage - \ Select Rule And Click Edit Button ${replicationrule} + \ Edit Replication Rule ${replicationrule} \ @{is_src_registry}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].is_src_registry \ @{trigger_type}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].trigger_type \ @{name_filters}= Get Value From Json ${json} $.replicationrule[?(@.rulename=${replicationrule})].name_filters @@ -166,8 +166,8 @@ Verify Replicationrule \ ${endpoint0}= Set Variable @{endpoint}[0] \ Log To Console -----endpoint0-----${endpoint0}------------ \ @{endpoint_type}= Get Value From Json ${json} $.endpoint[?(@.name=${endpoint0})].type - \ Retry Textfield Value Should Be ${source_project} @{name_filters}[0] - \ Retry Textfield Value Should Be ${filter_tag} @{tag_filters}[0] + \ Retry Textfield Value Should Be ${filter_name_id} @{name_filters}[0] + \ Retry Textfield Value Should Be ${filter_tag_id} @{tag_filters}[0] \ Retry Textfield Value Should Be ${rule_name_input} ${replicationrule} \ Retry Textfield Value Should Be ${dest_namespace_xpath} @{dest_namespace}[0] \ Log To Console -----endpoint_type-----@{endpoint_type}[0]------------ diff --git a/tests/resources/Nightly-Util.robot b/tests/resources/Nightly-Util.robot index 1b1c7c4ac..de5e3487c 100644 --- a/tests/resources/Nightly-Util.robot +++ b/tests/resources/Nightly-Util.robot @@ -26,6 +26,7 @@ Nightly Test Setup Run Keyword If '${ip1}' != '${EMPTY}' Run rm -rf ./harbor_ca.crt Run Keyword CA setup ${ip} ${HARBOR_PASSWORD} Run Keyword Start Docker Daemon Locally + Wait Unitl Command Success docker login -u ${DOCKER_USER} -p ${DOCKER_PWD} CA Setup [Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}=/ca/ca.crt diff --git a/tests/resources/TestCaseBody.robot b/tests/resources/TestCaseBody.robot index e43512896..187137759 100644 --- a/tests/resources/TestCaseBody.robot +++ b/tests/resources/TestCaseBody.robot @@ -153,8 +153,7 @@ Helm CLI Push Without Sign In Harbor Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename} Go Into Project project${d} has_image=${false} Switch To Project Charts - Go Into Chart Version ${harbor_chart_name} - Retry Wait Until Page Contains ${harbor_chart_version} + Retry Double Keywords When Error Go Into Chart Version ${harbor_chart_name} Retry Wait Until Page Contains ${harbor_chart_version} Capture Page Screenshot Helm3 CLI Push Without Sign In Harbor @@ -166,3 +165,31 @@ Helm3 CLI Push Without Sign In Harbor Switch To Project Charts Retry Double Keywords When Error Go Into Chart Version ${harbor_chart_name} Retry Wait Until Page Contains ${harbor_chart_version} Capture Page Screenshot + +Body Of Replication Of Push Images to Registry Triggered By Event + [Arguments] ${provider} ${endpoint} ${username} ${pwd} ${dest_namespace} + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + ${sha256}= Set Variable 0e67625224c1da47cb3270e7a861a83e332f708d3d89dde0cbed432c94824d9a + ${image}= Set Variable test_push_repli + ${tag1}= Set Variable v1.1.0 + @{tags} Create List ${tag1} + #login source + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${d} + 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} push project${d}/* image e${d} ${dest_namespace} mode=Event Based del_remote=${true} + Push Special Image To Project project${d} ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} ${image} tags=@{tags} size=12 + Filter Replication Rule rule${d} + Select Rule rule${d} + Run Keyword If '${provider}'=='docker-hub' Docker Image Can Be Pulled ${dest_namespace}/${image}:${tag1} times=3 + Executions Result Count Should Be Succeed event_based 1 + Go Into Project project${d} + Delete Repo project${d} + Run Keyword If '${provider}'=='docker-hub' Docker Image Can Not Be Pulled ${dest_namespace}/${image}:${tag1} + Switch To Replication Manage + Filter Replication Rule rule${d} + Select Rule rule${d} + Executions Result Count Should Be Succeed event_based 2 \ No newline at end of file diff --git a/tests/resources/Util.robot b/tests/resources/Util.robot index e289b647b..935a3f66d 100644 --- a/tests/resources/Util.robot +++ b/tests/resources/Util.robot @@ -233,7 +233,7 @@ Click Element If Visible Retry Keyword When Error [Arguments] ${keyword} @{elements} - :For ${n} IN RANGE 1 6 + :For ${n} IN RANGE 1 3 \ Log To Console Trying ${keyword} elements @{elements} ${n} times ... \ ${out} Run Keyword And Ignore Error ${keyword} @{elements} \ Log To Console Return value is ${out[0]} @@ -257,7 +257,7 @@ Retry Keyword When Return Value Mismatch Retry Double Keywords When Error [Arguments] ${keyword1} ${element1} ${keyword2} ${element2} ${DoAssert}=${true} - :For ${n} IN RANGE 1 5 + :For ${n} IN RANGE 1 3 \ Log To Console Trying ${keyword1} and ${keyword2} ${n} times ... \ ${out1} Run Keyword And Ignore Error ${keyword1} ${element1} \ Capture Page Screenshot diff --git a/tests/robot-cases/Group1-Nightly/LDAP.robot b/tests/robot-cases/Group1-Nightly/LDAP.robot index 307565a6d..d1510ebf1 100644 --- a/tests/robot-cases/Group1-Nightly/LDAP.robot +++ b/tests/robot-cases/Group1-Nightly/LDAP.robot @@ -112,8 +112,3 @@ Test Case - Ldap User Push An Image Test Case - Ldap User Can Not login Docker Login Fail ${ip} testerDeesExist 123456 - -Test Case - Run LDAP Group Related API Test - Harbor API Test ./tests/apitests/python/test_ldap_admin_role.py - Harbor API Test ./tests/apitests/python/test_user_group.py - Harbor API Test ./tests/apitests/python/test_assign_role_to_ldap_group.py \ No newline at end of file diff --git a/tests/robot-cases/Group1-Nightly/Notary.robot b/tests/robot-cases/Group1-Nightly/Notary.robot index ab210454f..604161996 100644 --- a/tests/robot-cases/Group1-Nightly/Notary.robot +++ b/tests/robot-cases/Group1-Nightly/Notary.robot @@ -35,6 +35,7 @@ Test Case - Project Level Policy Content Trust Click Content Trust Save Project Config # Verify + Sleep 10 Content Trust Should Be Selected Cannot Pull Unsigned Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world:latest Close Browser diff --git a/tests/robot-cases/Group1-Nightly/Replication.robot b/tests/robot-cases/Group1-Nightly/Replication.robot index 535588ecc..65eb01dab 100644 --- a/tests/robot-cases/Group1-Nightly/Replication.robot +++ b/tests/robot-cases/Group1-Nightly/Replication.robot @@ -14,7 +14,7 @@ *** Settings *** Documentation Harbor BATs -Library ../../apitests/python/library/Harbor.py ${SERVER_CONFIG} +Library ../../apitests/python/library/repository.py Resource ../../resources/Util.robot Default Tags Replication @@ -37,8 +37,8 @@ Test Case - Get Harbor Version Test Case - Pro Replication Rules Add Init Chrome Driver - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Registries Switch To Replication Manage Check New Rule UI Without Endpoint Close Browser @@ -48,7 +48,6 @@ Test Case - Harbor Endpoint Verification Init Chrome Driver ${d}= Get Current Date result_format=%m%s Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} - Click Element If Visible ${close_scan_plugin_mesg} Switch To Registries Create A New Endpoint harbor edp1${d} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} N Endpoint Is Pingable @@ -56,15 +55,14 @@ Test Case - Harbor Endpoint Verification Endpoint Is Unpingable Close Browser -Test Case - DockerHub Endpoint Add +##Test Case - DockerHub Endpoint Add #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} - Click Element If Visible ${close_scan_plugin_mesg} - Switch To Registries - Create A New Endpoint docker-hub edp1${d} https://hub.docker.com/ danfengliu Aa123456 Y - Close Browser + ##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 docker-hub edp1${d} https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} Y + ##Close Browser Test Case - Harbor Endpoint Add #This case need vailid info and selfsign cert @@ -94,6 +92,7 @@ Test Case - Harbor Endpoint Delete Close Browser Test Case - Replication Rule Edit + [tags] replication_rule_edit Init Chrome Driver ${d}= Get Current Date result_format=%m%s ${endpoint1}= Set Variable e1${d} @@ -106,71 +105,74 @@ Test Case - Replication Rule Edit ${cron_str}= Set Variable 10 10 10 * * * Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Switch To Registries - Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y + #Due to docker-hub access limitation, remove docker-hub endpoint + Create A New Endpoint harbor ${endpoint1} https://${ip1} ${null} ${null} Y Create A New Endpoint harbor ${endpoint2} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y Switch To Replication Manage - Create A Rule With Existing Endpoint ${rule_name_old} pull danfengliu/* image ${endpoint1} project${d} - Edit Replication Rule By Name ${rule_name_old} + Create A Rule With Existing Endpoint ${rule_name_old} pull nightly/a* image ${endpoint1} project${d} + Edit Replication Rule ${rule_name_old} # Change rule-name, source-registry, filter, trigger-mode for edition verification Clear Field Of Characters ${rule_name_input} 30 Retry Text Input ${rule_name_input} ${rule_name_new} Select Source Registry ${endpoint2} #Source Resource Filter - Retry Text Input ${source_project} project${d} + Retry Text Input ${filter_name_id} project${d} Select From List By Value ${rule_resource_selector} ${resource_type} Retry Text Input ${dest_namespace_xpath} ${dest_namespace} Select Trigger ${mode} Retry Text Input ${targetCron_id} ${cron_str} Retry Double Keywords When Error Retry Element Click ${rule_save_button} Retry Wait Until Page Not Contains Element ${rule_save_button} # verify all items were changed as expected - Edit Replication Rule By Name ${rule_name_new} + Edit Replication Rule ${rule_name_new} Retry Textfield Value Should Be ${rule_name_input} ${rule_name_new} Retry List Selection Should Be ${src_registry_dropdown_list} ${endpoint2}-https://${ip} - Retry Textfield Value Should Be ${source_project} project${d} + Retry Textfield Value Should Be ${filter_name_id} project${d} Retry Textfield Value Should Be ${dest_namespace_xpath} ${dest_namespace} Retry List Selection Should Be ${rule_resource_selector} ${resource_type} Retry List Selection Should Be ${rule_trigger_select} ${mode} Retry Textfield Value Should Be ${targetCron_id} ${cron_str} Retry Element Click ${rule_cancel_btn} - Ensure Delete Replication Rule By Name ${rule_name_new} + Delete Replication Rule ${rule_name_new} Close Browser Test Case - Replication Rule Delete + [tags] replication_rule_delete Init Chrome Driver ${d}= Get Current Date result_format=%m%s ${endpoint1}= Set Variable e1${d} ${rule_name}= Set Variable rule_testabc${d} Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Switch To Registries - Create A New Endpoint docker-hub ${endpoint1} https://hub.docker.com/ danfengliu Aa123456 Y + Create A New Endpoint harbor ${endpoint1} https://${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Y Switch To Replication Manage - Create A Rule With Existing Endpoint ${rule_name} pull danfengliu/* image ${endpoint1} project${d} - Ensure Delete Replication Rule By Name ${rule_name} + Create A Rule With Existing Endpoint ${rule_name} pull ${DOCKER_USER}/* image ${endpoint1} project${d} + Delete Replication Rule ${rule_name} Close Browser Test Case - Replication Of Pull Images from DockerHub To Self + [tags] pull_dockerhub 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 project${d} + Create An New Project project${d} Switch To Registries - Create A New Endpoint docker-hub e${d} https://hub.docker.com/ danfengliu Aa123456 Y + Create A New Endpoint docker-hub e${d} https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} Y Switch To Replication Manage - Create A Rule With Existing Endpoint rule${d} pull danfengliu/* image e${d} project${d} + Create A Rule With Existing Endpoint rule${d} pull ${DOCKER_USER}/{cent*,mariadb} image e${d} project${d} Select Rule And Replicate rule${d} - #In docker-hub, under repository danfengliu, there're only 2 images: centos,mariadb. + #In docker-hub, under repository ${DOCKER_USER}, there're only 2 images: centos,mariadb. Image Should Be Replicated To Project project${d} centos Image Should Be Replicated To Project project${d} mariadb Close Browser Test Case - Replication Of Push Images from Self To Harbor + [tags] push_to_harbor Init Chrome Driver ${d}= Get Current Date result_format=%m%s #login source - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} - Create An New Project project${d} + 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:latest Push Image With Tag ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world v1 @@ -180,31 +182,27 @@ Test Case - Replication Of Push Images from Self To Harbor Create A Rule With Existing Endpoint rule${d} push project${d}/* image e${d} project_dest${d} #logout and login target Logout Harbor - Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} - Create An New Project project_dest${d} + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project_dest${d} #logout and login source Logout Harbor - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Switch To Replication Manage Select Rule And Replicate rule${d} Sleep 20 Logout Harbor - Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Image Should Be Replicated To Project project_dest${d} hello-world Image Should Be Replicated To Project project_dest${d} busybox Close Browser Test Case - Replication Of Push Chart from Self To Harbor + [tags] pull_from_dockerhub Init Chrome Driver ${d}= Get Current Date result_format=%m%s #login source - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Create An New Project project${d} - Go Into Project project${d} has_image=${false} Switch To Project Charts Upload Chart files Switch To Registries @@ -213,19 +211,16 @@ Test Case - Replication Of Push Chart from Self To Harbor Create A Rule With Existing Endpoint rule${d} push project${d}/* chart e${d} project_dest${d} #logout and login target Logout Harbor - Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Create An New Project project_dest${d} #logout and login source Logout Harbor - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Switch To Replication Manage Select Rule And Replicate rule${d} Sleep 20 Logout Harbor - Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Go Into Project project_dest${d} has_image=${false} Switch To Project Charts Go Into Chart Version ${harbor_chart_name} @@ -234,11 +229,11 @@ Test Case - Replication Of Push Chart from Self To Harbor Close Browser Test Case - Replication Of Push Images from Self To Harbor By Push Event + [tags] pull_from_dockerhub Init Chrome Driver ${d}= Get Current Date result_format=%m%s #login source - Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Create An New Project project${d} Switch To Registries Create A New Endpoint harbor e${d} https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} @@ -247,14 +242,14 @@ Test Case - Replication Of Push Images from Self To Harbor By Push Event ... Event Based #logout and login target Logout Harbor - Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} is_close_scan_plugin_mesg=${true} - Click Element If Visible ${close_scan_plugin_mesg} + Sign In Harbor https://${ip1} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} Create An New Project project_dest${d} Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} centos Image Should Be Replicated To Project project_dest${d} centos Close Browser Test Case - Replication Of Pull Images from AWS-ECR To Self + [tags] pull_from_dockerhub Init Chrome Driver ${d}= Get Current Date result_format=%m%s #login source @@ -271,6 +266,7 @@ Test Case - Replication Of Pull Images from AWS-ECR To Self Close Browser Test Case - Replication Of Pull Images from Google-GCR To Self + [tags] pull_from_dockerhub Init Chrome Driver ${d}= Get Current Date result_format=%m%s #login source @@ -280,8 +276,20 @@ Test Case - Replication Of Pull Images from Google-GCR To Self Create A New Endpoint google-gcr e${d} asia.gcr.io ${null} ${gcr_ac_key} Y Switch To Replication Manage Create A Rule With Existing Endpoint rule${d} pull eminent-nation-87317/* image e${d} project${d} - Filter Replicatin Rule rule${d} + Filter Replication Rule rule${d} Select Rule And Replicate rule${d} Image Should Be Replicated To Project project${d} httpd Image Should Be Replicated To Project project${d} tomcat Close Browser + +Test Case - Replication Of Push Images to DockerHub Triggered By Event + [tags] event_push_to_dockerhub + Body Of Replication Of Push Images to Registry Triggered By Event docker-hub https://hub.docker.com/ ${DOCKER_USER} ${DOCKER_PWD} ${DOCKER_USER} + +#Due to issue of delete event replication +#Test Case - Replication Of Push Images to Google-GCR Triggered By Event + #Body Of Replication Of Push Images to Registry Triggered By Event google-gcr gcr.io ${null} ${gcr_ac_key} eminent-nation-87317/harbor-nightly-replication + +Test Case - Replication Of Push Images to AWS-ECR Triggered By Event + [tags] event_push_to_aws_ecr + Body Of Replication Of Push Images to Registry Triggered By Event aws-ecr us-east-2 ${ecr_ac_id} ${ecr_ac_key} harbor-nightly-replication \ No newline at end of file