diff --git a/tests/nightly-test/deployment/deployer.py b/tests/nightly-test/deployment/deployer.py new file mode 100644 index 000000000..f91d1a7f1 --- /dev/null +++ b/tests/nightly-test/deployment/deployer.py @@ -0,0 +1,158 @@ +import abc +import logging +import os +import sys +import time +import subprocess +from datetime import datetime +dir_path = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(dir_path + '../utils') +import govc_utils +import nlogging +logger = nlogging.create_logger(__name__) + +class Deployer(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def deploy(self): + return + + @abc.abstractmethod + def destory(self): + return + +class OVADeployer(Deployer): + + def __init__(self, vc_host, vc_user, vc_password, ds, cluster, ova_path, ova_name, ova_root_password, count, + dry_run, auth_mode, ldap_url, ldap_searchdn, ldap_search_pwd, ldap_filter, ldap_basedn, ldap_uid, + ldap_scope, ldap_timeout): + self.vc_host = vc_host + self.vc_user = vc_user + self.vc_password = vc_password + self.ds = ds + self.cluster = cluster + self.ova_path = ova_path + self.ova_name = ova_name + self.ova_root_password = ova_root_password + self.dry_run = dry_run + self.count = count + self.auth_mode=auth_mode + + if auth_mode == 'ldap_auth': + self.ldap_url = ldap_url + self.ldap_searchdn = ldap_searchdn + self.ldap_search_pwd = ldap_search_pwd + self.ldap_filter = ldap_filter + self.ldap_basedn = ldap_basedn + self.ldap_uid = ldap_uid + self.ldap_scope = ldap_scope + self.ldap_timeout = ldap_timeout + + self.harbor_password='Harbor12345' + self.log_path=None + self.ip=None + self.netmask=None + self.gateway=None + self.dns=None + self.ovf_tool_path=None + self.DEFAULT_LOCAL_OVF_TOOL_PATH = '/home/harbor-ci/ovftool/ovftool' + self.ova_endpoints = [] + self.ova_names = [] + + def __generate_ova_names(self): + for i in range(0, self.count): + ova_name_temp = '' + ova_name_temp = self.ova_name +"-"+ datetime.now().isoformat().replace(":", "-").replace(".", "-") + time.sleep(1) + self.ova_names.append(ova_name_temp) + + def __set_ovf_tool(self): + if not self.ova_endpoints: + self.ovf_tool_path = self.DEFAULT_LOCAL_OVF_TOOL_PATH + if not os.path.isfile(self.ovf_tool_path): + logger.error("ovftool not found.") + return + + def __compose_cmd(self, ova_name): + cmd = '' + + if self.auth_mode == "db_auth": + cmd = ( + '"%s" --X:"logFile"="./deploy_oms.log" --overwrite --powerOn --datastore=\'%s\' --noSSLVerify --acceptAllEulas --name=%s \ + --X:injectOvfEnv --X:enableHiddenProperties --prop:root_pwd=\'%s\' --prop:permit_root_login=true --prop:auth_mode=\'%s\' \ + --prop:harbor_admin_password=\'%s\' --prop:max_job_workers=5 %s \ + vi://%s:\'%s\'@%s/Datacenter/host/%s' + % (self.ovf_tool_path, self.ds, ova_name, + self.ova_root_password, self.auth_mode, + self.harbor_password, self.ova_path, + self.vc_user, self.vc_password, self.vc_host, self.cluster + ) + ) + + if self.auth_mode == "ldap_auth": + cmd = ( + '"%s" --X:"logFile"="./deploy_oms.log" --overwrite --powerOn --datastore=\'%s\' --noSSLVerify --acceptAllEulas --name=%s \ + --X:injectOvfEnv --X:enableHiddenProperties --prop:root_pwd=\'%s\' --prop:permit_root_login=true --prop:auth_mode=\'%s\' \ + --prop:harbor_admin_password=\'%s\' --prop:max_job_workers=5 \ + --prop:ldap_url=\'%s\' --prop:ldap_searchdn=\'%s\' --prop:ldap_search_pwd=\'%s\' \ + --prop:ldap_filter=\'%s\' \ + --prop:ldap_basedn=\'%s\' \ + --prop:ldap_uid=\'%s\' --prop:ldap_scope=\'%s\' --prop:ldap_timeout=\'%s\' %s \ + vi://%s:\'%s\'@%s/Datacenter/host/%s' + % (self.ovf_tool_path, self.ds, ova_name, + self.ova_root_password, self.auth_mode, + self.harbor_password, + self.ldap_url, self.ldap_searchdn, + self.ldap_search_pwd, self.ldap_filter, + self.ldap_basedn, self.ldap_uid, + self.ldap_scope, self.ldap_timeout, + self.ova_path, + self.vc_user, self.vc_password, self.vc_host, self.cluster + ) + ) + return cmd + + def deploy(self): + self.__generate_ova_names() + self.__set_ovf_tool() + + for i in range(0, self.count): + cmd = self.__compose_cmd(self.ova_names[i]) + logger.info(cmd) + if self.dry_run == "true" : + logger.info("Dry run ...") + else: + try: + subprocess.check_output(cmd, shell=True) + except Exception, e: + logger.info(e) + time.sleep(5) + # try onre more time if any failure. + subprocess.check_output(cmd, shell=True) + logger.info("Successfully deployed harbor OVA.") + + ova_endpoint = '' + ova_endpoint = govc_utils.getvmip(self.vc_host, self.vc_user, self.vc_password, self.ova_names[i]) + if ova_endpoint is not '': + self.ova_endpoints.append(ova_endpoint) + + return self.ova_endpoints, self.ova_names + + def destory(self): + for item in self.ova_names: + govc_utils.destoryvm(self.vc_host, self.vc_user, self.vc_password, item) + + +class OfflineDeployer(Deployer): + + def __init__(self): + self.vm_host = '' + self.vm_user = '' + self.vm_password = '' + + def deploy(self): + pass + + def destory(self): + pass \ No newline at end of file diff --git a/tests/nightly-test/launch.py b/tests/nightly-test/launch.py new file mode 100644 index 000000000..75f216be2 --- /dev/null +++ b/tests/nightly-test/launch.py @@ -0,0 +1,109 @@ +#!/usr/bin/python2 + +import sys +import os +import ConfigParser +from subprocess import call +from datetime import datetime +import time +dir_path = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(dir_path + '/utils') +sys.path.append(dir_path + '/deployment') +import harbor_util +import buildweb_utils +import govc_utils +import nlogging +logger = nlogging.create_logger(__name__) +import test_executor +from deployer import * + +if len(sys.argv)!=9 : + logger.info("python launch.py ") + logger.info("Wrong parameters, quit test") + quit() + +build_type = sys.argv[1] +image_url = sys.argv[2] +test_suite = sys.argv[3] +config_file = sys.argv[4] +deploy_count = int(sys.argv[5]) +dry_run = sys.argv[6] +auth_mode = sys.argv[7] +destory = sys.argv[8] +config_file = os.getcwd() + "/harbor_nightly_test/testenv.ini" +config = ConfigParser.ConfigParser() +config.read(config_file) +harbor_endpoints = [] +vm_names = [] + +# ----- deploy harbor build ----- +if build_type == "ova" : + vc_host = config.get("vcenter", "vc_host") + vc_user = config.get("vcenter", "vc_user") + vc_password = config.get("vcenter", "vc_password") + datastore = config.get("vcenter", "datastore") + cluster = config.get("vcenter", "cluster") + ova_password = config.get("vcenter", "ova_password") + ova_name = config.get("vcenter", "ova_name") + + ldap_url = config.get("ldap", "ldap_url") + ldap_searchdn = config.get("ldap", "ldap_searchdn") + ldap_search_pwd = config.get("ldap", "ldap_search_pwd") + ldap_filter = config.get("ldap", "ldap_filter") + ldap_basedn = config.get("ldap", "ldap_basedn") + ldap_uid = config.get("ldap", "ldap_uid") + ldap_scope = config.get("ldap", "ldap_scope") + ldap_timeout = config.get("ldap", "ldap_timeout") + + if image_url == "latest" : + image_url = buildweb_utils.get_latest_build_url('master','beta') + logger.info("Get latest image url:" + image_url) + + ova_deployer = OVADeployer(vc_host, + vc_user, + vc_password, + datastore, + cluster, + image_url, + ova_name, + ova_password, + deploy_count, + dry_run, + auth_mode, + ldap_url, + ldap_searchdn, + ldap_search_pwd, + ldap_filter, + ldap_basedn, + ldap_uid, + ldap_scope, + ldap_timeout) + + logger.info("Going to deploy harbor ova..") + harbor_endpoints, vm_names = ova_deployer.deploy() + + # ----- wait for harbor ready ----- + for item in harbor_endpoints: + is_harbor_ready = harbor_util.wait_for_harbor_ready("https://"+item) + if not is_harbor_ready: + logger.info("Harbor is not ready after 10 minutes.") + sys.exit(-1) + logger.info("%s is ready for test now..." % item) + + # ----- execute test cases ----- + try: + execute_results = test_executor.execute(harbor_endpoints, vm_names, ova_password, test_suite, auth_mode, vc_host, vc_user, vc_password) + if not execute_results: + logger.info("execute test failure.") + sys.exit(-1) + except Exception, e: + logger.info(e) + sys.exit(-1) + finally: + if destory == "true": + ova_deployer.destory() + +elif build_type == "installer" : + logger.info("Going to download installer image to install") +elif build_type == "all" : + logger.info("launch ova and installer") diff --git a/tests/nightly-test/shellscript/destoryvm.sh b/tests/nightly-test/shellscript/destoryvm.sh new file mode 100755 index 000000000..75ed7c7f2 --- /dev/null +++ b/tests/nightly-test/shellscript/destoryvm.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +export GOVC_USERNAME=$2 +export GOVC_PASSWORD=$3 +export GOVC_INSECURE=1 +export GOVC_URL=$1 +govc vm.destroy $4 diff --git a/tests/nightly-test/shellscript/getvmip.sh b/tests/nightly-test/shellscript/getvmip.sh new file mode 100755 index 000000000..0340a82dd --- /dev/null +++ b/tests/nightly-test/shellscript/getvmip.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +export GOVC_USERNAME=$2 +export GOVC_PASSWORD=$3 +export GOVC_INSECURE=1 +export GOVC_URL=$1 +govc vm.info -json $4 | jq -r .VirtualMachines[].Guest.HostName \ No newline at end of file diff --git a/tests/nightly-test/utils/buildweb_utils.py b/tests/nightly-test/utils/buildweb_utils.py new file mode 100644 index 000000000..f76fbf9a1 --- /dev/null +++ b/tests/nightly-test/utils/buildweb_utils.py @@ -0,0 +1,64 @@ +import os +import logging + +from buildwebapi import api as buildapi +LOG = logging.getLogger(__name__) + + +def get_build_type(build_id): + build = get_build(build_id) + LOG.debug('%s is %s build', build_id, build.buildtype) + return build.buildtype + + +def get_build_id_and_system(build_id): + build_system = 'ob' + if '-' in str(build_id): + temp = build_id.split('-') + build_id = temp[1] + build_system = temp[0] + return build_id, build_system + + +def get_ova_url(build_id): + return get_url(build_id, '_OVF10.ova') + + +def get_url(build_id, deliverable_name): + build = get_build(build_id) + deliverables = buildapi.ListResource.by_url(build._deliverables_url) + deliverable = [d for d in deliverables + if d.matches(path=deliverable_name)][0] + LOG.debug('Download URL of %s is %s', build_id, deliverable._download_url) + return deliverable._download_url + + +def get_product(build_id): + build = get_build(build_id) + LOG.debug('Product of %s is %s.', build_id, build.product) + return build.product + + +def get_latest_build_url(branch, build_type, product='harbor_build'): + build_id = get_latest_build_id(branch, build_type, product) + print build_id + return get_ova_url(build_id) + + +def get_latest_build_id(branch, build_type, product='harbor_build'): + return buildapi.MetricResource.by_name('build', + product=product, + buildstate='succeeded', + buildtype=build_type, + branch=branch).get_max_id() + + +def get_build(build_id): + build_id, build_system = get_build_id_and_system(build_id) + return buildapi.ItemResource.by_id('build', int(build_id), build_system) + + +def get_build_version(build_id): + build = get_build(build_id) + LOG.debug('Version of %s is %s.', build_id, build.version) + return build.version \ No newline at end of file diff --git a/tests/nightly-test/utils/cmd_utils.py b/tests/nightly-test/utils/cmd_utils.py new file mode 100644 index 000000000..fe8203e1f --- /dev/null +++ b/tests/nightly-test/utils/cmd_utils.py @@ -0,0 +1,37 @@ +import datetime +import logging +import time + + +LOG = logging.getLogger(__name__) + + +def wait_for(func, timeout, delay, *args, **kargs): + """Decorator for waiting for until a function finished running.""" + + poll_timeout = timeout + poll_sleep_retry = delay + + begin_poll = datetime.datetime.now() + while True: + try: + return func(*args, **kargs) + break + except Exception as e: + if (datetime.datetime.now() - begin_poll).seconds > poll_timeout: + LOG.exception('Time out after %s seconds.' % poll_timeout) + raise TimeoutError('Timed out after %s seconds. Reason: ' + '%s' % (poll_timeout, e)) + else: + LOG.debug('Sleeping %s seconds before retrying' + '' % poll_sleep_retry) + time.sleep(poll_sleep_retry) + + +def safe_run(cmd, msg, sleep_time=180): + exit_code = shell.local(cmd)[0] + if exit_code: + LOG.warning('Failed to %s. Retry it after %s seconds' % + (msg, sleep_time)) + time.sleep(sleep_time) + shell.local(cmd, raise_error=True) \ No newline at end of file diff --git a/tests/nightly-test/utils/govc_utils.py b/tests/nightly-test/utils/govc_utils.py new file mode 100644 index 000000000..4cc582449 --- /dev/null +++ b/tests/nightly-test/utils/govc_utils.py @@ -0,0 +1,32 @@ +#!/usr/bin/python2 + +import os, subprocess +import time + +SHELL_SCRIPT_DIR = os.getcwd() + '/tests/nightly-test/shellscript/' + +def getvmip(vc_url, vc_user, vc_password, vm_name, timeout=600) : + cmd = (SHELL_SCRIPT_DIR+'getvmip.sh %s %s %s %s ' % (vc_url, vc_user, getPasswordInShell(vc_password), vm_name)) + interval = 10 + while True: + try: + if timeout <= 0: + return '' + result = subprocess.check_output(cmd,shell=True).strip() + if result is not '': + if result != 'photon-machine': + return result + except Exception, e: + timeout -= interval + time.sleep(interval) + continue + timeout -= interval + time.sleep(interval) + +def destoryvm(vc_url, vc_user, vc_password, vm_name) : + cmd = (SHELL_SCRIPT_DIR+'destoryvm.sh %s %s %s %s ' % (vc_url, vc_user, getPasswordInShell(vc_password), vm_name)) + result = subprocess.check_output(cmd, shell=True) + return result + +def getPasswordInShell(password) : + return password.replace("!", "\!") \ No newline at end of file diff --git a/tests/nightly-test/utils/harbor_util.py b/tests/nightly-test/utils/harbor_util.py new file mode 100644 index 000000000..18707410d --- /dev/null +++ b/tests/nightly-test/utils/harbor_util.py @@ -0,0 +1,23 @@ +from urllib2 import urlopen +import ssl +import time + +# wait for 10 minutes as OVA needs about 7 minutes to startup harbor. +def wait_for_harbor_ready(harbor_endpoint, timeout=600): + ctx = ssl.create_default_context() + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + interval = 10 + while True: + try: + if timeout <= 0: + return False + code = urlopen(harbor_endpoint, context=ctx).code + if code == 200: + return True + except Exception, e: + timeout -= interval + time.sleep(interval) + continue + timeout -= interval + time.sleep(interval) \ No newline at end of file diff --git a/tests/nightly-test/utils/nlogging.py b/tests/nightly-test/utils/nlogging.py new file mode 100644 index 000000000..bc17eaedb --- /dev/null +++ b/tests/nightly-test/utils/nlogging.py @@ -0,0 +1,14 @@ +from __future__ import absolute_import + +import logging +import sys + +def create_logger(name): + default_handler = logging.StreamHandler(sys.stderr) + default_handler.setFormatter(logging.Formatter( + '[%(asctime)s] %(levelname)s in %(module)s: %(message)s' + )) + logger = logging.getLogger(name) + logger.setLevel(logging.DEBUG) + logger.addHandler(default_handler) + return logger \ No newline at end of file diff --git a/tests/nightly-test/utils/test_executor.py b/tests/nightly-test/utils/test_executor.py new file mode 100644 index 000000000..4ac5f3236 --- /dev/null +++ b/tests/nightly-test/utils/test_executor.py @@ -0,0 +1,53 @@ +#!/usr/bin/python2 + +import os, subprocess +import time +import sys + +from subprocess import call +import json + +import nlogging +logger = nlogging.create_logger(__name__) + +# Needs have docker installed. +def execute(harbor_endpoints, vm_names, harbor_root_pwd, test_suite, auth_mode ,vc_host, vc_user, vc_password, harbor_pwd='Harbor12345') : + cmd = '' + exe_result = -1 + cmd_base = "docker run -i --privileged -v %s:/drone -w /drone vmware/harbor-e2e-engine:1.38 " % os.getcwd() + + if len(harbor_endpoints) == 1: + cmd_pybot = "pybot -v ip:%s -v vm_name:%s -v HARBOR_PASSWORD:%s -v SSH_PWD:%s -v vc_host:%s -v vc_user:%s -v vc_password:%s " % (harbor_endpoints[0], vm_names[0], harbor_pwd, harbor_root_pwd, vc_host, vc_user, vc_password) + + if len(harbor_endpoints) == 2: + cmd_pybot = "pybot -v ip:%s -v vm_name:%s -v ip1:%s -v vm_name1:%s -v HARBOR_PASSWORD:%s -v SSH_PWD:%s -v vc_host:%s -v vc_user:%s -v vc_password:%s " % (harbor_endpoints[0], vm_names[0], harbor_endpoints[1], vm_names[1], harbor_pwd, harbor_root_pwd, vc_host, vc_user, vc_password) + + cmd = cmd_base + cmd_pybot + if test_suite == 'Nightly': + if auth_mode == 'ldap_auth': + cmd = cmd + "/drone/tests/robot-cases/Group11-Nightly/LDAP.robot" + else: + cmd = cmd + "/drone/tests/robot-cases/Group11-Nightly/Nightly.robot" + + logger.info(cmd) + p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE) + while True: + out = p.stderr.read(1) + if out == '' and p.poll() != None: + break + if out != '': + sys.stdout.write(out) + sys.stdout.flush() + exe_result = p.returncode + + if test_suite == 'Longevity': + cmd = cmd + "/drone/tests/robot-cases/Group12-Longevity/Longevity.robot > /dev/null 2>&1" + logger.info(cmd) + exe_result = subprocess.call(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE) + + collect_log() + return exe_result == 0 + +# Needs to move log.html to another path it will be overwrite by any pybot run. +def collect_log(): + pass \ No newline at end of file diff --git a/tests/resources/Docker-Util.robot b/tests/resources/Docker-Util.robot index 8891d2175..b02a44629 100644 --- a/tests/resources/Docker-Util.robot +++ b/tests/resources/Docker-Util.robot @@ -126,6 +126,13 @@ Start Docker Daemon Locally Sleep 2s [Return] ${handle} +Prepare Docker Cert + [Arguments] ${ip} + ${rc} ${out}= Run And Return Rc And Output mkdir -p /etc/docker/certs.d/${ip} + Should Be Equal As Integers ${rc} 0 + ${rc} ${out}= Run And Return Rc And Output cp harbor_ca.crt /etc/docker/certs.d/${ip} + Should Be Equal As Integers ${rc} 0 + Kill Local Docker Daemon [Arguments] ${handle} ${dockerd-pid} Terminate Process ${handle} diff --git a/tests/resources/Harbor-Pages/Configuration.robot b/tests/resources/Harbor-Pages/Configuration.robot index 0afa72da0..451807ba0 100644 --- a/tests/resources/Harbor-Pages/Configuration.robot +++ b/tests/resources/Harbor-Pages/Configuration.robot @@ -76,6 +76,10 @@ Test Ldap Connection Capture Page Screenshot Wait Until Page Contains Connection to LDAP server is verified timeout=15 +Test LDAP Server Success + Click Element xpath=${test_ldap_xpath} + Wait Until Page Contains Connection to LDAP server is verified timeout=15 + Disable Ldap Verify Cert Checkbox Mouse Down xpath=//*[@id="clr-checkbox-ldapVerifyCert"] Mouse Up xpath=//*[@id="clr-checkbox-ldapVerifyCert"] diff --git a/tests/resources/Harbor-Pages/Project-Repository.robot b/tests/resources/Harbor-Pages/Project-Repository.robot new file mode 100644 index 000000000..7601d3043 --- /dev/null +++ b/tests/resources/Harbor-Pages/Project-Repository.robot @@ -0,0 +1,36 @@ +# Copyright 2016-2017 VMware, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation This resource provides any keywords related to the Harbor private registry appliance +Resource ../../resources/Util.robot + +*** Keywords *** +View Repo Scan Details + Click Element xpath=${first_repo_xpath} + Sleep 2 + Capture Page Screenshot viewcve1.png + Wait Until Page Contains unknown + Wait Until Page Contains high + Wait Until Page Contains medium + Page Should Contain CVE + +View Scan Error Log + Page Should Contain View Log + Click Element xpath=${view_log_xpath} + Sleep 1 + Capture Page Screenshot viewlog.png + Wait Until Page Contains Entered scan initializer + Wait Until Page Contains ERROR + Wait Until Page Contains View Scanning Job Log \ No newline at end of file diff --git a/tests/resources/Harbor-Pages/Project-Repository_Elements.robot b/tests/resources/Harbor-Pages/Project-Repository_Elements.robot new file mode 100644 index 000000000..d5750c350 --- /dev/null +++ b/tests/resources/Harbor-Pages/Project-Repository_Elements.robot @@ -0,0 +1,21 @@ +# Copyright 2016-2017 VMware, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation This resource provides any keywords related to the Harbor private registry appliance + +*** Variables *** +${first_repo_xpath} //clr-dg-row//clr-dg-cell[2]//a +${first_cve_xpath} //clr-dg-row[1]//clr-dg-cell//a +${view_log_xpath} //clr-dg-row[1]//clr-dg-cell[5]//a \ No newline at end of file diff --git a/tests/resources/Harbor-Pages/Project.robot b/tests/resources/Harbor-Pages/Project.robot index a4d8890fc..b6dbbf455 100644 --- a/tests/resources/Harbor-Pages/Project.robot +++ b/tests/resources/Harbor-Pages/Project.robot @@ -61,7 +61,7 @@ Switch To Replication Back To projects Click Element xpath=${projects_xpath} - Sleep 1 + Sleep 2 Project Should Display [Arguments] ${projectname} diff --git a/tests/resources/Harbor-Util.robot b/tests/resources/Harbor-Util.robot index e7dad7ab3..a3cc1a6d5 100644 --- a/tests/resources/Harbor-Util.robot +++ b/tests/resources/Harbor-Util.robot @@ -92,7 +92,7 @@ Switch To LDAP Should Be Equal As Integers ${rc} 0 Generate Certificate Authority For Chrome -Enabe Notary Client +Enable Notary Client ${rc} ${output}= Run And Return Rc And Output rm -rf ~/.docker/ Log ${rc} Should Be Equal As Integers ${rc} 0 diff --git a/tests/resources/Nightly-Util.robot b/tests/resources/Nightly-Util.robot new file mode 100644 index 000000000..af5d150ff --- /dev/null +++ b/tests/resources/Nightly-Util.robot @@ -0,0 +1,53 @@ +# Copyright 2016-2017 VMware, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation This resource provides any keywords related to the Harbor private registry appliance +Resource Util.robot + +*** Variables *** +${SSH_USER} root + +*** Keywords *** +Nightly Test Setup + [Arguments] ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} + Run Keyword CA setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} + Run Keyword Prepare Docker Cert ${ip} + Run Keyword Start Docker Daemon Locally + +CA Setup + [Arguments] ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} + Open Connection ${ip} + Login ${SSH_USER} ${SSH_PWD} + SSHLibrary.Get File /data/ca_download/ca.crt + Close All Connections + Run mv ca.crt harbor_ca.crt + Generate Certificate Authority For Chrome ${HARBOR_PASSWORD} + +Collect Nightly Logs + [Arguments] ${ip} ${SSH_PWD} + Open Connection ${ip} + Login ${SSH_USER} ${SSH_PWD} + SSHLibrary.Get File /var/log/harbor/ui.log + SSHLibrary.Get File /var/log/harbor/registry.log + SSHLibrary.Get File /var/log/harbor/proxy.log + SSHLibrary.Get File /var/log/harbor/adminserver.log + SSHLibrary.Get File /var/log/harbor/clair-db.log + SSHLibrary.Get File /var/log/harbor/clair.log + SSHLibrary.Get File /var/log/harbor/jobservice.log + SSHLibrary.Get File /var/log/harbor/mysql.log + SSHLibrary.Get File /var/log/harbor/notary-db.log + SSHLibrary.Get File /var/log/harbor/notary-server.log + SSHLibrary.Get File /var/log/harbor/notary-signer.log + Close All Connections \ No newline at end of file diff --git a/tests/resources/OVA-Util.robot b/tests/resources/OVA-Util.robot index b7eaabb7d..c4d728398 100644 --- a/tests/resources/OVA-Util.robot +++ b/tests/resources/OVA-Util.robot @@ -32,10 +32,10 @@ ${ova_network_options} --prop:network.ip0=${ova_network_ip0} --prop:network.net ${ova_harbor_admin_password} harbor-admin-passwd ${ova_harbor_db_password} harbor-db-passwd -${ova_service_options} --prop:auth_mode="%{AUTH_MODE}" --prop:clair_db_password="%{CLAIR_DB_PASSWORD}" --prop:max_job_workers="%{MAX_JOB_WORKERS}" --prop:harbor_admin_password="%{HARBOR_ADMIN_PASSWORD}" --prop:db_password="%{DB_PASSWORD}" +#${ova_service_options} --prop:auth_mode="%{AUTH_MODE}" --prop:clair_db_password="%{CLAIR_DB_PASSWORD}" --prop:max_job_workers="%{MAX_JOB_WORKERS}" --prop:harbor_admin_password="%{HARBOR_ADMIN_PASSWORD}" --prop:db_password="%{DB_PASSWORD}" -${ova_options} ${ovftool_options} ${ova_appliance_options} ${ova_service_options} -${ova_options_with_network} ${ova_options} ${ova_network_options} +#${ova_options} ${ovftool_options} ${ova_appliance_options} ${ova_service_options} +#${ova_options_with_network} ${ova_options} ${ova_network_options} ${tls_not_disabled} False diff --git a/tests/resources/Util.robot b/tests/resources/Util.robot index f0c354c26..ea13de942 100644 --- a/tests/resources/Util.robot +++ b/tests/resources/Util.robot @@ -33,6 +33,8 @@ Resource Harbor-Pages/Project.robot Resource Harbor-Pages/Project_Elements.robot Resource Harbor-Pages/Project-Members.robot Resource Harbor-Pages/Project-Members_Elements.robot +Resource Harbor-Pages/Project-Repository.robot +Resource Harbor-Pages/Project-Repository_Elements.robot Resource Harbor-Pages/Replication.robot Resource Harbor-Pages/Replication_Elements.robot Resource Harbor-Pages/UserProfile.robot @@ -47,3 +49,4 @@ Resource OVA-Util.robot Resource Cert-Util.robot Resource SeleniumUtil.robot Resource Harbor-Pages/Project-Config.robot +Resource Nightly-Util.robot diff --git a/tests/resources/Vsphere-Util.robot b/tests/resources/Vsphere-Util.robot index 6072cc9ae..5a4a790ec 100644 --- a/tests/resources/Vsphere-Util.robot +++ b/tests/resources/Vsphere-Util.robot @@ -17,19 +17,19 @@ Documentation This resource contains any keywords dealing with operations being *** Keywords *** Power On VM OOB - [Arguments] ${vm} - ${rc} ${output}= Run And Return Rc And Output govc vm.power -on "${vm}" + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} + ${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -on "${vm}" Should Be Equal As Integers ${rc} 0 Log To Console Waiting for VM to power on ... - Wait Until VM Powers On ${vm} + Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password} Power Off VM OOB - [Arguments] ${vm} - ${rc} ${output}= Run And Return Rc And Output govc vm.power -off "${vm}" + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} + ${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -off "${vm}" Log To Console ${output} Should Be Equal As Integers ${rc} 0 Log To Console Waiting for VM to power off ... - Wait Until VM Powers Off "${vm}" + Wait Until VM Powers Off "${vm}" ${vc_host} ${vc_user} ${vc_password} Destroy VM OOB [Arguments] ${vm} @@ -45,24 +45,24 @@ Remove Host From Maintenance Mode Should Contain ${output} exiting maintenance mode... OK Reboot VM - [Arguments] ${vm} + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} Log To Console Rebooting ${vm} ... - Power Off VM OOB ${vm} - Power On VM OOB ${vm} + Power Off VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password} + Power On VM OOB ${vm} ${vc_host} ${vc_user} ${vc_password} Log To Console ${vm} Powered On Reset VM - [Arguments] ${vm} - ${rc} ${output}= Run And Return Rc And Output govc vm.power -reset "${vm}" + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} + ${rc} ${output}= Run And Return Rc And Output GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.power -reset "${vm}" Log To Console ${output} Should Be Equal As Integers ${rc} 0 Log To Console Waiting for VM to reset ... - Wait Until VM Powers On "${vm}" + Wait Until VM Powers On "${vm}" ${vc_host} ${vc_user} ${vc_password} Wait Until VM Powers On - [Arguments] ${vm} + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} :FOR ${idx} IN RANGE 0 30 - \ ${ret}= Run govc vm.info ${vm} + \ ${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm} \ Set Test Variable ${out} ${ret} \ ${status}= Run Keyword And Return Status Should Contain ${out} poweredOn \ Return From Keyword If ${status} @@ -70,9 +70,9 @@ Wait Until VM Powers On Fail VM did not power on within 30 seconds Wait Until VM Powers Off - [Arguments] ${vm} + [Arguments] ${vm} ${vc_host} ${vc_user} ${vc_password} :FOR ${idx} IN RANGE 0 30 - \ ${ret}= Run govc vm.info ${vm} + \ ${ret}= Run GOVC_URL=${vc_host} GOVC_USERNAME=${vc_user} GOVC_PASSWORD=${vc_password} GOVC_INSECURE=1 govc vm.info ${vm} \ Set Test Variable ${out} ${ret} \ ${status}= Run Keyword And Return Status Should Contain ${out} poweredOff \ Return From Keyword If ${status} diff --git a/tests/robot-cases/Group0-BAT/BAT.robot b/tests/robot-cases/Group0-BAT/BAT.robot index e4d66fce3..ae7ed6c44 100644 --- a/tests/robot-cases/Group0-BAT/BAT.robot +++ b/tests/robot-cases/Group0-BAT/BAT.robot @@ -392,13 +392,13 @@ Test Case - Assign Sys Admin Close Browser Test Case - Admin Push Signed Image - Enabe Notary Client + Enable Notary Client ${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest Log ${output} Push image ${ip} %{HARBOR_ADMIN} %{HARBOR_PASSWORD} library hello-world:latest - ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group9-Content-trust/notary-push-image.sh + ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group9-Content-trust/notary-push-image.sh ${ip} Log ${output} Should Be Equal As Integers ${rc} 0 diff --git a/tests/robot-cases/Group11-Nightly/LDAP.robot b/tests/robot-cases/Group11-Nightly/LDAP.robot new file mode 100644 index 000000000..62b74c3a7 --- /dev/null +++ b/tests/robot-cases/Group11-Nightly/LDAP.robot @@ -0,0 +1,61 @@ +// Copyright (c) 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +*** Settings *** +Documentation Harbor BATs +Resource ../../resources/Util.robot +Suite Setup Nightly Test Setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} +Suite Teardown Collect Nightly Logs ${ip} ${SSH_PWD} +Default Tags Nightly + +*** Variables *** +${HARBOR_URL} https://${ip} +${SSH_USER} root +${HARBOR_ADMIN} admin + +*** Test Cases *** +Test Case - Ldap Verify Cert + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Configure + Test LDAP Server Success + Close Browser + +Test Case - Ldap Sign in and out + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} mike zhu88jie + Close Browser + +Test Case - Ldap User Create Project + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} mike zhu88jie + Create An New Project project${d} + Logout Harbor + Manage Project Member ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} mike02 Add + Close Browser + +Test Case - Ldap User Push An Image + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} mike zhu88jie + Create An New Project project${d} + + Push Image ${ip} mike zhu88jie project${d} hello-world:latest + Go Into Project project${d} + Wait Until Page Contains project${d}/hello-world + Close Browser + +Test Case - Ldap User Can Not login + Docker Login Fail ${ip} test 123456 \ No newline at end of file diff --git a/tests/robot-cases/Group11-Nightly/Nightly.robot b/tests/robot-cases/Group11-Nightly/Nightly.robot new file mode 100644 index 000000000..c20dcd41f --- /dev/null +++ b/tests/robot-cases/Group11-Nightly/Nightly.robot @@ -0,0 +1,443 @@ +// Copyright (c) 2017 VMware, Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +*** Settings *** +Documentation Harbor BATs +Resource ../../resources/Util.robot +Suite Setup Nightly Test Setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} +Suite Teardown Collect Nightly Logs ${ip} ${SSH_PWD} +Default Tags Nightly + +*** Variables *** +${HARBOR_URL} https://${ip} +${SSH_USER} root +${HARBOR_ADMIN} admin + +*** Test Cases *** +Test Case - Create An New User + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Close Browser + +Test Case - Sign With Admin + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Close Browser + +Test Case - Update User Comment + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Update User Comment Test12#4 + Logout Harbor + +Test Case - Update Password + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Change Password Test1@34 Test12#4 + Logout Harbor + Sign In Harbor ${HARBOR_URL} tester${d} Test12#4 + Close Browser + +Test Case - Create An New Project + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Create An New Project test${d} + Close Browser + +Test Case - User View Projects + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Create An New Project test${d}1 + 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 + Close Browser + +Test Case - Push Image + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Create An New Project test${d} + + Push image ${ip} tester${d} Test1@34 test${d} hello-world:latest + Go Into Project test${d} + Wait Until Page Contains test${d}/hello-world + +Test Case - User View Logs + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + + Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=true + + Push image ${ip} tester${d} Test1@34 project${d} busybox:latest + Pull image ${ip} tester${d} Test1@34 project${d} busybox:latest + + Go Into Project project${d} + Delete Repo project${d} + + Go To Project Log + Advanced Search Should Display + + Do Log Advanced Search + Close Browser + +Test Case - Manage project publicity + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + + Create An New User url=${HARBOR_URL} username=usera${d} email=usera${d}@vmware.com realname=usera${d} newPassword=Test1@34 comment=harbor + Logout Harbor + Create An New User url=${HARBOR_URL} username=userb${d} email=userb${d}@vmware.com realname=userb${d} newPassword=Test1@34 comment=harbor + Logout Harbor + + Sign In Harbor ${HARBOR_URL} usera${d} Test1@34 + Create An New Project project${d} public=true + + Push image ${ip} usera${d} Test1@34 project${d} hello-world:latest + Pull image ${ip} userb${d} Test1@34 project${d} hello-world:latest + + Logout Harbor + Sign In Harbor ${HARBOR_URL} userb${d} Test1@34 + Project Should Display project${d} + Search Private Projects + Project Should Not Display project${d} + + Logout Harbor + Sign In Harbor ${HARBOR_URL} usera${d} Test1@34 + Make Project Private project${d} + + Logout Harbor + Sign In Harbor ${HARBOR_URL} userb${d} Test1@34 + Project Should Not Display project${d} + Cannot Pull image ${ip} userb${d} Test1@34 project${d} hello-world:latest + + Logout Harbor + Sign In Harbor ${HARBOR_URL} usera${d} Test1@34 + Make Project Public project${d} + + Logout Harbor + Sign In Harbor ${HARBOR_URL} userb${d} Test1@34 + Project Should Display project${d} + Close Browser + +Test Case - Project Level Policy Public + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${d} + Go Into Project project${d} + Goto Project Config + Click Project Public + Save Project Config + #verify + Public Should Be Selected + Back To Projects + #project${d} default should be private + Project Should Be Public project${d} + Close Browser + +Test Case - Project Level Policy Content Trust + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Create An New Project project${d} + Push Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world:latest + Go Into Project project${d} + Goto Project Config + Click Content Trust + Save Project Config + #verify + Content Trust Should Be Selected + Cannot Pull Unsigned Image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} project${d} hello-world:latest + Close Browser + +Test Case - Edit Project Creation + # create normal user and login + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + + Project Creation Should Display + Logout Harbor + + Sleep 3 + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Set Pro Create Admin Only + Logout Harbor + + Sign In Harbor ${HARBOR_URL} tester${d} Test1@34 + Project Creation Should Not Display + Logout Harbor + + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Set Pro Create Every One + Close browser + +Test Case - Edit Self-Registration + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Disable Self Reg + Logout Harbor + + Sign Up Should Not Display + + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To Configure + Self Reg Should Be Disabled + Sleep 1 + + #restore setting + Enable Self Reg + Close Browser + +Test Case - Edit Email Settings + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + + Switch To Email + Config Email + + Logout Harbor + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + + Switch To Email + Verify Email + + Close Browser + +Test Case - Edit Token Expire + Init Chrome Driver + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To System Settings + Modify Token Expiration 20 + Logout Harbor + + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch To System Settings + Token Must Be Match 20 + + #reset to default + Modify Token Expiration 30 + Close Browser + +#Test Case - Create An Replication Rule New Endpoint +# Init Chrome Driver +# ${d}= Get current date result_format=%m%s +# Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} +# Create An New Project project${d} +# Go Into Project project${d} +# Switch To Replication +# Create An New Rule With New Endpoint policy_name=test_policy_${d} policy_description=test_description destination_name=test_destination_name_${d} destination_url=test_destination_url_${d} destination_username=test_destination_username destination_password=test_destination_password +# Close Browser + +Test Case - Scan A Tag In The Repo + Init Chrome Driver + ${d}= get current date result_format=%m%s + Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false + Push Image ${ip} tester${d} Test1@34 project${d} hello-world + Go Into Project project${d} + Go Into Repo project${d}/hello-world + Scan Repo latest + Summary Chart Should Display latest + #Edit Repo Info + Close Browser + +Test Case - Manage Project Member + Init Chrome Driver + ${d}= Get current Date result_format=%m%s + + Create An New Project With New User url=${HARBOR_URL} username=alice${d} email=alice${d}@vmware.com realname=alice${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false + Push image ip=${ip} user=alice${d} pwd=Test1@34 project=project${d} image=hello-world + Logout Harbor + Create An New User url=${HARBOR_URL} username=bob${d} email=bob${d}@vmware.com realname=bob${d} newPassword=Test1@34 comment=habor + Logout Harbor + Create An New User url=${HARBOR_URL} username=carol${d} email=carol${d}@vmware.com realname=carol${d} newPassword=Test1@34 comment=harbor + Logout Harbor + + User Should Not Be A Member Of Project bob${d} Test1@34 project${d} + Manage Project Member alice${d} Test1@34 project${d} bob${d} Add + User Should Be Guest bob${d} Test1@34 project${d} + Change User Role In Project alice${d} Test1@34 project${d} bob${d} Developer + User Should Be Developer bob${d} Test1@34 project${d} + Change User Role In Project alice${d} Test1@34 project${d} bob${d} Admin + User Should Be Admin bob${d} Test1@34 project${d} carol${d} + Manage Project Member alice${d} Test1@34 project${d} bob${d} Remove + User Should Not Be A Member Of Project bob${d} Test1@34 project${d} + User Should Be Guest carol${d} Test1@34 project${d} + + Close Browser + +Test Case - Delete A Project + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New Project With New User ${HARBOR_URL} tester${d} tester${d}@vmware.com tester${d} Test1@34 harobr project${d} false + Push Image ${ip} tester${d} Test1@34 project${d} hello-world + Project Should Not Be Deleted project${d} + Go Into Project project${d} + Delete Repo project${d} + Back To projects + Project Should Be Deleted project${d} + Close Browser + +Test Case - Delete Multi Project + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor + Create An New Project projecta${d} + Create An New Project projectb${d} + Push Image ${ip} test${d} Test1@34 projecta${d} hello-world + Filter Object project + Multi-delete Object projecta projectb + #verify delete project with image should not be deleted directly + Partly Success + Page Should Contain projecta${d} + Page Should Not Contain projectb${d} + Close Browser + +Test Case - Delete Multi User + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User ${HARBOR_URL} deletea${d} testa${d}@vmware.com test${d} Test1@34 harbor + Logout Harbor + Create An New User ${HARBOR_URL} deleteb${d} testb${d}@vmware.com test${d} Test1@34 harbor + Logout Harbor + Create An New User ${HARBOR_URL} deletec${d} testc${d}@vmware.com test${d} Test1@34 harbor + Logout Harbor + Sign In Harbor ${HARBOR_URL} admin Harbor12345 + Switch To User Tag + Filter Object delete + Multi-delete Object deletea deleteb deletec + #assert delete + #Delete Success comment temp wait for fixing + Click Element //clr-modal//button[contains(.,'CLOSE')] + Sleep 1 + #filter object delete + Page Should Not Contain deletea + Close Browser + +Test Case - Delete Multi Repo + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor + Create An New Project project${d} + Push Image ${ip} test${d} Test1@34 project${d} hello-world + Push Image ${ip} test${d} Test1@34 project${d} busybox + Sleep 2 + Go Into Project project${d} + Multi-delete Object hello-world busybox + #verify + Delete Success + Close Browser + +Test Case - Delete Multi Tag + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor + Create An New Project project${d} + Push Image With Tag ${ip} test${d} Test1@34 project${d} hello-world latest + Push Image With Tag ${ip} test${d} Test1@34 project${d} hello-world v1 + Sleep 2 + Go Into Project project${d} + Go Into Repo hello-world + Multi-delete object latest v1 + #verify + Delete Success + Close Browser + +Test Case - Delete Multi Member + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User ${HARBOR_URL} testa${d} testa${d}@vmware.com test${d} Test1@34 harbor + Logout Harbor + Create An New User ${HARBOR_URL} testb${d} testb${d}@vmware.com test${d} Test1@34 harbor + Logout Harbor + Create An New User ${HARBOR_URL} test${d} test${d}@vmware.com test${d} Test1@34 harbor + Create An New Project project${d} + Go Into Project project${d} + Switch To Member + Add Guest Member to project testa${d} + Add Guest Member to project testb${d} + Multi-delete Object testa${d} testb${d} + Delete Success + Page Should Not Contain testa${d} + Close Browser + +Test Case - Assign Sys Admin + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest + Logout Harbor + Sign In Harbor ${HARBOR_URL} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} + Switch to User Tag + Assign User Admin tester${d} + Logout Harbor + Sign In Harbor ${HARBOR_URL} tester${d} Test1@34 + Administration Tag Should Display + Close Browser + +Test Case - Admin Push Signed Image + Enable Notary Client + + ${rc} ${output}= Run And Return Rc And Output docker pull hello-world:latest + Log ${output} + + Push image ${ip} ${HARBOR_ADMIN} ${HARBOR_PASSWORD} library hello-world:latest + ${rc} ${output}= Run And Return Rc And Output ./tests/robot-cases/Group9-Content-trust/notary-push-image.sh ${ip} + Log ${output} + Should Be Equal As Integers ${rc} 0 + + ${rc} ${output}= Run And Return Rc And Output curl -u admin:Harbor12345 -s --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/repositories/library/tomcat/signatures" + Log To Console ${output} + Should Be Equal As Integers ${rc} 0 + Should Contain ${output} sha256 + +Test Case - View Scan Results + Init Chrome Driver + ${d}= get current date result_format=%m%s + Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false + Push Image ${ip} tester${d} Test1@34 project${d} tomcat + Go Into Project project${d} + Go Into Repo project${d}/tomcat + Scan Repo latest + Summary Chart Should Display latest + View Repo Scan Details + Close Browser + +Test Case - View Scan Error + Init Chrome Driver + ${d}= get current date result_format=%m%s + Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false + Push Image ${ip} tester${d} Test1@34 project${d} vmware/photon:1.0 + Go Into Project project${d} + Go Into Repo project${d}/vmware/photon + Scan Repo 1.0 + View Scan Error Log + Close Browser + +#Test Case - OVA reboot +# Reboot VM ${vm_name} ${vc_host} ${vc_user} ${vc_password} +# Wait for Harbor Ready https ${ip} + +#Test Case - OVA reset +# Reset VM ${vm_name} ${vc_host} ${vc_user} ${vc_password} +# Wait for Harbor Ready https ${ip} \ No newline at end of file diff --git a/tests/robot-cases/Group12-Longevity/Dockerfile.longevity b/tests/robot-cases/Group12-Longevity/Dockerfile.longevity new file mode 100644 index 000000000..30ab268ce --- /dev/null +++ b/tests/robot-cases/Group12-Longevity/Dockerfile.longevity @@ -0,0 +1,2 @@ +FROM busybox:1.26 +RUN /bin/dd if=/dev/urandom of=file10mb bs=10485760 count=1 \ No newline at end of file diff --git a/tests/robot-cases/Group12-Longevity/Longevity.robot b/tests/robot-cases/Group12-Longevity/Longevity.robot new file mode 100644 index 000000000..be3524d5d --- /dev/null +++ b/tests/robot-cases/Group12-Longevity/Longevity.robot @@ -0,0 +1,90 @@ +# Copyright 2016-2017 VMware, Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +*** Settings *** +Documentation Longevity +Resource ../../resources/Util.robot +Suite Teardown Collect Nightly Logs ${ip} ${SSH_PWD} + +*** Variables *** +${HARBOR_URL} https://${ip} +${SSH_USER} root + +${image0} consul +${image1} node +${image2} tomcat +${image3} redis +${image4} httpd +${image5} busybox +${image6} mysql +${image7} registry +${image8} mongo +${image9} memcached + +*** Keywords *** +Longevity setup + Run Keyword CA setup + Run Keyword Prepare Docker Cert ${ip} + Run Keyword Start Docker Daemon Locally + +CA setup + Open Connection ${ip} + Login ${SSH_USER} ${SSH_PWD} + SSHLibrary.Get File /data/ca_download/ca.crt + Close All Connections + Run mv ca.crt harbor_ca.crt + Generate Certificate Authority For Chrome ${HARBOR_PASSWORD} + +Regression Test With DB + [Arguments] ${HARBOR_URL} + Run Keyword And Continue On Failure Exe Regression Test Cases ${HARBOR_URL} + +Exe Regression Test Cases + [Arguments] ${HARBOR_URL} + + # New user, new project, push image, pull image + Init Chrome Driver + ${d}= Get Current Date result_format=%m%s + Create An New Project With New User url=${HARBOR_URL} username=tester${d} email=tester${d}@vmware.com realname=tester${d} newPassword=Test1@34 comment=harbor projectname=project${d} public=false + + ${rand}= Evaluate random.randint(0, 1) modules=random + Run Keyword If '${rand}' == '0' Generate Prepared Image ${ip} tester${d} project${d} + Run Keyword If '${rand}' == '1' Generate Random 10MB Image ${ip} tester${d} project${d} + + Close Browser + +Generate Prepared Image + [Arguments] ${ip} ${user} ${project} + ${rand}= Evaluate random.randint(0, 9) modules=random + Push image ${ip} ${user} Test1@34 ${project} ${image${rand}}:latest + Pull image ${ip} ${user} Test1@34 ${project} ${image${rand}}:latest + Pull image ${ip} ${user} Test1@34 ${project} ${image${rand}}:latest + +Generate Random 10MB Image + [Arguments] ${ip} ${user} ${project} + ${rand}= Evaluate random.randint(0, 10000) modules=random + ${rc}= Run And Return Rc docker build -f ./tests/robot-cases/Group12-Longevity/Dockerfile.longevity -t longevity${rand}:latest . + Should Be Equal As Integers ${rc} 0 + Push image ${ip} ${user} Test1@34 ${project} longevity${rand}:latest + Pull image ${ip} ${user} Test1@34 ${project} longevity${rand}:latest + Pull image ${ip} ${user} Test1@34 ${project} longevity${rand}:latest + +*** Test Cases *** +Longevity + Run Keyword Longevity setup + # Each loop should take between 1 and 2 hours + :FOR ${idx} IN RANGE 0 48 + \ ${rand}= Evaluate random.randint(10, 50) modules=random + \ Log To Console \nLoop: ${idx} + \ Repeat Keyword ${rand} times Regression Test With DB ${HARBOR_URL} \ No newline at end of file diff --git a/tests/robot-cases/Group9-Content-trust/notary-push-image.py b/tests/robot-cases/Group9-Content-trust/notary-push-image.py deleted file mode 100755 index 5f39291f9..000000000 --- a/tests/robot-cases/Group9-Content-trust/notary-push-image.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/python - -import pexpect -import os -import sys -import time -import socket - -ip = socket.gethostbyname(socket.gethostname()) -cmd = "docker push "+ip+"/library/tomcat:latest" -passw = "Harbor12345" -child = pexpect.spawn(cmd) -time.sleep(5) - -child.expect(':') -child.sendline(passw) -time.sleep(1) -child.expect(':') -child.sendline(passw) -time.sleep(1) -child.expect(':') -child.sendline(passw) -time.sleep(1) -child.expect(':') -child.sendline(passw) -time.sleep(1) -child.expect(pexpect.EOF) diff --git a/tests/robot-cases/Group9-Content-trust/notary-push-image.sh b/tests/robot-cases/Group9-Content-trust/notary-push-image.sh index 3c4849829..71272d9e9 100755 --- a/tests/robot-cases/Group9-Content-trust/notary-push-image.sh +++ b/tests/robot-cases/Group9-Content-trust/notary-push-image.sh @@ -2,7 +2,7 @@ docker pull tomcat:latest -IP=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'` +IP=$1 PASSHRASE='Harbor12345' echo $IP