mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-16 15:25:18 +01:00
Merge pull request #13908 from danfengliu/fix-issue-of-replication-list-row-locator
Fix issue of wrong xpath for replicaiton row selector
This commit is contained in:
commit
de5445a894
@ -86,6 +86,8 @@ class DockerAPI(object):
|
|||||||
self.DCLIENT2 = docker.from_env()
|
self.DCLIENT2 = docker.from_env()
|
||||||
|
|
||||||
def docker_login(self, registry, username, password, expected_error_message = None):
|
def docker_login(self, registry, username, password, expected_error_message = None):
|
||||||
|
ret = ""
|
||||||
|
err_message = ""
|
||||||
if username == "" or password == "":
|
if username == "" or password == "":
|
||||||
print("[Warnig]: No docker credential was provided.")
|
print("[Warnig]: No docker credential was provided.")
|
||||||
return
|
return
|
||||||
@ -93,46 +95,55 @@ class DockerAPI(object):
|
|||||||
expected_error_message = None
|
expected_error_message = None
|
||||||
if registry == "docker":
|
if registry == "docker":
|
||||||
registry = None
|
registry = None
|
||||||
ret = ""
|
|
||||||
try:
|
try:
|
||||||
print("Docker login: {}:{}:{}".format(registry,username,password))
|
print("Docker login: {}:{}:{}".format(registry,username,password))
|
||||||
ret = self.DCLIENT.login(registry = registry, username=username, password=password)
|
ret = self.DCLIENT.login(registry = registry, username=username, password=password)
|
||||||
print("Docker image login commond return:", ret)
|
except Exception as err:
|
||||||
return ret
|
print( "Docker image pull catch exception:", str(err))
|
||||||
except docker.errors.APIError as err:
|
err_message = str(err)
|
||||||
if expected_error_message is not None:
|
if expected_error_message is None:
|
||||||
print( "docker login error:", str(err))
|
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, 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))
|
|
||||||
else:
|
else:
|
||||||
raise Exception(r" Docker login failed, error is [{}]".format (str(err)))
|
print("Docker image login did not catch exception and return message is:", ret)
|
||||||
|
err_message = ret
|
||||||
|
finally:
|
||||||
|
if expected_error_message is not None:
|
||||||
|
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:
|
||||||
|
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):
|
def docker_image_pull(self, image, tag = None, expected_error_message = None):
|
||||||
|
ret = ""
|
||||||
|
err_message = ""
|
||||||
if tag is not None:
|
if tag is not None:
|
||||||
_tag = tag
|
_tag = tag
|
||||||
else:
|
else:
|
||||||
_tag = "latest"
|
_tag = "latest"
|
||||||
if expected_error_message is "":
|
if expected_error_message is "":
|
||||||
expected_error_message = None
|
expected_error_message = None
|
||||||
ret = ""
|
|
||||||
try:
|
try:
|
||||||
ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
|
ret = self.DCLIENT.pull(r'{}:{}'.format(image, _tag))
|
||||||
print("Docker image pull commond return:", ret)
|
|
||||||
return ret
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if expected_error_message is not None:
|
print( "Docker image pull catch exception:", str(err))
|
||||||
print( "docker image pull error:", str(err))
|
err_message = str(err)
|
||||||
if str(err).lower().find(expected_error_message.lower()) < 0:
|
if expected_error_message is None:
|
||||||
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, str(err)))
|
raise Exception(r" Docker pull image {} failed, error is [{}]".format (image, str(err)))
|
||||||
else:
|
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 expected_error_message is not None:
|
||||||
if str(ret).lower().find(expected_error_message.lower()) < 0:
|
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, str(ret)))
|
raise Exception(r" Failed to catch error [{}] when pull image {}, return message: {}".format (expected_error_message, image, err_message))
|
||||||
else:
|
else:
|
||||||
if str(ret).lower().find("error".lower()) >= 0:
|
print(r"Docker image pull got expected error message:{}".format(expected_error_message))
|
||||||
raise Exception(r" It's was not suppose to catch error when pull image {}, return message is [{}]".format (image, ret))
|
else:
|
||||||
|
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):
|
def docker_image_tag(self, image, harbor_registry, tag = None):
|
||||||
_tag = base._random_name("tag")
|
_tag = base._random_name("tag")
|
||||||
@ -148,40 +159,37 @@ class DockerAPI(object):
|
|||||||
|
|
||||||
def docker_image_push(self, harbor_registry, tag, expected_error_message = None):
|
def docker_image_push(self, harbor_registry, tag, expected_error_message = None):
|
||||||
ret = ""
|
ret = ""
|
||||||
|
err_message = ""
|
||||||
if expected_error_message is "":
|
if expected_error_message is "":
|
||||||
expected_error_message = None
|
expected_error_message = None
|
||||||
try:
|
try:
|
||||||
ret = self.DCLIENT.push(harbor_registry, tag)
|
ret = self.DCLIENT.push(harbor_registry, tag)
|
||||||
print("Docker image push commond return:", ret)
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print( "docker image push catch Exception:", str(err))
|
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:
|
if expected_error_message is not None:
|
||||||
print( "docker image push error:", str(err))
|
if str(err_message).lower().find(expected_error_message.lower()) < 0:
|
||||||
if str(err).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))
|
||||||
raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message))
|
|
||||||
else:
|
else:
|
||||||
raise Exception(r" Docker push image {} failed, error is [{}]".format (harbor_registry, message))
|
print(r"Docker image push got expected error message:{}".format(expected_error_message))
|
||||||
else:
|
else:
|
||||||
print( "docker image push does not catch Exception:", str(expected_error_message))
|
if str(err_message).lower().find("error".lower()) >= 0:
|
||||||
if expected_error_message is not None:
|
raise Exception(r" It's was not suppose to catch error when push image {}, return message is [{}]".format (harbor_registry, err_message))
|
||||||
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:
|
|
||||||
print("docker image push action return expected error message [{}]".format(expected_error_message))
|
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None):
|
def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None):
|
||||||
ret = ""
|
ret = ""
|
||||||
|
err_message = ""
|
||||||
try:
|
try:
|
||||||
baseimage='busybox:latest'
|
baseimage='busybox:latest'
|
||||||
self.DCLIENT.login(username=DOCKER_USER, password=DOCKER_PWD)
|
self.DCLIENT.login(username=DOCKER_USER, password=DOCKER_PWD)
|
||||||
if not self.DCLIENT.images(name=baseimage):
|
if not self.DCLIENT.images(name=baseimage):
|
||||||
print( "docker pull is triggered when building {}".format(harbor_registry))
|
print( "Docker pull is triggered when building {}".format(harbor_registry))
|
||||||
self.DCLIENT.pull(baseimage)
|
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=%d' % size )
|
||||||
self.DCLIENT.start(c)
|
self.DCLIENT.start(c)
|
||||||
@ -203,23 +211,20 @@ class DockerAPI(object):
|
|||||||
self.DCLIENT.remove_container(c)
|
self.DCLIENT.remove_container(c)
|
||||||
#self.DCLIENT.pull(repo)
|
#self.DCLIENT.pull(repo)
|
||||||
#image = self.DCLIENT2.images.get(repo)
|
#image = self.DCLIENT2.images.get(repo)
|
||||||
return repo
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
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 (image, 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:
|
if expected_error_message is not None:
|
||||||
print( "docker image build error:", str(err))
|
if str(err_message).lower().find(expected_error_message.lower()) < 0:
|
||||||
if str(err).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))
|
||||||
raise Exception(r"Push image: Return message {} is not as expected {}".format(str(err), expected_error_message))
|
|
||||||
else:
|
else:
|
||||||
raise Exception(r" Docker build image {} failed, error is [{}]".format (harbor_registry, str(err)))
|
print(r"Docker image build got expected error message: {}".format(expected_error_message))
|
||||||
else:
|
else:
|
||||||
print("docker image build does not catch Exception:", str(expected_error_message))
|
if str(err_message).lower().find("error".lower()) >= 0:
|
||||||
print("Docker build -> docker image push ret:", ret)
|
raise Exception(r" It's was not suppose to catch error when build image {}, return message is [{}]".format (harbor_registry, err_message))
|
||||||
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:
|
|
||||||
print("docker image build return expected error message [{}]".format(expected_error_message))
|
|
||||||
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))
|
|
||||||
|
@ -157,7 +157,7 @@ Rename Rule
|
|||||||
|
|
||||||
Select Rule
|
Select Rule
|
||||||
[Arguments] ${rule}
|
[Arguments] ${rule}
|
||||||
Retry Double Keywords When Error Retry Element Click //clr-dg-cell[contains(.,'${rule}')] Retry Wait Element ${replication_rule_exec_id}
|
Retry Double Keywords When Error Retry Element Click //clr-dg-row[contains(.,'${rule}')]/div/div[2]/div//clr-radio-wrapper/label Retry Wait Element ${replication_rule_exec_id}
|
||||||
|
|
||||||
Stop Jobs
|
Stop Jobs
|
||||||
Retry Element Click ${stop_jobs_button}
|
Retry Element Click ${stop_jobs_button}
|
||||||
|
Loading…
Reference in New Issue
Block a user