Add docker-hub login before docker-hub pull

Due to docker-hub pull request rate limitation, we will use registed account to pull image
from docker-hub, therefore add docker-hub login in API tests.

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2020-11-10 17:33:09 +08:00
parent def782b6f8
commit 2bf89e9356
37 changed files with 188 additions and 218 deletions

View File

@ -95,7 +95,7 @@ jobs:
uploader ${harbor_online_build_bundle}.asc $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz $harbor_target_bucket
uploader harbor-offline-installer-latest.tgz.asc $harbor_target_bucket
echo "::set-env name=BUILD_BUNDLE::$harbor_offline_build_bundle"
echo "BUILD_BUNDLE=$harbor_offline_build_bundle" >> $GITHUB_ENV
- name: Slack Notification
uses: sonots/slack-notice-action@v3
with:

View File

@ -118,7 +118,7 @@ class Artifact(base.Base, object):
None: False,
}.get(artifact, True)
def waiting_for_reference_exist(self, project_name, repo_name, reference, ignore_not_found = True, period = 60, loop_count = 18, **kwargs):
def waiting_for_reference_exist(self, project_name, repo_name, reference, ignore_not_found = True, period = 60, loop_count = 20, **kwargs):
_loop_count = loop_count
while True:
print("Waiting for reference {} round...".format(_loop_count))

View File

@ -3,6 +3,7 @@
import base
import json
import docker_api
from testutils import DOCKER_USER, DOCKER_PWD
def load_bundle(service_image, invocation_image):
bundle_file = "./tests/apitests/python/bundle_data/bundle.json"
@ -41,6 +42,10 @@ def cnab_push_bundle(bundle_file, target):
def push_cnab_bundle(harbor_server, user, password, service_image, invocation_image, target, auto_update_bundle = True):
docker_api.docker_info_display()
#Add docker login command to avoid pull request access rate elimitation by docker hub
docker_api.docker_login_cmd("", DOCKER_USER, DOCKER_PWD, enable_manifest = False)
docker_api.docker_login_cmd(harbor_server, user, password, enable_manifest = False)
bundle_file = load_bundle(service_image, invocation_image)
fixed_bundle_file = cnab_fixup_bundle(bundle_file, target, auto_update_bundle = auto_update_bundle)

View File

@ -3,6 +3,7 @@
import base
import subprocess
import json
from testutils import DOCKER_USER, DOCKER_PWD
try:
import docker
@ -17,13 +18,17 @@ def docker_info_display():
ret = base.run_command(command)
print("Command return: ", ret)
def docker_login_cmd(harbor_host, user, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh", enable_manifest = True):
command = ["sudo", "docker", "login", harbor_host, "-u", user, "-p", password]
def docker_login_cmd(harbor_host, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh", enable_manifest = True):
if username == "" or password == "":
print("[Warnig]: No docker credential was provided.")
return
command = ["sudo", "docker", "login", harbor_host, "-u", username, "-p", password]
print( "Docker Login Command: ", command)
base.run_command(command)
if enable_manifest == True:
try:
ret = subprocess.check_output([cfg_file], shell=False)
print("docker login cmd ret:", ret)
except subprocess.CalledProcessError as exc:
raise Exception("Failed to update docker config, error is {} {}.".format(exc.returncode, exc.output))
@ -46,30 +51,30 @@ def docker_manifest_push(index):
manifest_list.append(line[-71:])
return index_sha256, manifest_list
def docker_manifest_push_to_harbor(index, manifests, harbor_server, user, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh"):
docker_login_cmd(harbor_server, user, password, cfg_file=cfg_file)
def docker_manifest_push_to_harbor(index, manifests, harbor_server, username, password, cfg_file = "./tests/apitests/python/update_docker_cfg.sh"):
docker_login_cmd(harbor_server, username, password, cfg_file=cfg_file)
docker_manifest_create(index, manifests)
return docker_manifest_push(index)
def list_repositories(harbor_host, user, password, n = None, last = None):
def list_repositories(harbor_host, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n+"&last="+last, "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n, "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/_catalog", "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/_catalog", "--insecure"]
print( "List Repositories Command: ", command)
ret = base.run_command(command)
repos = json.loads(ret).get("repositories","")
return repos
def list_image_tags(harbor_host, repository, user, password, n = None, last = None):
def list_image_tags(harbor_host, repository, username, password, n = None, last = None):
if n is not None and last is not None:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n+"&last="+last, "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n+"&last="+last, "--insecure"]
elif n is not None:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n, "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list"+"?n=%d"%n, "--insecure"]
else:
command = ["curl", "-s", "-u", user+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list", "--insecure"]
command = ["curl", "-s", "-u", username+":"+password, "https://"+harbor_host+"/v2/"+repository+"/tags/list", "--insecure"]
print( "List Image Tags Command: ", command)
ret = base.run_command(command)
tags = json.loads(ret).get("tags","")
@ -81,10 +86,17 @@ class DockerAPI(object):
self.DCLIENT2 = docker.from_env()
def docker_login(self, registry, username, password, expected_error_message = None):
if expected_error_message is "":
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
ret = ""
try:
self.DCLIENT.login(registry = registry, username=username, password=password)
ret = self.DCLIENT.login(registry = registry, username=username, password=password)
return ret
except docker.errors.APIError as err:
if expected_error_message is not None:
print( "docker login error:", str(err))
@ -100,20 +112,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))
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, str(err)))
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)))
@ -155,10 +165,10 @@ class DockerAPI(object):
format (harbor_registry, ret))
def docker_image_build(self, harbor_registry, tags=None, size=1, expected_error_message = None):
caught_err = False
ret = ""
try:
baseimage='busybox:latest'
self.DCLIENT.login(username=DOCKER_USER, password=DOCKER_PWD)
if not self.DCLIENT.images(name=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 )
@ -182,14 +192,13 @@ class DockerAPI(object):
image = self.DCLIENT2.images.get(repo)
return repo, image.id
except Exception as err:
caught_err = True
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))
else:
raise Exception(r" Docker build image {} failed, error is [{}]".format (harbor_registry, str(err)))
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 build image {}, return message: {}".

View File

@ -5,6 +5,7 @@ import base
import swagger_client
from docker_api import DockerAPI
from 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):
_docker_api = DockerAPI()
@ -18,11 +19,12 @@ def pull_harbor_image(registry, username, password, image, tag, expected_login_e
def push_image_to_project(project_name, registry, username, password, image, tag, expected_login_error_message = None, expected_error_message = None, profix_for_image = None, new_image=None):
print("Start to push image {}/{}/{}:{}".format(registry, project_name, image, tag) )
_docker_api = DockerAPI()
_docker_api.docker_login("docker", DOCKER_USER, DOCKER_PWD)
_docker_api.docker_image_pull(image, tag = tag)
_docker_api.docker_login(registry, username, password, expected_error_message = expected_login_error_message)
time.sleep(2)
if expected_login_error_message != None:
return
_docker_api.docker_image_pull(image, tag = tag)
time.sleep(2)
original_name = image
image = new_image or image

View File

@ -5,7 +5,7 @@ import unittest
import urllib
import sys
from testutils import ADMIN_CLIENT, suppress_urllib3_warning
from testutils import ADMIN_CLIENT, suppress_urllib3_warning, DOCKER_USER, DOCKER_PWD
from testutils import harbor_server
from testutils import TEARDOWN
from library.base import _random_name
@ -65,9 +65,9 @@ class TestProxyCache(unittest.TestCase):
#1. Create a new registry;
if registry_type == "docker-hub":
user_namespace = "danfengliu"
user_namespace = DOCKER_USER
access_key = user_namespace
access_secret = "Aa123456"
access_secret = DOCKER_PWD
registry = "https://hub.docker.com"
# Memo: ctr will not send image pull request if manifest list already exist, so we pull different manifest list for different registry;
index_for_ctr = dict(image = "alpine", tag = "3.12.0")

View File

@ -12,7 +12,6 @@ from library.project import Project
from library.user import User
from library.repository import Repository
from library.artifact import Artifact
from library.docker_api import DockerAPI
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
@ -44,12 +43,11 @@ class TestProjects(unittest.TestCase):
Test step and expected result:
1. Create a new user(UA);
2. Create a new project(PA) by user(UA);
3. Pull images for bundle;
4. Push bundle to harbor as repository(RA);
5. Get repository from Harbor successfully;
6. Verfiy bundle name;
7. Get artifact by sha256;
8. Verify artifact information.
3. Push bundle to harbor as repository(RA);
4. Get repository from Harbor successfully;
5. Verfiy bundle name;
6. Get artifact by sha256;
7. Verify artifact information.
Tear down:
1. Delete repository(RA) by user(UA);
2. Delete project(PA);
@ -63,31 +61,26 @@ class TestProjects(unittest.TestCase):
#2. Create a new project(PA) by user(UA);
TestProjects.project_push_bundle_id, TestProjects.project_push_bundle_name = self.project.create_project(metadata = {"public": "false"}, **TestProjects.USER_CLIENT)
#3. Pull images for bundle;
_docker_api = DockerAPI()
_docker_api.docker_image_pull("alpine", tag = "latest")
_docker_api.docker_image_pull("haproxy", tag = "latest")
#4. Push bundle to harbor as repository(RA);
#3. Push bundle to harbor as repository(RA);
target = harbor_server + "/" + TestProjects.project_push_bundle_name + "/" + self.cnab_repo_name + ":" + self.cnab_tag
reference_sha256 = library.cnab.push_cnab_bundle(harbor_server, user_name, self.user_push_cnab_password, "alpine:latest", "haproxy:latest", target)
#5. Get repository from Harbor successfully;
#4. Get repository from Harbor successfully;
index_data = self.repo.get_repository(TestProjects.project_push_bundle_name, self.cnab_repo_name, **TestProjects.USER_CLIENT)
#5.2 Cnab bundle can be pulled by ctr successfully;
#4.2 Cnab bundle can be pulled by ctr successfully;
# This step might not successful since ctr does't support cnab fully, it might be uncomment sometime in future.
# Please keep them in comment!
#library.containerd.ctr_images_pull(user_name, self.user_push_cnab_password, target)
#library.containerd.ctr_images_list(oci_ref = target)
#6. Verfiy bundle name;
#5. Verfiy bundle name;
self.assertEqual(index_data.name, TestProjects.project_push_bundle_name + "/" + self.cnab_repo_name)
#7. Get artifact by sha256;
#6. Get artifact by sha256;
artifact = self.artifact.get_reference_info(TestProjects.project_push_bundle_name, self.cnab_repo_name, reference_sha256, **TestProjects.USER_CLIENT)
#8. Verify artifact information;
#7. Verify artifact information;
self.assertEqual(artifact.type, 'CNAB')
self.assertEqual(artifact.digest, reference_sha256)

View File

@ -10,6 +10,7 @@ from library.registry import Registry
from library.artifact import Artifact
from library.repository import Repository
import swagger_client
from testutils import DOCKER_USER, DOCKER_PWD
class TestProjects(unittest.TestCase):
@suppress_urllib3_warning
@ -75,7 +76,7 @@ class TestProjects(unittest.TestCase):
expected_project_id = TestProjects.project_add_rule_id, **TestProjects.USER_add_rule_CLIENT)
#3. Create a new registry;
TestProjects.registry_id, _ = self.registry.create_registry("https://hub.docker.com", registry_type="docker-hub", access_key = "", access_secret = "", insecure=False, **ADMIN_CLIENT)
TestProjects.registry_id, _ = self.registry.create_registry("https://hub.docker.com", registry_type="docker-hub", access_key = DOCKER_USER, access_secret = DOCKER_PWD, insecure=False, **ADMIN_CLIENT)
#4. Create a pull-based rule for this registry;
TestProjects.rule_id, rule_name = self.replication.create_replication_policy(src_registry=swagger_client.Registry(id=int(TestProjects.registry_id)),

View File

@ -4,14 +4,16 @@ import sys
import warnings
from functools import wraps
sys.path.insert(0, os.environ["SWAGGER_CLIENT_PATH"])
sys.path.insert(0, os.environ.get("SWAGGER_CLIENT_PATH", ''))
path=os.getcwd() + "/library"
sys.path.insert(0, path)
path=os.getcwd() + "/tests/apitests/python/library"
sys.path.insert(0, path)
path=os.getcwd() + "/tests/apitests/python/"
sys.path.insert(0, path)
print(sys.path)
import v2_swagger_client
from swagger_client.rest import ApiException
import swagger_client.models
@ -20,15 +22,17 @@ from pprint import pprint
admin_user = "admin"
admin_pwd = "Harbor12345"
harbor_server = os.environ["HARBOR_HOST"]
harbor_server = os.environ.get("HARBOR_HOST", '')
#CLIENT=dict(endpoint="https://"+harbor_server+"/api")
ADMIN_CLIENT=dict(endpoint = os.environ.get("HARBOR_HOST_SCHEMA", "https")+ "://"+harbor_server+"/api/v2.0", username = admin_user, password = admin_pwd)
CHART_API_CLIENT=dict(endpoint = os.environ.get("HARBOR_HOST_SCHEMA", "https")+ "://"+harbor_server+"/api", username = admin_user, password = admin_pwd)
USER_ROLE=dict(admin=0,normal=1)
TEARDOWN = os.environ.get('TEARDOWN', 'true').lower() in ('true', 'yes')
notary_url = os.environ.get('NOTARY_URL', 'https://'+harbor_server+':4443')
DOCKER_USER = os.environ.get('DOCKER_USER', '')
DOCKER_PWD = os.environ.get('DOCKER_PWD', '')
def GetProductApi(username, password, harbor_server= os.environ["HARBOR_HOST"]):
def GetProductApi(username, password, harbor_server= os.environ.get("HARBOR_HOST", '')):
cfg = swagger_client.Configuration()
cfg.host = "https://"+harbor_server+"/api/v2.0"
@ -40,7 +44,7 @@ def GetProductApi(username, password, harbor_server= os.environ["HARBOR_HOST"]):
api_instance = swagger_client.ProductsApi(api_client)
return api_instance
def GetRepositoryApi(username, password, harbor_server= os.environ["HARBOR_HOST"]):
def GetRepositoryApi(username, password, harbor_server= os.environ.get("HARBOR_HOST", '')):
cfg = v2_swagger_client.Configuration()
cfg.host = "https://"+harbor_server+"/api/v2.0"
@ -71,8 +75,7 @@ def suppress_urllib3_warning(func):
warnings.filterwarnings(action="ignore",
message="unclosed",
category=ResourceWarning)
warnings.filterwarnings(action='ignore',
message='Unverified HTTPS request')
warnings.filterwarnings(action='ignore', message='Unverified HTTPS request')
func(*args)
return inner_func

View File

@ -31,7 +31,7 @@ set +e
docker ps
# run db auth api cases
if [ "$1" = 'DB' ]; then
docker run -i --privileged -v $DIR/../../:/drone -v $DIR/../:/ca -w /drone $E2E_IMAGE robot -v ip:$2 -v ip1: -v HARBOR_PASSWORD:Harbor12345 /drone/tests/robot-cases/Group1-Nightly/Setup.robot /drone/tests/robot-cases/Group0-BAT/API_DB.robot
docker run -i --privileged -v $DIR/../../:/drone -v $DIR/../:/ca -w /drone $E2E_IMAGE robot -v DOCKER_USER:${DOCKER_USER} -v DOCKER_PWD:${DOCKER_PWD} -v ip:$2 -v ip1: -v HARBOR_PASSWORD:Harbor12345 /drone/tests/robot-cases/Group1-Nightly/Setup.robot /drone/tests/robot-cases/Group0-BAT/API_DB.robot
elif [ "$1" = 'LDAP' ]; then
# run ldap api cases
python $DIR/../../tests/configharbor.py -H $IP -u $HARBOR_ADMIN -p $HARBOR_ADMIN_PASSWD -c auth_mode=ldap_auth \
@ -40,7 +40,7 @@ elif [ "$1" = 'LDAP' ]; then
ldap_search_password=admin \
ldap_base_dn=dc=example,dc=com \
ldap_uid=cn
docker run -i --privileged -v $DIR/../../:/drone -v $DIR/../:/ca -w /drone $E2E_IMAGE robot -v ip:$2 -v ip1: -v HARBOR_PASSWORD:Harbor12345 /drone/tests/robot-cases/Group1-Nightly/Setup.robot /drone/tests/robot-cases/Group0-BAT/API_LDAP.robot
docker run -i --privileged -v $DIR/../../:/drone -v $DIR/../:/ca -w /drone $E2E_IMAGE robot -v DOCKER_USER:${DOCKER_USER} -v DOCKER_PWD:${DOCKER_PWD} -v ip:$2 -v ip1: -v HARBOR_PASSWORD:Harbor12345 /drone/tests/robot-cases/Group1-Nightly/Setup.robot /drone/tests/robot-cases/Group0-BAT/API_LDAP.robot
else
rc=999
fi

View File

@ -12,7 +12,7 @@ Harbor API Test
${current_dir}= Run pwd
Log To Console ${current_dir}
Log To Console ${ip}
${rc} ${output}= Run And Return Rc And Output SWAGGER_CLIENT_PATH=${current_dir}/harborclient HARBOR_HOST=${ip} python ${testcase_name}
${rc} ${output}= Run And Return Rc And Output SWAGGER_CLIENT_PATH=${current_dir}/harborclient HARBOR_HOST=${ip} DOCKER_USER=${DOCKER_USER} DOCKER_PWD=${DOCKER_PWD} python ${testcase_name}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -19,7 +19,8 @@ Library Process
*** Keywords ***
CNAB Push Bundle
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file}
[Arguments] ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group0-Util/cnab_push_bundle.sh ${ip} ${user} ${pwd} ${target} ${bundle_file} ${docker_user} ${docker_pwd}
Log To Console ${output}
Log ${output}
Should Be Equal As Integers ${rc} 0

View File

@ -156,6 +156,15 @@ Prepare Docker Cert
Wait Unitl Command Success cp harbor_ca.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates
Prepare Docker Cert For Nightly
[Arguments] ${ip}
Wait Unitl Command Success mkdir -p /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp harbor_ca.crt /etc/docker/certs.d/${ip}
Wait Unitl Command Success cp harbor_ca.crt /usr/local/share/ca-certificates/
#Add pivotal ecs cert for docker manifest push test.
Wait Unitl Command Success cp /ecs_ca/vmwarecert.crt /usr/local/share/ca-certificates/
Wait Unitl Command Success update-ca-certificates
Kill Local Docker Daemon
[Arguments] ${handle} ${dockerd-pid}
Terminate Process ${handle}
@ -175,7 +184,7 @@ Docker Login
Docker Pull
[Arguments] ${image}
${output}= Retry Keyword N Times When Error 10 Wait Unitl Command Success docker pull ${image}
${output}= Retry Keyword N Times When Error 2 Wait Unitl Command Success docker pull ${image}
Log ${output}
Log To Console Docker Pull: ${output}
[Return] ${output}
@ -197,17 +206,22 @@ Docker Push Index
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
END
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}=10
[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'

View File

@ -35,13 +35,11 @@ Init LDAP
Sleep 1
Input Text xpath=//*[@id='ldapUid'] cn
Sleep 1
Capture Page Screenshot
Disable Ldap Verify Cert Checkbox
Retry Element Click xpath=${config_auth_save_button_xpath}
Sleep 2
Retry Element Click xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/config/div/div/div/button[3]
Sleep 1
Capture Page Screenshot
Switch To Configure
Retry Element Click xpath=${configuration_xpath}
@ -72,7 +70,6 @@ Test Ldap Connection
# ldap checkbox unchecked, click test connection to verify success.
Sleep 1
Retry Element Click xpath=${test_ldap_xpath}
Capture Page Screenshot
Wait Until Page Contains Connection to LDAP server is verified timeout=15
Test LDAP Server Success
@ -83,7 +80,6 @@ Disable Ldap Verify Cert Checkbox
Mouse Down xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Mouse Up xpath=//*[@id='clr-checkbox-ldapVerifyCert']
Sleep 2
Capture Page Screenshot
Ldap Verify Cert Checkbox Should Be Disabled
Ldap Verify Cert Checkbox Should Be Disabled
@ -99,7 +95,6 @@ Set Pro Create Admin Only
Retry Element Click xpath=//select[@id='proCreation']//option[@value='adminonly']
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Capture Page Screenshot AdminCreateOnly.png
Set Pro Create Every One
Retry Element Click xpath=${configuration_xpath}
@ -112,7 +107,6 @@ Set Pro Create Every One
Sleep 1
Retry Element Click xpath=${config_system_save_button_xpath}
Sleep 2
Capture Page Screenshot EveryoneCreate.png
Disable Self Reg
Retry Element Click xpath=${configuration_xpath}
@ -121,7 +115,6 @@ Disable Self Reg
Sleep 1
Self Reg Should Be Disabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Capture Page Screenshot DisableSelfReg.png
Sleep 1
Enable Self Reg
@ -130,7 +123,6 @@ Enable Self Reg
Sleep 1
Self Reg Should Be Enabled
Retry Element Click xpath=${config_auth_save_button_xpath}
Capture Page Screenshot EnableSelfReg.png
Sleep 1
Self Reg Should Be Disabled
@ -183,7 +175,6 @@ Check Verify Remote Cert
Mouse Down xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Mouse Up xpath=//*[@id='clr-checkbox-verifyRemoteCert']
Retry Element Click xpath=${config_save_button_xpath}
Capture Page Screenshot RemoteCert.png
Sleep 1
Switch To System Replication
@ -276,7 +267,6 @@ Create New Labels
Sleep 1
Input Text xpath=//*[@id='description'] global
Retry Element Click xpath=//div/form/section/label[4]/button[2]
Capture Page Screenshot
Wait Until Page Contains ${labelname}
Update A Label
@ -288,7 +278,6 @@ Update A Label
Input Text xpath=//*[@id='name'] ${labelname}1
Sleep 1
Retry Element Click xpath=//hbr-create-edit-label//form/section//button[2]
Capture Page Screenshot
Wait Until Page Contains ${labelname}1
Delete A Label
@ -297,7 +286,6 @@ Delete A Label
Sleep 1
Retry Element Click xpath=//button[contains(.,'Delete')]
Sleep 3
Capture Page Screenshot
Retry Element Click xpath=//clr-modal//div//button[contains(.,'DELETE')]
Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${labelname}')]/../div/clr-icon[@shape='success-standard']
@ -334,7 +322,6 @@ Delete Top Item In System CVE Allowlist
Retry Element Click ${configuration_system_wl_delete_a_cve_id_icon}
END
Retry Element Click ${config_system_save_button_xpath}
Capture Page Screenshot
Get Project Count Quota Text From Project Quotas List
[Arguments] ${project_name}
@ -352,13 +339,11 @@ Get Project Storage Quota Text From Project Quotas List
Check Automatic Onboarding And Save
Retry Element Click ${cfg_auth_automatic_onboarding_checkbox}
Retry Element Click xpath=${config_auth_save_button_xpath}
Capture Page Screenshot
Set User Name Claim And Save
[Arguments] ${type}
Retry Text Input ${cfg_auth_user_name_claim_input} ${type}
Retry Element Click xpath=${config_auth_save_button_xpath}
Capture Page Screenshot
Select Distribution
[Arguments] ${name}

View File

@ -22,9 +22,7 @@ Resource ../../resources/Util.robot
GC Now
[Arguments] ${harbor_url} ${login_user} ${login_pwd} ${untag}=${false}
Switch To Garbage Collection
Capture Page Screenshot
Run Keyword If '${untag}' == '${true}' Retry Element Click xpath=${checkbox_delete_untagged_artifacts}
Capture Page Screenshot
Click GC Now
Logout Harbor
Sleep 2

View File

@ -20,20 +20,17 @@ Upload Chart files
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Double Keywords When Error Retry Element Click xpath=${upload_chart_button} Retry Wait Until Page Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${prometheus_chart_name}
Capture Page Screenshot
${harbor_file_path} Set Variable ${current_dir}/${harbor_chart_filename}
${harbor_prov_file_path} Set Variable ${current_dir}/${harbor_chart_prov_filename}
Choose File xpath=${chart_file_browse} ${harbor_file_path}
Choose File xpath=${chart_prov_browse} ${harbor_prov_file_path}
Retry Double Keywords When Error Retry Element Click xpath=${upload_action_button} Retry Wait Until Page Not Contains Element xpath=${upload_action_button}
Retry Wait Until Page Contains ${harbor_chart_name}
Capture Page Screenshot
Go Into Chart Version
[Arguments] ${chart_name}
Retry Element Click xpath=//hbr-helm-chart//a[contains(., '${chart_name}')]
Sleep 3
Capture Page Screenshot viewchartversion.png
Go Into Chart Detail
[Arguments] ${version_name}
@ -47,10 +44,7 @@ Multi-delete Chart Files
Retry Element Click //clr-dg-row[contains(.,'${obj}')]//label
END
#Retry Element Click xpath=${version_checkbox}
Capture Page Screenshot
Retry Double Keywords When Error Retry Element Click xpath=${version_delete} Retry Wait Until Page Contains Element ${version_confirm_delete}
Capture Page Screenshot
Retry Double Keywords When Error Retry Element Click ${version_confirm_delete} Retry Wait Until Page Not Contains Element xpath=${version_confirm_delete}
Retry Wait Element xpath=//clr-dg-placeholder[contains(.,\"We couldn\'t find any charts!\")]
Capture Page Screenshot

View File

@ -20,7 +20,6 @@ Resource ../../resources/Util.robot
View Repo Scan Details
[Arguments] @{vulnerabilities_level}
Retry Element Click xpath=${first_repo_xpath}
Capture Page Screenshot
FOR ${item} IN @{vulnerabilities_level}
Retry Wait Until Page Contains Element //hbr-artifact-vulnerabilities//clr-dg-row[contains(.,'${item}')]
END
@ -30,6 +29,5 @@ View Repo Scan Details
View Scan Error Log
Retry Wait Until Page Contains View Log
Retry Element Click xpath=${view_log_xpath}
Capture Page Screenshot viewlog.png

View File

@ -16,7 +16,6 @@ Create A New Webhook
Retry Text Input ${webhook_name_xpath} ${webhook_name}
Retry Text Input ${webhook_endpoint_id_xpath} ${webhook_endpoint_url}
Retry Double Keywords When Error Retry Element Click ${create_webhooks_continue_button_xpath} Retry Wait Until Page Not Contains Element ${create_webhooks_continue_button_xpath}
Capture Page Screenshot
Retry Wait Until Page Contains ${webhook_name}
Update A Webhook
@ -35,7 +34,6 @@ Update A Webhook
Retry Text Input ${webhook_endpoint_id_xpath} ${new_webhook_enpoint}
Retry Double Keywords When Error Retry Element Click ${edit_webhooks_save_button_xpath} Retry Wait Until Page Not Contains Element ${edit_webhooks_save_button_xpath}
Retry Wait Until Page Contains ${new_webhook_name}
Capture Page Screenshot
Enable/Disable State of Same Webhook
[Arguments] ${webhook_name}

View File

@ -24,16 +24,13 @@ Create An New Project And Go Into Project
Navigate To Projects
Retry Button Click xpath=${create_project_button_xpath}
Log To Console Project Name: ${projectname}
Capture Page Screenshot
Retry Text Input xpath=${project_name_xpath} ${projectname}
${element_project_public}= Set Variable xpath=${project_public_xpath}
Run Keyword If '${public}' == 'true' Run Keywords Wait Until Element Is Visible And Enabled ${element_project_public} AND Retry Element Click ${element_project_public}
Run Keyword If '${count_quota}'!='${null}' Input Count Quota ${count_quota}
Run Keyword If '${storage_quota}'!='${null}' Input Storage Quota ${storage_quota} ${storage_quota_unit}
Run Keyword If '${proxy_cache}' == '${true}' Run Keywords Mouse Down ${project_proxy_cache_switcher_id} AND Mouse Up ${project_proxy_cache_switcher_id} AND Retry Element Click ${project_registry_select_id} AND Retry Element Click xpath=//select[@id='registry']//option[contains(.,'${registry}')]
Capture Page Screenshot
Retry Double Keywords When Error Retry Element Click ${create_project_OK_button_xpath} Retry Wait Until Page Not Contains Element ${create_project_OK_button_xpath}
Capture Page Screenshot
Sleep 2
Go Into Project ${projectname} has_image=${false}
@ -102,7 +99,6 @@ Search Private Projects
Retry Element Click xpath=//select
Retry Element Click xpath=//select/option[@value=1]
Sleep 1
Capture Page Screenshot SearchPrivateProjects.png
Make Project Private
[Arguments] ${projectname}
@ -164,7 +160,6 @@ Advanced Search Should Display
# it's not a common keywords, only used into log case.
Do Log Advanced Search
Capture Page Screenshot LogAdvancedSearch.png
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'pull')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'create')]
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'artifact') and contains(.,'delete')]
@ -193,7 +188,6 @@ Do Log Advanced Search
Retry Element Click xpath=//audit-log//hbr-filter//clr-icon
Retry Text Input xpath=//audit-log//hbr-filter//input harbor
Sleep 1
Capture Page Screenshot LogAdvancedSearch2.png
${rc} = Get Element Count //audit-log//clr-dg-row
Should Be Equal As Integers ${rc} 0
@ -239,7 +233,6 @@ Go Into Index And Contain Artifacts
FOR ${n} IN RANGE 1 10
${out} Run Keyword And Ignore Error Page Should Contain Element ${artifact_rows} limit=${limit}
Exit For Loop If '${out[0]}'=='PASS'
Capture Page Screenshot gointo_${tag_name}.png
Sleep 3
END
Run Keyword If '${out[0]}'=='FAIL' Capture Page Screenshot
@ -268,7 +261,6 @@ Edit Repo Info
Input Text xpath=//*[@id='info-edit-textarea'] test_description_info
Retry Element Click xpath=//*[@id='edit-save']
Retry Wait Until Page Contains test_description_info
Capture Page Screenshot
Switch To Project Label
Retry Element Click xpath=//project-detail//a[contains(.,'Labels')]
@ -281,7 +273,6 @@ Switch To Project Repo
Add Labels To Tag
[Arguments] ${tagName} ${labelName}
Retry Element Click xpath=//clr-dg-row[contains(.,'${tagName}')]//label
Capture Page Screenshot add_${labelName}.png
Retry Element Click xpath=//clr-dg-action-bar//clr-dropdown//span
Retry Element Click xpath=//clr-dropdown-menu//clr-dropdown//button[contains(.,'Add Labels')]
Retry Element Click xpath=//clr-dropdown//div//label[contains(.,'${labelName}')]
@ -301,7 +292,6 @@ Filter Labels In Tags
Retry Element Click xpath=//*[@id='filterArea']//div//button[contains(.,'${labelName2}')]
Retry Element Click xpath=//*[@id='filterArea']//hbr-filter/span/clr-icon
Sleep 2
Capture Page Screenshot filter_${labelName2}.png
Retry Wait Until Page Contains Element xpath=//clr-dg-row[contains(.,'${labelName2}')]
Retry Wait Until Page Not Contains Element xpath=//clr-dg-row[contains(.,'${labelName1}')]

View File

@ -25,7 +25,6 @@ Filter Replication Rule
Retry Element Click ${filter_rules_btn}
Retry Text Input ${filter_rules_input} ${ruleName}
Retry Wait Until Page Contains Element ${rule_name_element}
Capture Page Screenshot filter_replic_${ruleName}.png
Filter Registry
[Arguments] ${registry_name}
@ -35,7 +34,6 @@ Filter Registry
Retry Element Click ${filter_registry_btn}
Retry Text Input ${filter_registry_input} ${registry_name}
Retry Wait Until Page Contains Element ${registry_name_element}
Capture Page Screenshot filter_repistry_${registry_name}.png
Select Dest Registry
[Arguments] ${endpoint}
@ -73,8 +71,8 @@ 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}
@ -274,7 +272,5 @@ 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}')]
Capture Page Screenshot
Should Be Equal As Integers ${count} ${expected_result_count}
Capture Page Screenshot

View File

@ -25,7 +25,6 @@ Delete Success
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='success-standard']
END
Sleep 1
Capture Page Screenshot
Delete Fail
[Arguments] @{obj}
@ -33,7 +32,6 @@ Delete Fail
Retry Wait Until Page Contains Element //*[@id='contentAll']//div[contains(.,'${obj}')]/../div/clr-icon[@shape='error-standard']
END
Sleep 1
Capture Page Screenshot
Filter Object
#Filter project repo user tag.
@ -64,13 +62,10 @@ Multi-delete Object
Retry Element Click ${element}
END
Sleep 1
Capture Page Screenshot
Retry Element Click ${delete_btn}
Sleep 1
Capture Page Screenshot
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Capture Page Screenshot
Sleep 1
# This func cannot support as the delete user flow changed.
@ -81,15 +76,12 @@ Multi-delete Artifact
Retry Element Click ${element}
END
Sleep 1
Capture Page Screenshot
Retry Element Click ${artifact_action_xpath}
Sleep 1
Retry Element Click ${artifact_action_delete_xpath}
Sleep 1
Capture Page Screenshot
Retry Element Click ${repo_delete_on_card_view_btn}
Sleep 1
Capture Page Screenshot
Sleep 1
Multi-delete User

View File

@ -41,6 +41,5 @@ Update User Comment
Logout Harbor
Retry Element Click ${head_admin_xpath}
Retry Link Click Log Out
Capture Page Screenshot Logout.png
Sleep 2
Wait Until Keyword Succeeds 5x 1 Retry Wait Until Page Contains Element ${sign_in_title_xpath}

View File

@ -350,12 +350,13 @@ Verify Replicationrule
${endpoint0}= Set Variable @{endpoint}[0]
Log To Console -----endpoint0-----${endpoint0}------------
@{endpoint_type}= Get Value From Json ${json} $.endpoint[?(@.name=${endpoint0})].type
@{endpoint_url}= Get Value From Json ${json} $.endpoint[?(@.name=${endpoint0})].url
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]------------
${registry}= Set Variable If "@{endpoint_type}[0]"=="harbor" ${endpoint0}-https://${IP} ${endpoint0}-https://hub.docker.com
${registry}= Set Variable If "@{endpoint_type}[0]"=="harbor" ${endpoint0}-@{endpoint_url}[0] ${endpoint0}-https://hub.docker.com
Log To Console -------registry---${registry}------------
Run Keyword If '@{is_src_registry}[0]' == '${true}' Retry List Selection Should Be ${src_registry_dropdown_list} ${registry}
... ELSE Retry List Selection Should Be ${dest_registry_dropdown_list} ${registry}

View File

@ -51,12 +51,15 @@ Nightly Test Setup For Nightly
Run Keyword Start Docker Daemon Locally
Log To Console Start Containerd Daemon Locally ...
Run Keyword Start Containerd Daemon Locally
#Prepare docker image for push special image keyword in replication test
Docker Pull ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/busybox:latest
Docker Tag ${LOCAL_REGISTRY}/${LOCAL_REGISTRY_NAMESPACE}/busybox:latest busybox:latest
CA Setup For Nightly
[Arguments] ${ip} ${HARBOR_PASSWORD} ${cert}=/ca/ca.crt
Run cp ${cert} harbor_ca.crt
Generate Certificate Authority For Chrome ${HARBOR_PASSWORD}
Prepare Docker Cert ${ip}
Prepare Docker Cert For Nightly ${ip}
Prepare Helm Cert
Collect Nightly Logs

View File

@ -212,7 +212,6 @@ Helm CLI Push Without Sign In Harbor
Switch To Project Charts
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
[Arguments] ${sign_in_user} ${sign_in_pwd}
@ -221,7 +220,6 @@ Helm3 CLI Push Without Sign In Harbor
Helm Repo Push ${sign_in_user} ${sign_in_pwd} ${harbor_chart_filename} helm_repo_name=${HARBOR_URL}/chartrepo/project${d} helm_cmd=helm3
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
#Important Note: All CVE IDs in CVE Allowlist cases must unique!
Body Of Verfiy System Level CVE Allowlist

View File

@ -213,7 +213,7 @@ Clear Field Of Characters
END
Wait Unitl Command Success
[Arguments] ${cmd} ${times}=8
[Arguments] ${cmd} ${times}=2
FOR ${n} IN RANGE 1 ${times}
Log Trying ${cmd}: ${n} ... console=True
${rc} ${output}= Run And Return Rc And Output ${cmd}
@ -237,7 +237,6 @@ Retry Keyword N Times When Error
Log To Console Trying ${keyword} elements @{elements} ${n} times ...
${out} Run Keyword And Ignore Error ${keyword} @{elements}
Log To Console Return value is ${out} and ${out[0]}
Capture Page Screenshot
Run Keyword If '${keyword}'=='Make Swagger Client' Exit For Loop If '${out[0]}'=='PASS' and '${out[1]}'=='0'
... ELSE Exit For Loop If '${out[0]}'=='PASS'
Sleep 10
@ -264,14 +263,13 @@ Retry Double Keywords When Error
FOR ${n} IN RANGE 1 ${times}
Log To Console Trying ${keyword1} and ${keyword2} ${n} times ...
${out1} Run Keyword And Ignore Error ${keyword1} ${element1}
Capture Page Screenshot
Sleep 1
${out2} Run Keyword And Ignore Error ${keyword2} ${element2}
Capture Page Screenshot
Log To Console Return value is ${out1[0]} ${out2[0]}
Exit For Loop If '${out2[0]}'=='PASS'
Sleep 1
END
Capture Page Screenshot
Return From Keyword If ${DoAssert} == ${false} '${out2[0]}'
Should Be Equal As Strings '${out2[0]}' 'PASS'

View File

@ -1,12 +1,25 @@
#!/bin/bash
set -x
IP=$1
USER=$2
PWD=$3
TARGET=$4
BUNDLE_FILE=$5
DOCKER_USER=$6
DOCKER_PWD=$7
echo $DOCKER_USER
echo $IP
TOKEN=$(curl --user "$DOCKER_USER:$DOCKER_PWD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl -v -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit
docker login -u $DOCKER_USER -p $DOCKER_PWD
docker login $IP -u $USER -p $PWD
cnab-to-oci fixup $BUNDLE_FILE --target $TARGET --bundle fixup_bundle.json --auto-update-bundle
TOKEN=$(curl --user "$DOCKER_USER:$DOCKER_PWD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl -v -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest 2>&1 | grep RateLimit
cnab-to-oci push fixup_bundle.json --target $TARGET --auto-update-bundle

View File

@ -1,4 +1,6 @@
#!/bin/bash
set -x
set -e
IP=$1
USER=$2
@ -12,9 +14,11 @@ docker login $IP -u $USER -p $PWD
cat /$HOME/.docker/config.json
sed -i '$d' /$HOME/.docker/config.json
sed -i '$d' /$HOME/.docker/config.json
echo -e "\n },\n \"experimental\": \"enabled\"\n}" >> /$HOME/.docker/config.json
if [ $(cat /$HOME/.docker/config.json |grep experimental |wc -l) -eq 0 ];then
sudo sed -i '$d' /$HOME/.docker/config.json
sudo sed -i '$d' /$HOME/.docker/config.json
sudo echo -e "},\n \"experimental\": \"enabled\"\n}" >> /$HOME/.docker/config.json
fi
cat /$HOME/.docker/config.json

View File

@ -29,6 +29,28 @@ Test Case - Sign With Admin
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Close Browser
Test Case - Push CNAB Bundle and Display
[Tags] run-once
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user010 Test1@34
Create An New Project And Go Into Project test${d}
${target}= Set Variable ${ip}/test${d}/cnab${d}:cnab_tag${d}
Retry Keyword N Times When Error 5 CNAB Push Bundle ${ip} user010 Test1@34 ${target} ./tests/robot-cases/Group0-Util/bundle.json ${DOCKER_USER} ${DOCKER_PWD}
Go Into Project test${d}
Wait Until Page Contains test${d}/cnab${d}
Go Into Repo test${d}/cnab${d}
Wait Until Page Contains cnab_tag${d}
Go Into Project test${d}
Wait Until Page Contains test${d}/cnab${d}
Go Into Repo test${d}/cnab${d}
Go Into Index And Contain Artifacts cnab_tag${d} limit=3
Close Browser
Test Case - Create An New Project
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
@ -494,10 +516,8 @@ Test Case - Project Quotas Control Under Copy
Sleep 2
Go Into Project project_b_${d}
Sleep 2
Capture Page Screenshot
Retry Wait Until Page Contains Element xpath=//clr-dg-cell[contains(.,'${image_a}')]/a
Retry Wait Until Page Not Contains Element xpath=//clr-dg-cell[contains(.,'${image_b}')]/a
Capture Page Screenshot
Close Browser
Test Case - Webhook CRUD
@ -611,27 +631,6 @@ Test Case - Push Docker Manifest Index and Display
Go Into Index And Contain Artifacts index_tag${d} limit=2
Close Browser
Test Case - Push CNAB Bundle and Display
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
Sign In Harbor ${HARBOR_URL} user010 Test1@34
Create An New Project And Go Into Project test${d}
${target}= Set Variable ${ip}/test${d}/cnab${d}:cnab_tag${d}
Retry Keyword N Times When Error 5 CNAB Push Bundle ${ip} user010 Test1@34 ${target} ./tests/robot-cases/Group0-Util/bundle.json
Go Into Project test${d}
Wait Until Page Contains test${d}/cnab${d}
Go Into Repo test${d}/cnab${d}
Wait Until Page Contains cnab_tag${d}
Go Into Project test${d}
Wait Until Page Contains test${d}/cnab${d}
Go Into Repo test${d}/cnab${d}
Go Into Index And Contain Artifacts cnab_tag${d} limit=3
Close Browser
Test Case - Push Helm Chart and Display
Init Chrome Driver
${d}= Get Current Date result_format=%m%s
@ -694,10 +693,10 @@ Test Case - Read Only Mode
Close Browser
Test Case - Proxy Cache
[Tags] proxy_cache
[Tags] run-once
${d}= Get Current Date result_format=%m%s
${registry}= Set Variable https://hub.docker.com/
${user_namespace}= Set Variable danfengliu
${user_namespace}= Set Variable ${DOCKER_USER}
${image}= Set Variable for_proxy
${tag}= Set Variable 1.0
${manifest_index}= Set Variable index081597864867
@ -705,7 +704,7 @@ Test Case - Proxy Cache
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Create A New Endpoint docker-hub e1${d} ${registry} ${user_namespace} Aa123456
Create A New Endpoint docker-hub e1${d} ${registry} ${user_namespace} ${DOCKER_PWD}
Create An New Project And Go Into Project project${d} proxy_cache=${true} registry=e1${d}
Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} busybox:latest err_msg=can not push artifact to a proxy project
Pull Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${user_namespace}/${image} tag=${tag}

View File

@ -80,11 +80,8 @@ Test Case - Project Quotas Control Under GC
${image_a_size}= Set Variable 321.03MB
${image_a_ver}= Set Variable 6.8.3
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Capture Page Screenshot
Create An New Project And Go Into Project project${d} storage_quota=${storage_quota} storage_quota_unit=${storage_quota_unit}
Capture Page Screenshot
Cannot Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} ${image_a}:${image_a_ver} err_msg=will exceed the configured upper limit of 200.0 MiB
Capture Page Screenshot
GC Now ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Retry GC Should Be Successful 4 ${null}
@{param} Create List project${d}

View File

@ -119,7 +119,7 @@ Test Case - Ldap Group Admin DN Setting
Logout Harbor
Sign In Harbor ${HARBOR_URL} mike zhu88jie
Switch To Registries
Create A New Endpoint docker-hub edp1${d} https://hub.docker.com/ danfengliu Aa123456 Y
Create A New Endpoint harbor edp1${d} https://cicd.harbor.vmwarecna.net ${null} ${null} Y
Test Case - Run LDAP Group Related API Test

View File

@ -133,7 +133,6 @@ Test Case - User View Projects
Create An New Project test${d}2
Create An New Project test${d}3
Switch To Log
Capture Page Screenshot UserViewProjects.png
Wait Until Page Contains test${d}1
Wait Until Page Contains test${d}2
Wait Until Page Contains test${d}3
@ -368,9 +367,7 @@ TestCase - Project Admin Add Labels To Repo
# Add labels
Switch To Project Label
Create New Labels label111
Capture Page Screenshot CreateLabel1.png
Create New Labels label22
Capture Page Screenshot CreateLabel2.png
Sleep 2
Switch To Project Repo
Go Into Repo project${d}/redis

View File

@ -14,6 +14,7 @@
*** Settings ***
Documentation Harbor BATs
Library ../../apitests/python/testutils.py
Library ../../apitests/python/library/repository.py
Resource ../../resources/Util.robot
Default Tags Replication
@ -39,7 +40,6 @@ Test Case - Pro Replication Rules Add
Init Chrome Driver
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Switch To Registries
Capture Page Screenshot
Switch To Replication Manage
Check New Rule UI Without Endpoint
Close Browser
@ -56,14 +56,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}
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
@ -105,10 +105,11 @@ 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://cicd.harbor.vmwarecna.net ${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}
Create A Rule With Existing Endpoint ${rule_name_old} pull nightly/a* image ${endpoint1} project${d}
Edit Replication Rule By Name ${rule_name_old}
# Change rule-name, source-registry, filter, trigger-mode for edition verification
Clear Field Of Characters ${rule_name_input} 30
@ -141,9 +142,9 @@ Test Case - Replication Rule Delete
${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}
Create A Rule With Existing Endpoint ${rule_name} pull ${DOCKER_USER}/* image ${endpoint1} project${d}
Ensure Delete Replication Rule By Name ${rule_name}
Close Browser
@ -154,11 +155,11 @@ Test Case - Replication Of Pull Images from DockerHub To Self
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into 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/{cent*,mariadb} 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
@ -275,7 +276,7 @@ Test Case - Replication Of Pull Images from Google-GCR To Self
Close Browser
Test Case - Replication Of Push Images to DockerHub Triggered By Event
Body Of Replication Of Push Images to Registry Triggered By Event docker-hub https://hub.docker.com/ danfengliu Aa123456 danfengliu
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

View File

@ -39,14 +39,15 @@ Test Case - Scan Schedule Job
Retry Wait Until Page Contains Element ${not_scanned_icon}
Switch To Vulnerability Page
${flag}= Set Variable ${false}
:FOR ${i} IN RANGE 999999
\ ${minite}= Get Current Date result_format=%M
\ ${minite_int} = Convert To Integer ${minite}
\ ${left} = Evaluate ${minite_int}%10
\ Log To Console ${i}/${left}
\ Sleep 55
\ Run Keyword If ${left} <= 3 and ${left} != 0 Run Keywords Set Scan Schedule custom value=* */10 * * * * AND Set Suite Variable ${flag} ${true}
\ Exit For Loop If '${flag}' == '${true}'
FOR ${i} IN RANGE 999999
${minite}= Get Current Date result_format=%M
${minite_int} = Convert To Integer ${minite}
${left} = Evaluate ${minite_int}%10
Log To Console ${i}/${left}
Sleep 55
Run Keyword If ${left} <= 3 and ${left} != 0 Run Keywords Set Scan Schedule custom value=* */10 * * * * AND Set Suite Variable ${flag} ${true}
Exit For Loop If '${flag}' == '${true}'
END
# After scan custom schedule is set, image should stay in unscanned status.
Log To Console Sleep for 300 seconds......
Sleep 300
@ -73,17 +74,18 @@ Test Case - Replication Schedule Job
Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD}
Create An New Project And Go Into Project ${project_name}
Switch To Registries
Create A New Endpoint docker-hub e${d} https://hub.docker.com/ danfengliu Aa123456 Y
Create A New Endpoint harbor e${d} https://cicd.harbor.vmwarecna.net ${null} ${null} Y
Switch To Replication Manage
${flag}= Set Variable ${false}
:FOR ${i} IN RANGE 999999
\ ${minite}= Get Current Date result_format=%M
\ ${minite_int} = Convert To Integer ${minite}
\ ${left} = Evaluate ${minite_int}%10
\ Log To Console ${i}/${left}
\ Run Keyword If ${left} <= 3 and ${left} != 0 Run Keywords Create A Rule With Existing Endpoint rule${d} pull danfengliu/* image e${d} ${project_name} mode=Scheduled cron=* */10 * * * * AND Set Suite Variable ${flag} ${true}
\ Sleep 40
\ Exit For Loop If '${flag}' == '${true}'
FOR ${i} IN RANGE 999999
${minite}= Get Current Date result_format=%M
${minite_int} = Convert To Integer ${minite}
${left} = Evaluate ${minite_int}%10
Log To Console ${i}/${left}
Run Keyword If ${left} <= 3 and ${left} != 0 Run Keywords Create A Rule With Existing Endpoint rule${d} pull nightly/{mariadb,centos} image e${d} ${project_name} mode=Scheduled cron=* */10 * * * * AND Set Suite Variable ${flag} ${true}
Sleep 40
Exit For Loop If '${flag}' == '${true}'
END
# After replication schedule is set, project should contain 2 images.
Log To Console Sleep for 720 seconds......

View File

@ -28,38 +28,15 @@
],
"endpoint":[
{
"url":"http://url",
"name":"endpoint1",
"user":"admin",
"pass":"Harbor12345",
"insecure":true,
"type":"harbor"
},
{
"url":"https://hub.docker.com",
"url":"https://harbor-repo.vmware.com",
"name":"endpoint_for_proxy_cache",
"user":"",
"pass":"",
"insecure":false,
"type":"docker-hub"
"type":"harbor"
}
],
"replicationrule":[
{
"project":"project1",
"endpoint":"endpoint1",
"trigger":"Manual",
"rulename":"rulename",
"is_src_registry":false,
"dest_namespace":"rule1-namespace",
"trigger_type":"event_based",
"cron":"",
"deletion":true,
"enabled":true,
"override":true,
"name_filters":"namefilter1",
"tag_filters":"tagfilter1"
},
{
"project":"library",
"endpoint":"endpoint_for_proxy_cache",
@ -203,7 +180,7 @@
"storage_unit_for_verify":"GB",
"replications":{
"rulename":"ruleproject1",
"endpointname":"endpoint1",
"endpointname":"endpoint_for_proxy_cache",
"trigger":"Manual"
},
"labels":[
@ -325,7 +302,7 @@
"storage_unit_for_verify":"TB",
"replications":{
"rulename":"rulename1",
"endpointname":"endpoint1",
"endpointname":"endpoint_for_proxy_cache",
"trigger":"Manual"
},
"labels":[

View File

@ -192,8 +192,6 @@ class HarborAPI:
body=dict(body=payload)
request(url+"targets", 'post', **body)
elif kwargs["branch"] == 2:
if registry_type == "harbor":
endpointurl = endpoint_url
payload = {
"credential":{
"access_key":""+username+"",
@ -223,6 +221,7 @@ class HarborAPI:
request(url+"policies/replication", 'post', **body)
elif kwargs["branch"] == 2:
r = request(url+"registries?name="+replicationrule["endpoint"]+"", 'get')
print("response:", r)
targetid = r.json()[0]['id']
if replicationrule["is_src_registry"] is True:
registry = r'"src_registry": { "id": '+str(targetid)+r'},'
@ -638,6 +637,7 @@ def do_data_creation():
# Make sure to create endpoint first, it's for proxy cache project creation.
for endpoint in data["endpoint"]:
print("endpoint:", endpoint)
harborAPI.add_endpoint(endpoint["url"], endpoint["name"], endpoint["user"], endpoint["pass"], endpoint["insecure"], endpoint["type"], version=args.version)
for distribution in data["distributions"]:

View File

@ -1,7 +1,9 @@
#!/bin/bash
IP=$1
HARBOR_VERSION=$2
DOCKER_USER=$3
DOCKER_PWD=$4
robot -v ip:$IP -v ip1: -v HARBOR_PASSWORD:Harbor12345 /drone/tests/robot-cases/Group1-Nightly/Setup.robot
cd /drone/tests/robot-cases/Group3-Upgrade
python ./prepare.py -e $IP -v $HARBOR_VERSION -l /drone/tests/apitests/python/
DOCKER_USER=$DOCKER_USER DOCKER_PWD=$DOCKER_PWD python ./prepare.py -e $IP -v $HARBOR_VERSION -l /drone/tests/apitests/python/