Skip to content

Commit

Permalink
Remove chartmuseum test case
Browse files Browse the repository at this point in the history
Harbor deprecates chartmuseum as of v2.8.0
Epic: goharbor#17958
Discussion: goharbor#15057

Signed-off-by: Yang Jiao <jiaoya@vmware.com>
  • Loading branch information
Yang Jiao authored and YangJiao0817 committed Feb 24, 2023
1 parent 10c54c0 commit 4545974
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 577 deletions.
10 changes: 0 additions & 10 deletions tests/apitests/python/library/Harbor.py

This file was deleted.

17 changes: 3 additions & 14 deletions tests/apitests/python/library/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import subprocess
import time

import client
import swagger_client
import v2_swagger_client

try:
Expand All @@ -27,16 +25,8 @@ def get_endpoint():
harbor_server = os.environ.get("HARBOR_HOST", "localhost:8080")
return os.environ.get("HARBOR_HOST_SCHEMA", "https")+ "://"+harbor_server+"/api/v2.0"

def _create_client(server, credential, debug, api_type="products"):
cfg = None
if api_type in ('projectv2', 'artifact', 'repository', 'scanner', 'scan', 'scanall', 'preheat', 'quota',
'replication', 'registry', 'robot', 'gc', 'retention', 'immutable', 'system_cve_allowlist',
'configure', 'user', 'member', 'health', 'label', 'webhook', 'purge', 'audit_log', 'scan_data_export',
'statistic', "system_info", "jobservice", "schedule"):
cfg = v2_swagger_client.Configuration()
else:
cfg = swagger_client.Configuration()

def _create_client(server, credential, debug, api_type):
cfg = v2_swagger_client.Configuration()
cfg.host = server.endpoint
cfg.verify_ssl = server.verify_ssl
# support basic auth only for now
Expand All @@ -55,7 +45,6 @@ def _create_client(server, credential, debug, api_type="products"):
cfg.auth_settings = types.MethodType(lambda self: {}, cfg)

return {
"products": swagger_client.ProductsApi(swagger_client.ApiClient(cfg)),
"projectv2":v2_swagger_client.ProjectApi(v2_swagger_client.ApiClient(cfg)),
"artifact": v2_swagger_client.ArtifactApi(v2_swagger_client.ApiClient(cfg)),
"preheat": v2_swagger_client.PreheatApi(v2_swagger_client.ApiClient(cfg)),
Expand Down Expand Up @@ -161,7 +150,7 @@ def run_command(command, expected_error_message = None):
return output

class Base(object):
def __init__(self, server=None, credential=None, debug=True, api_type="products"):
def __init__(self, server=None, credential=None, debug=True, api_type=""):
if server is None:
server = Server(endpoint=get_endpoint(), verify_ssl=False)
if not isinstance(server.verify_ssl, bool):
Expand Down
1 change: 0 additions & 1 deletion tests/apitests/python/library/configurations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

from swagger_client.rest import ApiException
from v2_swagger_client.rest import ApiException

import base
Expand Down
53 changes: 0 additions & 53 deletions tests/apitests/python/library/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,6 @@
import os
import base

def get_chart_file(file_name):
command = ["wget", file_name]
ret = base.run_command(command)
print("Command return: ", ret)
command = ["tar", "xvf", file_name.split('/')[-1]]
ret = base.run_command(command)
print("Command return: ", ret)

def helm_login(harbor_server, user, password):
os.putenv("HELM_EXPERIMENTAL_OCI", "1")
command = ["helm3", "registry", "login", harbor_server, "-u", user, "-p", password]
ret = base.run_command(command)
print("Command return: ", ret)

def helm_save(chart_archive, harbor_server, project, repo_name):
command = ["helm3", "chart","save", chart_archive, harbor_server+"/"+project+"/"+repo_name]
base.run_command(command)

def helm_push(harbor_server, project, repo_name, version):
command = ["helm3", "chart", "push", harbor_server+"/"+project+"/"+repo_name+":"+version]
ret = base.run_command(command)
return ret

def helm_chart_push_to_harbor(chart_file, archive, harbor_server, project, repo_name, version, user, password):
get_chart_file(chart_file)
helm_login(harbor_server, user, password)
helm_save(archive, harbor_server, project, repo_name)
return helm_push(harbor_server, project, repo_name, version)

def helm2_add_repo(helm_repo_name, harbor_url, project, username, password, expected_error_message = None):
command = ["helm2", "repo", "add", "--username=" + username, "--password=" + password, helm_repo_name, harbor_url + "/chartrepo/" + project]
ret = base.run_command(command, expected_error_message = expected_error_message)


def helm2_push(helm_repo_name, chart_file, project, username, password):
get_chart_file(chart_file)
command = ["helm2", "cm-push", "--username=" + username, "--password=" + password, chart_file.split('/')[-1], helm_repo_name]
base.run_command(command)

def helm2_repo_update():
command = ["helm2", "repo", "update"]
base.run_command(command)

def helm2_fetch_chart_file(helm_repo_name, harbor_url, project, username, password, chart_file, expected_add_repo_error_message = None):
helm2_add_repo(helm_repo_name, harbor_url, project, username, password, expected_error_message = expected_add_repo_error_message)
if expected_add_repo_error_message is not None:
return
helm2_repo_update()
command_ls = ["ls"]
base.run_command(command_ls)
command = ["helm2", "fetch", "{}/{}".format(helm_repo_name, chart_file)]
base.run_command(command)
base.run_command(command_ls)

def helm3_7_registry_login(ip, user, password):
command = ["helm3.7", "registry", "login", ip, "-u", user, "-p", password]
Expand Down
3 changes: 1 addition & 2 deletions tests/apitests/python/library/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def get_project_members(self, project_id, **kwargs):
return self._get_client(**kwargs).list_project_members(project_id)

def get_project_member(self, project_id, member_id, expect_status_code = 200, expect_response_body = None, **kwargs):
from swagger_client.rest import ApiException
kwargs['api_type'] = 'member'
data = []
try:
Expand Down Expand Up @@ -213,4 +212,4 @@ def query_user_logs(self, project_name, status_code=200, **kwargs):
return count
except ApiException as e:
_assert_status_code(status_code, e.status)
return 0
return 0
8 changes: 4 additions & 4 deletions tests/apitests/python/library/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import time
import base
import swagger_client
import v2_swagger_client
import docker_api
from docker_api import DockerAPI
from swagger_client.rest import ApiException
from v2_swagger_client.rest import ApiException
from testutils import DOCKER_USER, DOCKER_PWD

def pull_harbor_image(registry, username, password, image, tag, expected_login_error_message = None, expected_error_message = None):
Expand Down Expand Up @@ -124,7 +124,7 @@ def get_repository(self, project_name, repo_name, **kwargs):

def add_label_to_tag(self, repo_name, tag, label_id, expect_status_code = 200, **kwargs):
client = self._get_client(**kwargs)
label = swagger_client.Label(id=label_id)
label = v2_swagger_client.Label(id=label_id)
_, status_code, _ = client.repositories_repo_name_tags_tag_labels_post_with_http_info(repo_name, tag, label)
base._assert_status_code(expect_status_code, status_code)

Expand Down Expand Up @@ -160,7 +160,7 @@ def signature_should_exist(self, repo_name, tag, **kwargs):

def retag_image(self, repo_name, tag, src_image, override=True, expect_status_code = 200, expect_response_body = None, **kwargs):
client = self._get_client(**kwargs)
request = swagger_client.RetagReq(tag=tag, src_image=src_image, override=override)
request = v2_swagger_client.RetagReq(tag=tag, src_image=src_image, override=override)

try:
data, status_code, _ = client.repositories_repo_name_tags_post_with_http_info(repo_name, request)
Expand Down
8 changes: 4 additions & 4 deletions tests/apitests/python/library/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import time
import re
import base
import swagger_client
from swagger_client.rest import ApiException
import v2_swagger_client
from v2_swagger_client.rest import ApiException

class System(base.Base):
def get_gc_history(self, expect_status_code = 200, expect_response_body = None, **kwargs):
Expand Down Expand Up @@ -73,8 +73,8 @@ def get_gc_schedule(self, expect_status_code = 200, expect_response_body = None,

def set_cve_allowlist(self, expires_at=None, expected_status_code=200, *cve_ids, **kwargs):
client = self._get_client(**kwargs)
cve_list = [swagger_client.CVEAllowlistItem(cve_id=c) for c in cve_ids]
allowlist = swagger_client.CVEAllowlist(expires_at=expires_at, items=cve_list)
cve_list = [v2_swagger_client.CVEAllowlistItem(cve_id=c) for c in cve_ids]
allowlist = v2_swagger_client.CVEAllowlist(expires_at=expires_at, items=cve_list)
try:
r = client.system_cve_allowlist_put_with_http_info(allowlist=allowlist, _preload_content=False)
except Exception as e:
Expand Down
40 changes: 0 additions & 40 deletions tests/apitests/python/test_ldap_ping.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/apitests/python/test_p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from library.repository import pull_harbor_image
from library.artifact import Artifact
from library.preheat import Preheat
import library.containerd
import v2_swagger_client

class TestP2P(unittest.TestCase):
Expand Down

This file was deleted.

Loading

0 comments on commit 4545974

Please sign in to comment.