Add OVA CI scripts

This commit is contained in:
wangyan 2017-11-03 03:34:51 -07:00
parent 10199c10ef
commit 8df0dae5ca
6 changed files with 185 additions and 44 deletions

36
.drone.ova.yml Normal file
View File

@ -0,0 +1,36 @@
# Harbor OVA drone.
---
workspace:
base: /drone
path: src/github.com/vmware/harbor
pipeline:
clone:
image: plugins/git
tags: true
recursive: false
integration-test-on-pr:
image: vmware/harbor-e2e-engine:1.39
pull: true
privileged: true
environment:
BIN: bin
GOPATH: /drone
SHELL: /bin/bash
LOG_TEMP_DIR: install-logs
HARBOR_ADMIN: ${HARBOR_ADMIN}
HARBOR_PASSWORD: ${HARBOR_PASSWORD}
DHCP: ${DHCP}
PROTOCOL: ${PROTOCOL}
USER: ${USER}
PASSWORD: ${PASSWORD}
HOST: ${HOST}
DATASTORE: ${DATASTORE}
CLUSTER: ${CLUSTER}
DATACENTER: ${DATACERTER}
commands:
- tests/integration_ova.sh
when:
status: success

36
tests/integration_ova.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
# Copyright 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.
#
set -x
gsutil version -l
set +x
container_ip=`ip addr s eth0 |grep "inet "|awk '{print $2}' |awk -F "/" '{print $1}'`
echo $container_ip
ova_url="$(python /auto-ova/ova.py)"
echo $ova_url
## --------------------------------------------- Init Env -------------------------------------------------
# Start Xvfb for Chrome headlesss
Xvfb -ac :99 -screen 0 1280x1024x16 & export DISPLAY=:99
## --------------------------------------------- Run -------------------------------------------------
pybot -v ip:$container_ip -v ova_url:$ova_url --include OVA tests/robot-cases/Group5-OVA-install-config/5-00-OVA-BAT.robot
## --------------------------------------------- Tear Down -------------------------------------------------
rc="$?"
echo $rc
exit $rc

View File

@ -148,3 +148,16 @@ Compile and Up Harbor With Source Code
Log ${output}
Should Be Equal As Integers ${rc} 0
Sleep 20
Wait for Harbor Ready
[Arguments] ${protocol} ${HARBOR_IP}
Log To Console Waiting for Harbor to Come Up...
:FOR ${i} IN RANGE 20
\ ${out}= Run curl -k ${protocol}://${HARBOR_IP}
\ Log ${out}
\ ${status}= Run Keyword And Return Status Should Not Contain ${out} 502 Bad Gateway
\ ${status}= Run Keyword If ${status} Run Keyword And Return Status Should Not Contain ${out} Connection refused
\ ${status}= Run Keyword If ${status} Run Keyword And Return Status Should Contain ${out} <title>Harbor</title>
\ Return From Keyword If ${status} ${HARBOR_IP}
\ Sleep 30s
Fail Harbor failed to come up properly!

View File

@ -17,9 +17,9 @@ Documentation This resource provides any keywords related to Unified OVA
*** Variables ***
${ova_root_pwd} ova-test-root-pwd
${ova_appliance_options} --prop:appliance.root_pwd=${ova_root_pwd} --prop:appliance.permit_root_login=True
${ova_appliance_options} --prop:root_pwd=${ova_root_pwd} --prop:permit_root_login=true
${ova_target_vm_name} vic-unified-ova-integration-test
${ova_target_vm_name} harbor-unified-ova-integration-test
${ovftool_options} --noSSLVerify --acceptAllEulas --name=${ova_target_vm_name} --diskMode=thin --powerOn --X:waitForIp --X:injectOvfEnv --X:enableHiddenProperties
${ova_network_ip0} 10.17.109.207
@ -32,7 +32,7 @@ ${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:registry.admin_password=${ova_harbor_admin_password} --prop:registry.db_password=${ova_harbor_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}
@ -41,11 +41,8 @@ ${tls_not_disabled} False
*** Keywords ***
# Requires vc credential for govc
Deploy VIC-OVA To Test Server
[Arguments] ${dhcp}=False ${build}=False ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD} ${host}=%{TEST_URL} ${datastore}=%{TEST_DATASTORE} ${cluster}=%{TEST_RESOURCE} ${datacenter}=%{TEST_DATACENTER}
Run Keyword if ${build} Build Unified OVA
${rev}= Run git rev-parse --short HEAD
Set Test Variable ${ova_path} bin/vic-1.1.0-${rev}.ova
Deploy Harbor-OVA To Test Server
[Arguments] ${dhcp} ${protocol} ${build} ${user} ${password} ${ova_path} ${host} ${datastore} ${cluster} ${datacenter}
Log To Console \nCleanup environment...
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
@ -56,16 +53,31 @@ Deploy VIC-OVA To Test Server
... ELSE Log To Console ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
${out}= Run Keyword If ${dhcp} Run ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
... ELSE Run ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${datacenter}/host/${cluster}'
Log ${out}
Should Contain ${out} Received IP address:
Should Not Contain ${out} None
Log To Console \n${out}
@{out}= Split To Lines ${out}
Should Contain @{out}[-1] Completed successfully
${out}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc ls /ha-datacenter/host/cls/
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/ha-datacenter/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Log To Console \nUnified OVA is deployed successfully
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc host.esxcli -host.ip=${esx1-ip} system settings advanced set -o /Net/GuestIPHack -i 1
${ip}= Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.ip -esxcli harbor-unified-ova-integration-test
Set Environment Variable HARBOR_IP ${ip}
Log To Console \nHarbor IP: %{HARBOR_IP}
Wait for Harbor Ready ${protocol} %{HARBOR_IP}
[Return] %{HARBOR_IP}
# Requires vc credential for govc
Cleanup VIC-OVA On Test Server
Cleanup Harbor-OVA On Test Server
[Arguments] ${url}=%{GOVC_URL} ${username}=%{GOVC_USERNAME} ${password}=%{GOVC_PASSWORD}
${rc} ${output}= Run And Return Rc And Output GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${ova_target_vm_name}
Log ${output}
@ -82,8 +94,4 @@ Build Unified OVA
Log ${out}
@{out}= Split To Lines ${out}
Should Not Contain @{out}[-1] Error
Log To Console \nUnified OVA is built successfully
Remove OVA Artifacts Locally
${rev}= Run git rev-parse --short HEAD
Remove Files bin/vic-1.1.0-${rev}.ova bin/vic-1.1.0-${rev}.ovf bin/vic-1.1.0-${rev}.mk bin/vic-1.1.0-${rev}-disk*.vmdk
Log To Console \nUnified OVA is built successfully

View File

@ -18,28 +18,23 @@ Documentation This resource contains any keywords dealing with operations being
*** Keywords ***
Power On VM OOB
[Arguments] ${vm}
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc vm.power -on %{VCH-NAME}/"${vm}"
Run Keyword If '%{HOST_TYPE}' == 'VC' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc vm.power -on "${vm}"
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output 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}
Power Off VM OOB
[Arguments] ${vm}
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc vm.power -off %{VCH-NAME}/"${vm}"
Run Keyword If '%{HOST_TYPE}' == 'VC' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc vm.power -off "${vm}"
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output 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}"
Destroy VM OOB
[Arguments] ${vm}
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run And Return Rc And Output govc vm.destroy %{VCH-NAME}/"*-${vm}"
Run Keyword If '%{HOST_TYPE}' == 'VC' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run And Return Rc And Output govc vm.destroy "*-${vm}"
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output govc vm.destroy "*-${vm}"
Should Be Equal As Integers ${rc} 0
Put Host Into Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.enter -host.ip=%{TEST_URL}
@ -56,13 +51,19 @@ Reboot VM
Power On VM OOB ${vm}
Log To Console ${vm} Powered On
Reset VM
[Arguments] ${vm}
${rc} ${output}= Run And Return Rc And Output 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
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc vm.info %{VCH-NAME}/${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'VC' Set Test Variable ${out} ${ret}
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc vm.info ${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Test Variable ${out} ${ret}
\ ${ret}= Run govc vm.info ${vm}
\ Set Test Variable ${out} ${ret}
\ ${status}= Run Keyword And Return Status Should Contain ${out} poweredOn
\ Return From Keyword If ${status}
\ Sleep 1
@ -71,10 +72,8 @@ Wait Until VM Powers On
Wait Until VM Powers Off
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc vm.info %{VCH-NAME}/${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'VC' Set Test Variable ${out} ${ret}
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc vm.info ${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Test Variable ${out} ${ret}
\ ${ret}= Run govc vm.info ${vm}
\ Set Test Variable ${out} ${ret}
\ ${status}= Run Keyword And Return Status Should Contain ${out} poweredOff
\ Return From Keyword If ${status}
\ Sleep 1
@ -83,10 +82,8 @@ Wait Until VM Powers Off
Wait Until VM Is Destroyed
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'VC' Run govc ls vm/%{VCH-NAME}/${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'VC' Set Test Variable ${out} ${ret}
\ ${ret}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc ls vm/${vm}
\ Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Test Variable ${out} ${ret}
\ ${ret}= Run govc ls vm/${vm}
\ Set Test Variable ${out} ${ret}
\ ${status}= Run Keyword And Return Status Should Be Empty ${out}
\ Return From Keyword If ${status}
\ Sleep 1
@ -215,4 +212,4 @@ Enable Host Firewall
Run govc host.esxcli network firewall set --enabled true
Disable Host Firewall
Run govc host.esxcli network firewall set --enabled false
Run govc host.esxcli network firewall set --enabled false

View File

@ -0,0 +1,51 @@
// 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
Default Tags OVA
*** Test Cases ***
Test Case - Deploy OVA
Deploy Harbor-OVA To Test Server %{DHCP} %{PROTOCOL} False %{USER} %{PASSWORD} ${ova_url} %{HOST} %{DATASTORE} %{CLUSTER} %{DATACENTER}
Test Case - Sign With Admin Modified Pwd
Open Connection %{HARBOR_IP}
Login root ova-test-root-pwd
SSHLibrary.Get File /data/ca_download/harbor_ca.crt
Close All Connections
Generate Certificate Authority For Chrome %{HARBOR_PASSWORD}
Init Chrome Driver
Sign In Harbor https://%{HARBOR_IP} admin %{HARBOR_ADMIN_PASSWORD}
Close Browser
Test Case - Push Image
Init Chrome Driver
Start Docker Daemon Locally
${d}= Get Current Date result_format=%m%s
Create An New User url=https://%{HARBOR_IP} username=tester${d} email=tester${d}@vmware.com realname=harbortest newPassword=Test1@34 comment=harbortest
Create An New Project test${d}
Push image %{HARBOR_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 - OVA reboot
Reboot VM harbor-unified-ova-integration-test
Wait for Harbor Ready %{protocol} %{HARBOR_IP}
Test Case - OVA reset
Reset VM harbor-unified-ova-integration-test
Wait for Harbor Ready %{protocol} %{HARBOR_IP}