From c37b3748b9e1787bc8e874c94e8bcceed6c6949b Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 28 Feb 2018 19:37:25 +0800 Subject: [PATCH] Support replication test in nightly infrastructure (#4302) --- tests/nightly-test/utils/test_executor.py | 2 +- tests/resources/Cert-Util.robot | 5 +++-- tests/resources/Nightly-Util.robot | 13 +++++++++++-- tests/robot-cases/Group11-Nightly/Nightly.robot | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/nightly-test/utils/test_executor.py b/tests/nightly-test/utils/test_executor.py index 4ac5f3236..f352bdee6 100644 --- a/tests/nightly-test/utils/test_executor.py +++ b/tests/nightly-test/utils/test_executor.py @@ -17,7 +17,7 @@ def execute(harbor_endpoints, vm_names, harbor_root_pwd, test_suite, auth_mode , 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) + cmd_pybot = "pybot -v ip:%s -v vm_name:%s -v ip1: -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) diff --git a/tests/resources/Cert-Util.robot b/tests/resources/Cert-Util.robot index 001f3e9ad..f833384b7 100644 --- a/tests/resources/Cert-Util.robot +++ b/tests/resources/Cert-Util.robot @@ -19,11 +19,12 @@ Documentation This resource contains keywords related to creating and using cer Generate Certificate Authority For Chrome # add the ca to chrome trust list to enable https testing. [Arguments] ${password}=%{HARBOR_PASSWORD} + ${rand}= Evaluate random.randint(0, 100000) modules=random Log To Console Generate Certificate Authority For Chrome - ${rc} ${out}= Run And Return Rc And Output echo ${password} > password.ca + ${rc} ${out}= Run And Return Rc And Output echo ${password} > password${rand}.ca Log ${out} Should Be Equal As Integers ${rc} 0 - ${rc} ${out}= Run And Return Rc And Output certutil -d sql:$HOME/.pki/nssdb -A -t TC -f password.ca -n "Harbor" -i ./harbor_ca.crt + ${rc} ${out}= Run And Return Rc And Output certutil -d sql:$HOME/.pki/nssdb -A -t TC -f password${rand}.ca -n "Harbor${rand}" -i ./harbor_ca.crt Log ${out} Should Be Equal As Integers ${rc} 0 diff --git a/tests/resources/Nightly-Util.robot b/tests/resources/Nightly-Util.robot index af5d150ff..f3c0827f2 100644 --- a/tests/resources/Nightly-Util.robot +++ b/tests/resources/Nightly-Util.robot @@ -21,9 +21,12 @@ ${SSH_USER} root *** Keywords *** Nightly Test Setup - [Arguments] ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} + [Arguments] ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} ${ip1}==${EMPTY} Run Keyword CA setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} - Run Keyword Prepare Docker Cert ${ip} + Run Keyword Prepare Docker Cert ${ip} + Run Keyword And Ignore Error Run rm harbor_ca.crt + Run Keyword If '${ip1}' != '${EMPTY}' CA setup ${ip1} ${SSH_PWD} ${HARBOR_PASSWORD} + Run Keyword If '${ip1}' != '${EMPTY}' Prepare Docker Cert ${ip1} Run Keyword Start Docker Daemon Locally CA Setup @@ -36,6 +39,11 @@ CA Setup Generate Certificate Authority For Chrome ${HARBOR_PASSWORD} Collect Nightly Logs + [Arguments] ${ip} ${SSH_PWD} ${ip1}==${EMPTY} + Run Keyword Collect Logs ${ip} ${SSH_PWD} + Run Keyword If '${ip1}' != '${EMPTY}' Collect Logs ${ip1} ${SSH_PWD} + +Collect Logs [Arguments] ${ip} ${SSH_PWD} Open Connection ${ip} Login ${SSH_USER} ${SSH_PWD} @@ -50,4 +58,5 @@ Collect Nightly Logs 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 + Run rename 's/^/${ip}/' *.log Close All Connections \ No newline at end of file diff --git a/tests/robot-cases/Group11-Nightly/Nightly.robot b/tests/robot-cases/Group11-Nightly/Nightly.robot index 4f2683e8f..880d7120d 100644 --- a/tests/robot-cases/Group11-Nightly/Nightly.robot +++ b/tests/robot-cases/Group11-Nightly/Nightly.robot @@ -15,8 +15,8 @@ *** 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} +Suite Setup Nightly Test Setup ${ip} ${SSH_PWD} ${HARBOR_PASSWORD} ${ip1} +Suite Teardown Collect Nightly Logs ${ip} ${SSH_PWD} ${ip1} Default Tags Nightly *** Variables ***