diff --git a/tests/apitests/python/library/docker_api.py b/tests/apitests/python/library/docker_api.py index 8fd5fa86a..7ee2c8319 100644 --- a/tests/apitests/python/library/docker_api.py +++ b/tests/apitests/python/library/docker_api.py @@ -34,20 +34,18 @@ class DockerAPI(object): _tag = "latest" if expected_error_message is "": expected_error_message = None - caught_err = False ret = "" try: - self.DCLIENT.pull(r'{}:{}'.format(image, _tag)) + ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag)) return ret except Exception as err: - caught_err = True 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)) - if caught_err == False: + else: 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))) diff --git a/tests/apitests/python/library/repository.py b/tests/apitests/python/library/repository.py index cec1b6fd0..497adc818 100644 --- a/tests/apitests/python/library/repository.py +++ b/tests/apitests/python/library/repository.py @@ -20,7 +20,8 @@ def push_image_to_project(project_name, registry, username, password, image, tag time.sleep(2) if expected_login_error_message != None: return - _docker_api.docker_image_pull(image, tag = tag) + ret = _docker_api.docker_image_pull(image, tag = tag) + print("docker image pull ret:", ret) time.sleep(2) new_harbor_registry, new_tag = _docker_api.docker_image_tag(r'{}:{}'.format(image, tag), r'{}/{}/{}'.format(registry, project_name, image)) @@ -147,4 +148,4 @@ class Repository(base.Base): base._assert_status_code(expect_status_code, status_code) base._assert_status_code(200, status_code) - return data \ No newline at end of file + return data diff --git a/tests/resources/Harbor-Util.robot b/tests/resources/Harbor-Util.robot index 1d6fbe261..00bd39b6a 100644 --- a/tests/resources/Harbor-Util.robot +++ b/tests/resources/Harbor-Util.robot @@ -55,7 +55,9 @@ Package Harbor Offline [Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=true ${with_chartmuseum}=true Log To Console \nStart Docker Daemon Start Docker Daemon Locally - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD + ${rc} ${output}= Run And Return Rc And Output docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD + Log ${rc} + Log ${output} Log To Console \n\nmake package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY= ${rc} ${output}= Run And Return Rc And Output make package_offline BASEIMAGETAG=%{Harbor_Build_Base_Tag} NPM_REGISTRY=%{NPM_REGISTRY} VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY= Log To Console ${rc} @@ -66,7 +68,9 @@ Package Harbor Online [Arguments] ${with_notary}=true ${with_clair}=true ${with_migrator}=false ${with_chartmuseum}=true Log To Console \nStart Docker Daemon Start Docker Daemon Locally - docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD + ${rc} ${output}= Run And Return Rc And Output docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD + Log ${rc} + Log ${output} Log To Console \nmake package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY= ${rc} ${output}= Run And Return Rc And Output make package_online VERSIONTAG=%{Harbor_Assets_Version} PKGVERSIONTAG=%{Harbor_Package_Version} NOTARYFLAG=${with_notary} CLAIRFLAG=${with_clair} MIGRATORFLAG=${with_migrator} CHARTFLAG=${with_chartmuseum} HTTPPROXY= Log ${rc}