From 3eeb8cf355af4e3aedae18285a707f95b737816c Mon Sep 17 00:00:00 2001 From: danfengliu Date: Thu, 1 Aug 2019 15:29:42 +0800 Subject: [PATCH] After helm cli test was added to nightly, ca was get by reading from local file, but in helm nighly test, ca file was not in local, it has to be got from harbor api. Signed-off-by: danfengliu --- tests/apitests/python/library/Harbor.py | 2 +- tests/apitests/python/library/base.py | 2 +- tests/apitests/python/library/registry.py | 2 +- tests/apitests/python/library/replication.py | 25 -------------------- tests/resources/Helm-Util.robot | 3 +++ tests/resources/Nightly-Util.robot | 1 + 6 files changed, 7 insertions(+), 28 deletions(-) diff --git a/tests/apitests/python/library/Harbor.py b/tests/apitests/python/library/Harbor.py index 29f12db99..096f9f782 100644 --- a/tests/apitests/python/library/Harbor.py +++ b/tests/apitests/python/library/Harbor.py @@ -8,7 +8,7 @@ import replication import repository import swagger_client -class Harbor(project.Project, label.Label, +class Harbor(project.Project, label.Label, registry.Registry, replication.Replication, repository.Repository): pass \ No newline at end of file diff --git a/tests/apitests/python/library/base.py b/tests/apitests/python/library/base.py index 362bf2dd3..daaf8eba7 100644 --- a/tests/apitests/python/library/base.py +++ b/tests/apitests/python/library/base.py @@ -51,7 +51,7 @@ def _get_string_from_unicode(udata): return result class Base: - def __init__(self, + def __init__(self, server = Server(endpoint="http://localhost:8080/api", verify_ssl=False), credential = Credential(type="basic_auth", username="admin", password="Harbor12345"), debug = True): diff --git a/tests/apitests/python/library/registry.py b/tests/apitests/python/library/registry.py index decabb19f..a0466ce58 100644 --- a/tests/apitests/python/library/registry.py +++ b/tests/apitests/python/library/registry.py @@ -14,7 +14,7 @@ class Registry(base.Base): username=username, password=password, insecure=insecure) _, _, header = client.targets_post_with_http_info(registry) return base._get_id_from_header(header), name - + def get_registry_id_by_endpoint(self, endpoint, **kwargs): client = self._get_client(**kwargs) registries = client.targets_get() diff --git a/tests/apitests/python/library/replication.py b/tests/apitests/python/library/replication.py index af32ae73d..9406339b1 100644 --- a/tests/apitests/python/library/replication.py +++ b/tests/apitests/python/library/replication.py @@ -6,31 +6,6 @@ import base import swagger_client class Replication(base.Base): - def create_replication_rule(self, - projectIDList, targetIDList, name=None, desc="", - filters=[], trigger=swagger_client.RepTrigger(kind="Manual"), - replicate_deletion=True, - replicate_existing_image_now=False, - expect_status_code = 201, - **kwargs): - if name is None: - name = base._random_name("rule") - projects = [] - for projectID in projectIDList: - projects.append(swagger_client.Project(project_id=int(projectID))) - targets = [] - for targetID in targetIDList: - targets.append(swagger_client.RepTarget(id=int(targetID))) - for filter in filters: - filter["value"] = int(filter["value"]) - client = self._get_client(**kwargs) - policy = swagger_client.RepPolicy(name=name, description=desc, - projects=projects, targets=targets, filters=filters, - trigger=trigger, replicate_deletion=replicate_deletion, - replicate_existing_image_now=replicate_existing_image_now) - _, status_code, header = client.policies_replication_post_with_http_info(policy) - base._assert_status_code(expect_status_code, status_code) - return base._get_id_from_header(header), name def get_replication_rule(self, param = None, rule_id = None, expect_status_code = 200, **kwargs): client = self._get_client(**kwargs) diff --git a/tests/resources/Helm-Util.robot b/tests/resources/Helm-Util.robot index b677a4f8b..06be47dbf 100644 --- a/tests/resources/Helm-Util.robot +++ b/tests/resources/Helm-Util.robot @@ -18,6 +18,9 @@ Library OperatingSystem Library Process *** Keywords *** +Prepare Helm Cert + Wait Unitl Command Success cp harbor_ca.crt /helm_ca/server.crt + Helm Repo Add [Arguments] ${harbor_url} ${user} ${pwd} ${project_name}=library ${helm_repo_name}=myrepo ${rc} ${output}= Run And Return Rc And Output helm repo remove ${project_name} diff --git a/tests/resources/Nightly-Util.robot b/tests/resources/Nightly-Util.robot index 132053eeb..1b1c7c4ac 100644 --- a/tests/resources/Nightly-Util.robot +++ b/tests/resources/Nightly-Util.robot @@ -32,6 +32,7 @@ CA Setup Run mv ${cert} harbor_ca.crt Generate Certificate Authority For Chrome ${HARBOR_PASSWORD} Prepare Docker Cert ${ip} + Prepare Helm Cert Collect Nightly Logs [Arguments] ${ip} ${SSH_PWD} ${ip1}==${EMPTY}