VMware vSphere Integrated Containers provider (#206)

* Add Virtual Kubelet provider for VIC

Initial virtual kubelet provider for VMware VIC.  This provider currently
handles creating and starting of a pod VM via the VIC portlayer and persona
server.  Image store handling via the VIC persona server.  This provider
currently requires the feature/wolfpack branch of VIC.

* Added pod stop and delete.  Also added node capacity.

Added the ability to stop and delete pod VMs via VIC.  Also retrieve
node capacity information from the VCH.

* Cleanup and readme file

Some file clean up and added a Readme.md markdown file for the VIC
provider.

* Cleaned up errors, added function comments, moved operation code

1. Cleaned up error handling.  Set standard for creating errors.
2. Added method prototype comments for all interface functions.
3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder.

* Add mocking code and unit tests for podcache, podcreator, and podstarter

Used the unit test framework used in VIC to handle assertions in the provider's
unit test.  Mocking code generated using OSS project mockery, which is compatible
with the testify assertion framework.

* Vendored packages for the VIC provider

Requires feature/wolfpack branch of VIC and a few specific commit sha of
projects used within VIC.

* Implementation of POD Stopper and Deleter unit tests (#4)

* Updated files for initial PR
This commit is contained in:
Loc Nguyen
2018-06-04 15:41:32 -07:00
committed by Ria Bhatia
parent 98a111e8b7
commit 513cebe7b7
6296 changed files with 1123685 additions and 8 deletions

View File

@@ -0,0 +1,105 @@
# 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
*** Settings ***
Documentation This resource contains all keywords related to creating, deleting, maintaining an instance of Admiral
Library Selenium2Library 5 5
Library OperatingSystem
*** Keywords ***
Install Admiral
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run -d -p 8282:8282 --name admiral vmware/admiral:vic_v1.1.0
Should Be Equal As Integers 0 ${rc}
Set Environment Variable ADMIRAL_IP %{VCH-IP}:8282
:FOR ${idx} IN RANGE 0 10
\ ${out}= Run curl %{ADMIRAL_IP}
\ ${status}= Run Keyword And Return Status Should Contain ${out} <body class="admiral-default">
\ Return From Keyword If ${status}
\ Sleep 5
Fail Install Admiral failed: Admiral endpoint failed to respond to curl
Cleanup Admiral
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rm -f admiral
Should Be Equal As Integers 0 ${rc}
Login To Admiral
[Arguments] ${url}=localhost:8282 ${browser}=chrome
Open Browser ${url} ${browser}
Maximize Browser Window
Wait Until Page Contains Welcome!
Wait Until Page Contains This is the place for you to create, provision, manage and monitor containerized applications.
Wait Until Element Is Visible css=button.btn.btn-primary.enter-btn
Wait Until Element Is Enabled css=button.btn.btn-primary.enter-btn
Click Button css=button.btn.btn-primary.enter-btn
Wait Until Element Is Visible css=div.query-search-input-controls.form-control
Wait Until Element Is Enabled css=div.query-search-input-controls.form-control
Wait Until Element Is Visible css=a.btn.btn-primary.addHost-btn
Wait Until Element Is Enabled css=a.btn.btn-primary.addHost-btn
Add Host To Admiral
[Arguments] ${address} ${credentials}=${EMPTY}
Wait Until Element Is Visible css=a[data-cmd="navigation-hosts"]
Wait Until Element Is Enabled css=a[data-cmd="navigation-hosts"]
Click Element css=a[data-cmd="navigation-hosts"]
Wait Until Element Is Visible css=div.query-search-input-controls.form-control
Wait Until Element Is Enabled css=div.query-search-input-controls.form-control
Wait Until Element Is Visible css=a.btn.btn-primary.addHost-btn
Wait Until Element Is Enabled css=a.btn.btn-primary.addHost-btn
Click Element css=a.btn.btn-primary.addHost-btn
Wait Until Page Contains Add Host
Wait Until Element Is Visible address
Wait Until Element Is Enabled address
Wait Until Element Is Visible credential
Wait Until Element Is Enabled credential
Input Text css=#address > input.form-control ${address}
Select From List css=#hostType > div.select > select VCH
Run Keyword If '${credentials}' != '${EMPTY}' Click Element css=#credential > div.form-control > div.dropdown > button.dropdown-toggle
Run Keyword If '${credentials}' != '${EMPTY}' Click Element css=a[data-name=${credentials}]
Wait Until Element Is Visible css=a.btn.verifyHost
Wait Until Element Is Enabled css=a.btn.verifyHost
Click Element css=a.btn.verifyHost
Wait Until Page Contains Verified successfully!
Wait Until Element Is Visible css=button.btn.btn-primary.saveHost
Wait Until Element Is Enabled css=button.btn.btn-primary.saveHost
Click Button css=button.btn.btn-primary.saveHost
Wait Until Element Is Visible css=div.status.ON
Wait Until Element Is Enabled css=div.status.ON
Add Project to Admiral
[Arguments] ${name}
Wait Until Element Is Visible css=a[data-cmd="navigation-placements"]
Wait Until Element Is Enabled css=a[data-cmd="navigation-placements"]
Click Element css=a[data-cmd="navigation-placements"]
Wait Until Element Is Visible css=div.right-context-panel > div.toolbar > div:nth-child(2) > a
Wait Until Element Is Enabled css=div.right-context-panel > div.toolbar > div:nth-child(2) > a
Click Element css=div.right-context-panel > div.toolbar > div:nth-child(2) > a
Wait Until Page Contains Project
Wait Until Element Is Visible css=div.right-context-panel > div.content > div > div.list-holder > div.inline-editable-list-holder > div.inline-editable-list > div.toolbar > a.new-item
Wait Until Element Is Enabled css=div.right-context-panel > div.content > div > div.list-holder > div.inline-editable-list-holder > div.inline-editable-list > div.toolbar > a.new-item
Click Element css=div.right-context-panel > div.content > div > div.list-holder > div.inline-editable-list-holder > div.inline-editable-list > div.toolbar > a.new-item
Input Text css=input.name-input ${name}
Click Element css=button.btn.btn-primary.inline-edit-save
Table Should Contain css=div.right-context-panel > div.content > div > div > div > div > table ${name}

View File

@@ -0,0 +1,105 @@
# 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
*** Settings ***
Documentation This resource contains keywords related to creating and using certificates. Requires scripts in infra/integration-image/scripts be available in PATH
*** Keywords ***
Generate Certificate Authority
# Generates CA (private/ca.key.pem, certs/ca.cert.pem, certs/STARK_ENTERPRISES_ROOT_CA.crt) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${OUT_DIR}=/root/ca
Log To Console Generating Certificate Authority
${rc} ${out}= Run And Return Rc And Output generate-ca.sh -c ${CA_NAME} -d ${OUT_DIR}
Log ${out}
Should Be Equal As Integers ${rc} 0
Generate Wildcard Server Certificate
# Generates key and signs with CA for *.DOMAIN (csr/*.DOMAIN.csr.pem,
# private/*.DOMAIN.key.pem, certs/*.DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${DOMAIN}=%{DOMAIN} ${OUT_DIR}=/root/ca ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA
Log To Console Generating Wildcard Server Certificate
Run Keyword Generate Server Key And CSR *.${DOMAIN} ${OUT_DIR}
Run Keyword Sign Server CSR ${CA_NAME} *.${DOMAIN} ${OUT_DIR}
Run Keyword Create Certificate Bundle CA_NAME=${CA_NAME} SRC_DIR=${OUT_DIR} CN=*.${DOMAIN}
${out}= Run ls -al ${OUT_DIR}/csr
Log ${out}
${out}= Run ls -al ${OUT_DIR}/private
Log ${out}
${out}= Run ls -al ${OUT_DIR}/certs
Log ${out}
Generate Server Key And CSR
# Generates key and CSR (private/DOMAIN.key.pem, csr/DOMAIN.csr.pem) in OUT_DIR
[Arguments] ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Generating Server Key And CSR
${out}= Run generate-server-key-csr.sh -d ${OUT_DIR} -n ${CN}
Log ${out}
Sign Server CSR
# Generates certificate signed by CA (certs/DOMAIN.cert.pem) in OUT_DIR
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${CN}=%{DOMAIN} ${OUT_DIR}=/root/ca
Log To Console Signing Server CSR
${out}= Run sign-csr.sh -c ${CA_NAME} -d ${OUT_DIR} -n ${CN}
Log ${out}
Trust Certificate Authority
# Installs root certificate into trust store on Debian based distro
[Arguments] ${CRT_FILE}=/root/ca/certs/STARK_ENTERPRISES_ROOT_CA.crt
Log To Console Installing CA
${rc} ${out}= Run And Return Rc And Output ubuntu-install-ca.sh -f ${CRT_FILE}
Should Be Equal As Integers ${rc} 0
Log ${out}
Reload Default Certificate Authorities
# Reloads default certificates into trust store on Debian based distro
# Removes all user provided CAs
Log To Console Reloading Default CAs
${rc} ${out}= Run And Return Rc And Output ubuntu-reload-cas.sh
Should Be Equal As Integers ${rc} 0
Log ${out}
Create Certificate Bundle
[Arguments] ${CA_NAME}=STARK_ENTERPRISES_ROOT_CA ${SRC_DIR}=/root/ca ${OUT_FILE}=/root/ca/cert-bundle.tgz ${CN}=%{DOMAIN} ${TMP_DIR}=/root/ca/bundle
${rc} ${out}= Run And Return Rc And Output bundle-certs.sh -c ${CA_NAME} -d ${SRC_DIR} -f ${OUT_FILE} -n ${CN} -o ${TMP_DIR}
Should Be Equal As Integers ${rc} 0
Log ${out}
Get Certificate Authority CRT
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
[Arguments] ${CA_CRT}=STARK_ENTERPRISES_ROOT_CA.crt ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${CA_CRT}
[Return] ${out}
Get Server Certificate
# Return ascii armored certificate from file e.g. `-----BEGIN CERTIFICATE-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.cert.pem ${DIR}=/root/ca/certs
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}
Get Server Key
# Return ascii armored key from file e.g. `-----BEGIN RSA PRIVATE KEY-----`
# PEM must be provided if using a wildcard cert not specified by DOMAIN
[Arguments] ${PEM}=%{DOMAIN}.key.pem ${DIR}=/root/ca/private
${out}= Run cat ${DIR}/${PEM}
[Return] ${out}

View File

@@ -0,0 +1,318 @@
# Copyright 2016-2018 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 helper functions for docker operations
Library OperatingSystem
Library Process
*** Keywords ***
Run Docker Info
[Arguments] ${docker-params}
${rc}= Run And Return Rc docker ${docker-params} info
Should Be Equal As Integers ${rc} 0
Pull image
[Arguments] ${image}
[Timeout] 10 minutes
Log To Console \nRunning docker pull ${image}...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} pull ${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Digest:
Should Contain ${output} Status:
Should Not Contain ${output} No such image:
Wait Until Container Stops
[Arguments] ${container} ${sleep-time}=1
:FOR ${idx} IN RANGE 0 60
\ ${out}= Run docker %{VCH-PARAMS} inspect -f '{{.State.Running}}' ${container}
\ Return From Keyword If '${out}' == 'false'
\ Sleep ${sleep-time}
Fail Container did not stop within 60 seconds
Hit Nginx Endpoint
[Arguments] ${vch-ip} ${port}
${rc} ${output}= Run And Return Rc And Output wget ${vch-ip}:${port}
Should Be Equal As Integers ${rc} 0
Get Container IP
[Arguments] ${docker-params} ${id} ${network}=bridge ${dockercmd}=docker
${rc} ${ip}= Run And Return Rc And Output ${dockercmd} ${docker-params} inspect --format='{{(index .NetworkSettings.Networks "${network}").IPAddress}}' ${id}
Should Be Equal As Integers ${rc} 0
[Return] ${ip}
Get IP Address of Container
[Arguments] ${container}
${ip}= Run docker %{VCH-PARAMS} inspect ${container} | jq -r ".[].NetworkSettings.Networks.bridge.IPAddress"
[Return] ${ip}
# The local dind version is embedded in Dockerfile
# docker:1.13-dind
# If you are running this keyword in a container, make sure it is run with --privileged turned on
Start Docker Daemon Locally
[Arguments] ${dockerd-params} ${dockerd-path}=/usr/local/bin/dockerd-entrypoint.sh ${log}=./daemon-local.log
OperatingSystem.File Should Exist ${dockerd-path}
Log To Console Starting docker daemon locally
${pid}= Run pidof dockerd
Run Keyword If '${pid}' != '${EMPTY}' Run kill -9 ${pid}
Run Keyword If '${pid}' != '${EMPTY}' Log To Console \nKilling local dangling dockerd process: ${pid}
${handle}= Start Process ${dockerd-path} ${dockerd-params} >${log} 2>&1 shell=True
Process Should Be Running ${handle}
:FOR ${IDX} IN RANGE 5
\ ${pid}= Run pidof dockerd
\ Run Keyword If '${pid}' != '${EMPTY}' Set Test Variable ${dockerd-pid} ${pid}
\ Exit For Loop If '${pid}' != '${EMPTY}'
\ Sleep 1s
Should Not Be Equal '${dockerd-pid}' '${EMPTY}'
:FOR ${IDX} IN RANGE 10
\ ${rc}= Run And Return Rc DOCKER_API_VERSION=1.23 docker -H unix:///var/run/docker-local.sock ps
\ Return From Keyword If '${rc}' == '0' ${handle} ${dockerd-pid}
\ Sleep 1s
Fail Failed to initialize local dockerd
[Return] ${handle} ${dockerd-pid}
Kill Local Docker Daemon
[Arguments] ${handle} ${dockerd-pid}
Terminate Process ${handle}
Process Should Be Stopped ${handle}
${rc}= Run And Return Rc kill -9 ${dockerd-pid}
Should Be Equal As Integers ${rc} 0
Get container shortID
[Arguments] ${id}
${shortID}= Get Substring ${id} 0 12
[Return] ${shortID}
Get container name
[Arguments] ${id}
${rc} ${name}= Run And Return Rc And Output docker %{VCH-PARAMS} inspect --format='{{.Name}}' ${id}
Should Be Equal As Integers ${rc} 0
${name}= Get Substring ${name} 1
[Return] ${name}
Get VM display name
[Arguments] ${id}
${name}= Get container name ${id}
${shortID}= Get container shortID ${id}
[Return] ${name}-${shortID}
Verify Container Rename
[Arguments] ${oldname} ${newname} ${contID}
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a
Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${newname}
Should Not Contain ${output} ${oldname}
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} inspect -f '{{.Name}}' ${newname}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${newname}
${vmName}= Get VM display name ${contID}
${rc} ${output}= Run And Return Rc And Output govc vm.info ${vmname}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${vmName}
Run Regression Tests
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} pull ${busybox}
Should Be Equal As Integers ${rc} 0
# Pull an image that has been pulled already
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} pull ${busybox}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} images
Should Be Equal As Integers ${rc} 0
Should Contain ${output} busybox
${rc} ${container}= Run And Return Rc And Output docker %{VCH-PARAMS} create ${busybox} /bin/top
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} start ${container}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps
Should Be Equal As Integers ${rc} 0
Should Contain ${output} /bin/top
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} stop ${container}
Should Be Equal As Integers ${rc} 0
Wait Until Container Stops ${container}
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Exited
${vmName}= Get VM Display Name ${container}
Wait Until Keyword Succeeds 5x 10s Check For The Proper Log Files ${vmName}
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rm ${container}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} /bin/top
# Check for regression for #1265
${rc} ${container1}= Run And Return Rc And Output docker %{VCH-PARAMS} create -it ${busybox} /bin/top
Should Be Equal As Integers ${rc} 0
${rc} ${container2}= Run And Return Rc And Output docker %{VCH-PARAMS} create -it ${busybox}
Should Be Equal As Integers ${rc} 0
${shortname}= Get Substring ${container2} 1 12
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a
${lines}= Get Lines Containing String ${output} ${shortname}
Should Not Contain ${lines} /bin/top
${rc}= Run And Return Rc docker %{VCH-PARAMS} rm ${container1}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc docker %{VCH-PARAMS} rm ${container2}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rmi ${busybox}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} images
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} ${busybox}
Scrape Logs For The Password
Launch Container
[Arguments] ${name} ${network}=default ${dockercmd}=docker
${rc} ${output}= Run And Return Rc And Output ${dockercmd} %{VCH-PARAMS} run --name ${name} --net ${network} -itd busybox
Should Be Equal As Integers ${rc} 0
${id}= Get Line ${output} -1
${ip}= Get Container IP %{VCH-PARAMS} ${id} ${network} ${dockercmd}
[Return] ${id} ${ip}
Start Container and Exec Command
[Arguments] ${containerName} ${cmd}
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} start ${containerName}
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} Error
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} exec ${containerName} ${cmd}
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} Error
[Return] ${output}
Verify Volume Inspect Info
[Arguments] ${inspectedWhen} ${volTestContainer} ${checkList}
Log To Console \nContainer Mount Inspected ${inspectedWhen}
${rc} ${mountInfo}= Run And Return Rc And Output docker %{VCH-PARAMS} inspect -f '{{.Mounts}}' ${volTestContainer}
Should Be Equal As Integers ${rc} 0
:FOR ${item} IN @{checkList}
\ Should Contain ${mountInfo} ${item}
Log All Containers
${rc} ${out}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a
Run Keyword If ${rc} != 0 Log To Console Remaining containers - ${out}
Do Images Exist
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} images -q
${len}= Get Length ${output}
Return From Keyword If ${len} == 0 ${false}
[Return] ${true}
Do Containers Exist
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -a -q
${len}= Get Length ${output}
Return From Keyword If ${len} == 0 ${false}
[Return] ${true}
Do Volumes Exist
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} volume ls -q
${len}= Get Length ${output}
Return From Keyword If ${len} == 0 ${false}
[Return] ${true}
Do Networks Exist
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} network ls -q
${len}= Get Length ${output}
Return From Keyword If ${len} == 0 ${false}
[Return] ${true}
Remove All Containers
${exist}= Do Containers Exist
Run Keyword If ${exist} Log To Console Stopping and removing all containers from %{VCH-NAME}
Return From Keyword If ${exist} == ${false} 0
# Run Keyword If ${exist} Kill All Containers
Run Keyword If ${exist} Run docker %{VCH-PARAMS} rm -f $(docker %{VCH-PARAMS} ps -a -q)
${exist}= Do Containers Exist
Return From Keyword If ${exist} == ${false} 0
Run Keyword If ${exist} Log All Containers
[Return] 1
Stop All Containers
Run docker %{VCH-PARAMS} stop $(docker %{VCH-PARAMS} ps -q)
Kill All Containers
Run docker %{VCH-PARAMS} kill $(docker %{VCH-PARAMS} ps -q)
Remove All Images
${exist}= Do Images Exist
Run Keyword If ${exist} Log To Console Removing all images from %{VCH-NAME}
Return From Keyword If ${exist} == ${false} 0
Run Keyword If ${exist} Remove All Containers
Run Keyword If ${exist} Run docker %{VCH-PARAMS} rmi $(docker %{VCH-PARAMS} images -q)
${exist}= Do Images Exist
Return From Keyword If ${exist} == ${false} 0
[Return] 1
Remove All Volumes
${exist}= Do Volumes Exist
Run Keyword If ${exist} Log To Console Removing all volumes from %{VCH-NAME}
Return From Keyword If ${exist} == ${false} 0
Run Keyword If ${exist} Run docker %{VCH-PARAMS} volume rm $(docker %{VCH-PARAMS} volume ls -q)
${exist}= Do Volumes Exist
Return From Keyword If ${exist} == ${false} 0
[Return] 1
Remove All Container Networks
${exist}= Do Networks Exist
Run Keyword If ${exist} Log To Console Removing all container networks from %{VCH-NAME}
Return From Keyword If ${exist} == ${false} 0
Run Keyword If ${exist} Run docker %{VCH-PARAMS} network rm $(docker %{VCH-PARAMS} network ls -q)
${exist}= Do Networks Exist
Return From Keyword If ${exist} == ${false} 0
[Return] 1
Add List To Dictionary
[Arguments] ${dict} ${list}
: FOR ${item} IN @{list}
\ Set To Dictionary ${dict} ${item} 1
List Existing Images On VCH
# Get list of image IDs
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} images -q
${len}= Get Length ${output}
Run Keyword If ${len} != 0 Log To Console Found images on %{VCH-NAME}:
${image_ids}= Run Keyword If ${rc} == 0 Split String ${output}
${tags_dict}= Create Dictionary
: FOR ${id} IN @{image_ids}
\ ${rc} ${repotags}= Run And Return Rc And Output docker %{VCH-PARAMS} inspect --format='{{.RepoTags}}' --type=image ${id}
\ ${clean_tags} Strip String ${repotags} characters=[]
\ ${tags}= Split String ${clean_tags}
\ Add List To Dictionary ${tags_dict} ${tags}
: FOR ${tag} IN @{tags_dict.keys()}
\ Log To Console \t${tag}
List Running Containers On VCH
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} ps -q
Log To Console ${EMPTY}
${len}= Get Length ${output}
Run Keyword If ${len} != 0 Log To Console Found running containers on %{VCH-NAME}:
... ELSE Log To Console No running containers on %{VCH-NAME}
Return From Keyword If ${len} == 0
${cids}= Run Keyword If ${len} != 0 Split String ${output}
: FOR ${id} IN @{cids}
\ Log To Console \t${id}

View File

@@ -0,0 +1,29 @@
# 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 contains any keywords related to using the Drone CI Build System
*** Keywords ***
Get State Of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num} --format {{.Status}}
[Return] ${out}
Get Title of Drone Build
[Arguments] ${num}
Return From Keyword If '${num}' == '0' local
${out}= Run drone build info vmware/vic ${num} --format {{ .Message }}
[Return] ${out}

View File

@@ -0,0 +1,47 @@
# 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 keywords to interact with Github
*** Keywords ***
Get State Of Github Issue
[Arguments] ${num}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/repos/vmware/vic/issues/${num}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
\ Exit For Loop If '${status}'
\ Sleep 1
Should Be Equal ${result.status_code} ${200}
${status}= Get From Dictionary ${result.json()} state
[Return] ${status}
Post Comment To Github Issue
[Arguments] ${num} ${comment}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Post https://api.github.com/repos/vmware/vic/issues/${num}/comments?access_token\=%{GITHUB_AUTOMATION_API_KEY} data={"body": "${comment}"}
\ Exit For Loop If '${status}'
\ Sleep 1
Should Be Equal ${result.status_code} ${201}
Check VMware Organization Membership
[Arguments] ${username}
[Tags] secret
:FOR ${idx} IN RANGE 0 5
\ ${status} ${result}= Run Keyword And Ignore Error Get https://api.github.com/orgs/vmware/members/${username}?access_token\=%{GITHUB_AUTOMATION_API_KEY}
\ Exit For Loop If '${status}'
\ Sleep 1
${isMember}= Run Keyword And Return Status Should Be Equal ${result.status_code} ${204}
[Return] ${isMember}

View File

@@ -0,0 +1,147 @@
# 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
*** Settings ***
Documentation This resource contains keywords which are helpful for using curl to test the vic-machine API.
*** Variables ***
${HTTP_PORT} 1337
${HTTPS_PORT} 31337
${RC} The return code of the last curl invocation
${OUTPUT} The output of the last curl invocation
${STATUS} The HTTP status of the last curl invocation
*** Keywords ***
Start VIC Machine Server
Start Process ./bin/vic-machine-server --port ${HTTP_PORT} --scheme http shell=True cwd=/go/src/github.com/vmware/vic
Get Path
[Arguments] ${path}
${RC} ${OUTPUT}= Run And Return Rc And Output curl -s -w "\n\%{http_code}\n" -X GET "http://127.0.0.1:${HTTP_PORT}/container/${PATH}"
${OUTPUT} ${STATUS}= Split String From Right ${OUTPUT} \n 1
Set Test Variable ${RC}
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}
Get Path Under Target
[Arguments] ${path} @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
${auth}= Evaluate base64.b64encode("%{TEST_USERNAME}:%{TEST_PASSWORD}") modules=base64
${RC} ${OUTPUT}= Run And Return Rc And Output curl -s -w "\n\%{http_code}\n" -X GET "http://127.0.0.1:${HTTP_PORT}/container/target/%{TEST_URL}/${PATH}?${fullQuery}" -H "Accept: application/json" -H "Authorization: Basic ${auth}"
${OUTPUT} ${STATUS}= Split String From Right ${OUTPUT} \n 1
Set Test Variable ${RC}
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}
Get Path Under Target Using Session
[Arguments] ${path} @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
${ticket}= Run govc vm.console %{VCH-NAME} | awk -F'[:@]' '{print $3}'
${RC} ${OUTPUT}= Run And Return Rc And Output curl -s -w "\n\%{http_code}\n" -X GET "http://127.0.0.1:${HTTP_PORT}/container/target/%{TEST_URL}/${path}?${fullQuery}" -H "Accept: application/json" -H "X-VMWARE-TICKET: ${ticket}"
${OUTPUT} ${STATUS}= Split String From Right ${OUTPUT} \n 1
Set Test Variable ${RC}
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}
Post Path Under Target
[Arguments] ${path} ${data} @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
${auth}= Evaluate base64.b64encode("%{TEST_USERNAME}:%{TEST_PASSWORD}") modules=base64
${RC} ${OUTPUT}= Run And Return Rc And Output curl -s -w "\n\%{http_code}\n" -X POST "http://127.0.0.1:${HTTP_PORT}/container/target/%{TEST_URL}/${PATH}?${fullQuery}" -H "Accept: application/json" -H "Authorization: Basic ${auth}" -H "Content-Type: application/json" --data ${data}
${OUTPUT} ${STATUS}= Split String From Right ${OUTPUT} \n 1
Set Test Variable ${RC}
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}
Delete Path Under Target
[Arguments] ${path} ${data}='' @{query}
${fullQuery}= Catenate SEPARATOR=& thumbprint=%{TEST_THUMBPRINT} @{query}
${auth}= Evaluate base64.b64encode("%{TEST_USERNAME}:%{TEST_PASSWORD}") modules=base64
${RC} ${OUTPUT}= Run And Return Rc And Output curl -s -w "\n\%{http_code}\n" -X DELETE "http://127.0.0.1:${HTTP_PORT}/container/target/%{TEST_URL}/${PATH}?${fullQuery}" -H "Accept: application/json" -H "Authorization: Basic ${auth}" -H "Content-Type: application/json" --data ${data}
${OUTPUT} ${STATUS}= Split String From Right ${OUTPUT} \n 1
Set Test Variable ${RC}
Set Test Variable ${OUTPUT}
Set Test Variable ${STATUS}
Verify Return Code
Should Be Equal As Integers ${RC} 0
Verify Status
[Arguments] ${expected}
Should Be Equal As Integers ${expected} ${STATUS}
Verify Status Ok
Verify Status 200
Verify Status Created
Verify Status 201
Verify Status Accepted
Verify Status 202
Verify Status Bad Request
Verify Status 400
Verify Status Not Found
Verify Status 404
Verify Status Unprocessable Entity
Verify Status 422
Verify Status Internal Server Error
Verify Status 500
Output Should Contain
[Arguments] ${expected}
Should Contain ${OUTPUT} ${expected}
Output Should Not Contain
[Arguments] ${expected}
Should Not Contain ${OUTPUT} ${expected}
Output Should Match Regexp
[Arguments] ${expected}
Should Match Regexp ${OUTPUT} ${expected}
Property Should Be Equal
[Arguments] ${jq} ${expected}
${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Be Equal ${actual} ${expected}
Property Should Not Be Equal
[Arguments] ${jq} ${expected}
${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Not Be Equal ${actual} ${expected}
Property Should Contain
[Arguments] ${jq} ${expected}
${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Contain ${actual} ${expected}
Property Should Not Be Empty
[Arguments] ${jq}
${actual}= Run echo '${OUTPUT}' | jq -r '${jq}'
Should Not Be Empty ${actual}

View File

@@ -0,0 +1,646 @@
# 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
Library Selenium2Library
Library OperatingSystem
*** Variables ***
${HARBOR_SHORT_VERSION} 0.5.0
${HARBOR_VERSION} harbor_0.5.0-9e4c90e
${MY_PROJECTS_TABLE} harbor-app > harbor-shell > clr-main-container > div > div > project > div > div > list-project
${MY_MEMBERS_TABLE} body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(2) > clr-datagrid > div > div > div > div.datagrid-body
${harbor_cert} getcert
${ova_harbor_admin_password} harbor-admin-passwd
*** Keywords ***
Secret Install Harbor To Test Server
[Tags] secret
[Arguments] ${name} ${protocol} ${verify} ${host} ${datastore} ${network}
${out}= Run ovftool --noSSLVerify --acceptAllEulas --datastore=${datastore} --name=${name} --net:"Network 1"='${network}' --diskMode=thin --powerOn --X:waitForIp --X:injectOvfEnv --X:enableHiddenProperties --prop:root_pwd=%{TEST_PASSWORD} --prop:harbor_admin_password=%{TEST_PASSWORD} --prop:db_password=%{TEST_PASSWORD} --prop:auth_mode=db_auth --prop:verify_remote_cert=${verify} --prop:protocol=${protocol} ${HARBOR_VERSION}.ova 'vi://%{TEST_USERNAME}:%{TEST_PASSWORD}@${host}'
[Return] ${out}
Install Harbor To Test Server
[Arguments] ${name}=harbor ${protocol}=http ${verify}=off ${host}=%{TEST_URL_ARRAY} ${datastore}=%{TEST_DATASTORE} ${network}=VM Network
Log To Console \nFetching harbor ova...
${status} ${message}= Run Keyword And Ignore Error OperatingSystem.File Should Exist ${HARBOR_VERSION}.ova
${out}= Run Keyword If '${status}' == 'FAIL' Run wget https://github.com/vmware/harbor/releases/download/${HARBOR_SHORT_VERSION}/${HARBOR_VERSION}.ova
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set DRONE_BUILD_NUMBER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable DRONE_BUILD_NUMBER 0
@{URLs}= Split String %{TEST_URL_ARRAY}
${len}= Get Length ${URLs}
${IDX}= Evaluate %{DRONE_BUILD_NUMBER} \% ${len}
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Suite Variable ${host} @{URLs}[${IDX}]
${rc} ${output}= Run Keyword If '%{HOST_TYPE}' == 'VC' Set Suite Variable ${host} @{URLs}[${IDX}]%{TEST_DATACENTER}/host/%{TEST_RESOURCE}
Log To Console \nDeploying ova...
${out}= Secret Install Harbor To Test Server ${name} ${protocol} ${verify} ${host} ${datastore} ${network}
Log ${out}
Should Contain ${out} Received IP address:
Should Not Contain ${out} None
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} Received IP address:
\ ${ip}= Run Keyword If ${status} Fetch From Right ${line} ${SPACE}
\ Run Keyword If ${status} Set Environment Variable HARBOR-IP ${ip}
\ Exit For Loop If ${status}
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 Any ${out} 502 Bad Gateway Connection refused Connection timed out
\ ${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!
[Return] %{HARBOR-IP}
Restart Docker With Insecure Registry Option
# Requires you to edit /etc/systemd/system/docker.service.d/overlay.conf or docker.conf to be:
# ExecStart=/bin/bash -c "usr/bin/docker daemon -H fd:// -s overlay $DOCKER_OPTS --insecure-registry='cat /tmp/harbor'"
# Requires to be run as root
${out}= Run systemctl daemon-reload
${out}= Run systemctl restart docker
Log ${out}
Install Harbor Self Signed Cert
# Need to provide permissions to /etc/docker folder for your user (sudo chmod -R 777 /etc/docker)
${out}= Run wget --tries=10 --connect-timeout=10 --auth-no-challenge --no-check-certificate --user admin --password ${ova_harbor_admin_password} https://%{HARBOR_IP}/api/systeminfo/getcert
Log ${out}
${out}= Run mkdir -p /etc/docker/certs.d/%{HARBOR_IP}
Move File getcert /etc/docker/certs.d/%{HARBOR_IP}/ca.crt
${out}= Run systemctl daemon-reload
${out}= Run systemctl restart docker
Log Into Harbor
[Arguments] ${user}=%{TEST_USERNAME} ${pw}=%{TEST_PASSWORD}
Maximize Browser Window
Input Text login_username ${user}
Input Text login_password ${pw}
Click button LOG IN
Wait Until Page Contains Projects
Wait Until Keyword Succeeds 5x 1 Page Should Contain Element xpath=/html/body/harbor-app/harbor-shell/clr-main-container[@class='main-container']/navigator/clr-header[@class='header-5 header']/div[@class='header-actions']/clr-dropdown[@class='dropdown bottom-right']/button[@class='nav-text dropdown-toggle']/span[contains(., '${user}')]
Create A New Project
[Arguments] ${name} ${public}=${true}
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > a.nav-link.active
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > a.nav-link.active
Click Element css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > a.nav-link.active
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > project > div > div > div:nth-child(2) > div.option-left > button
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > project > div > div > div:nth-child(2) > div.option-left > button
Click Element css=body > harbor-app > harbor-shell > clr-main-container > div > div > project > div > div > div:nth-child(2) > div.option-left > button
Wait Until Page Contains New Project
#Wait Until Element Is Visible name="Project Name"
#Wait Until Element Is Enabled name="Project Name"
Input Text create_project_name ${name}
#Wait Until Element Is Visible css=body > div.container-fluid.container-fluid-custom.ng-scope > div > div > div > add-project > div > form > div > div.col-xs-10.col-md-10 > div:nth-child(2) > label > input
#Wait Until Element Is Enabled css=body > div.container-fluid.container-fluid-custom.ng-scope > div > div > div > add-project > div > form > div > div.col-xs-10.col-md-10 > div:nth-child(2) > label > input
Sleep 1
Run Keyword If ${public} Select Checkbox css=body > harbor-app > harbor-shell > clr-main-container > div > div > project > div > div > div:nth-child(2) > div.option-left > create-project > clr-modal > div > div.modal-dialog > div > div.modal-body > form > section > div:nth-child(2) > div > label
Click Button OK
Wait Until Keyword Succeeds 5x 1 Table Should Contain css=${MY_PROJECTS_TABLE} ${name}
Create A New User
[Arguments] ${name} ${email} ${fullName} ${password} ${comments}
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > section > ul > li:nth-child(1) > a
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > section > ul > li:nth-child(1) > a
Click Element css=body > harbor-app > harbor-shell > clr-main-container > div > nav > section > section > ul > li:nth-child(1) > a
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > div.action-panel-pos > span:nth-child(1) > button
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > div.action-panel-pos > span:nth-child(1) > button
Click Element css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > div.action-panel-pos > span:nth-child(1) > button
Wait Until Element Is Visible username
Wait Until Element Is Enabled username
Wait Until Element Is Visible email
Wait Until Element Is Enabled email
Wait Until Element Is Visible realname
Wait Until Element Is Enabled realname
Wait Until Element Is Visible newPassword
Wait Until Element Is Enabled newPassword
Wait Until Element Is Visible confirmPassword
Wait Until Element Is Enabled confirmPassword
Wait Until Element Is Visible comment
Wait Until Element Is Enabled comment
Input Text username ${name}
Input Text email ${email}
Input Text realname ${fullName}
Input Text newPassword ${password}
Input Text confirmPassword ${password}
Input Text comment ${comments}
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > new-user-modal > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > new-user-modal > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Click Button css=body > harbor-app > harbor-shell > clr-main-container > div > div > harbor-user > div > div > new-user-modal > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Wait Until Page Contains New user created successfully.
Sleep 3
Toggle Admin Priviledges For User
[Arguments] ${user}
Wait Until Element Is Visible //a[@tag='admin_option']
Wait Until Element Is Enabled //a[@tag='admin_option']
Click Link Admin Options
Table Should Contain css=body > div.container-fluid.container-fluid-custom.ng-scope > div > div > div > list-user > div > div > div.pane > div.sub-pane > div.table-body-container > table ${user}
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()-1]/toggle-admin/button[not(contains(@class, 'ng-hide'))]
Wait Until Element Is Enabled xpath=//td[text()='test-user']/../td[last()-1]/toggle-admin/button[not(contains(@class, 'ng-hide'))]
${oldPublicity}= Get Text xpath=//td[text()='test-user']/../td[last()-1]/toggle-admin/button[not(contains(@class, 'ng-hide'))]
Click Button xpath=//td[text()='test-user']/../td[last()-1]/toggle-admin/button[not(contains(@class, 'ng-hide'))]
Sleep 1
Log to Console show result
${newPublicity}= Get Text xpath=//td[text()='test-user']/../td[last()-1]/toggle-admin/button[not(contains(@class, 'ng-hide'))]
Should Not Be Equal ${oldPublicity} ${newPublicity}
[return] ${newPublicity}
Delete A User
[Arguments] ${user}
Wait Until Element Is Visible //a[@tag='admin_option']
Wait Until Element Is Enabled //a[@tag='admin_option']
Click Link Admin Options
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a
Wait Until Element Is Enabled xpath=//td[text()='${user}']/../td[last()]/a
Click Link xpath=//td[text()='${user}']/../td[last()]/a
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Are you sure to delete the user "${user}" ?
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Sleep 1
Wait Until Keyword Succeeds 5x 1 Element Should Not Contain css=div.table-body-container > table ${user}
Search For A User
[Arguments] ${keyword}
Wait Until Element Is Visible //a[@tag='admin_option']
Wait Until Element Is Enabled //a[@tag='admin_option']
Click Link Admin Options
Wait Until Element Is Visible txtSearchInput
Wait Until Element Is Enabled txtSearchInput
Input Text txtSearchInput ${keyword}
Wait Until Element Is Visible css=span.input-group-btn > button
Wait Until Element Is Enabled css=span.input-group-btn > button
Click Button css=span.input-group-btn > button
Sleep 1
Wait Until Keyword Succeeds 5x 1 Table Should Contain css=div.table-body-container > table ${keyword}
# check all result contains the search keyword
Wait Until Element Is Visible xpath=//tbody/tr/td[1]
Wait Until Element Is Enabled xpath=//tbody/tr/td[1]
${rowNum}= Get Matching Xpath Count xpath=//tbody/tr/td[1]
${names}= Create List
${realRowNum}= Evaluate ${rowNum} + 1
:FOR ${idx} IN RANGE 1 ${realRowNum}
\ ${searchName}= Get Text xpath=//tbody/tr[${idx}]/td[1]
\ Should Match Regexp ${searchName} .*${keyword}.*
\ Append To List ${names} ${searchName}
[return] ${names}
Change User Information
[Arguments] ${email} ${fullName} ${comments}
Wait Until Element Is Visible css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Enabled css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Click Link css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Visible xpath=//a[contains(., 'Account Settings')]
Wait Until Element Is Enabled xpath=//a[contains(., 'Account Settings')]
Click Link xpath=//a[contains(., 'Account Settings')]
Wait Until Element Is Visible email
Wait Until Element Is Enabled email
Wait Until Element Is Visible fullName
Wait Until Element Is Enabled fullName
Wait Until Element Is Visible comments
Wait Until Element Is Enabled comments
Input Text email ${email}
Input Text fullName ${fullName}
Input Text comments ${comments}
Wait Until Element Is Visible xpath=//input[@value='Save']
Wait Until Element Is Enabled xpath=//input[@value='Save']
Click Element xpath=//input[@value='Save']
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) User profile has been changed successfully.
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Wait Until Page Contains Summary
Wait Until Page Contains My Projects:
Change User Password
[Arguments] ${password} ${newPassword}
Wait Until Element Is Visible css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Enabled css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Click Link css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Visible xpath=//a[contains(., 'Account Settings')]
Wait Until Element Is Enabled xpath=//a[contains(., 'Account Settings')]
Click Link xpath=//a[contains(., 'Account Settings')]
Wait Until Element Is Visible toggleChangePassword
Wait Until Element Is Enabled toggleChangePassword
Click Link toggleChangePassword
Wait Until Element Is Visible oldPassword
Wait Until Element Is Enabled oldPassword
Wait Until Element Is Visible password
Wait Until Element Is Enabled password
Wait Until Element Is Visible confirmPassword
Wait Until Element Is Enabled confirmPassword
Input Text oldPassword ${password}
Input Text password ${newPassword}
Input Text confirmPassword ${newPassword}
Wait Until Element Is Visible xpath=//input[@value='Save']
Wait Until Element Is Enabled xpath=//input[@value='Save']
Click Element xpath=//input[@value='Save']
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Password has been changed successfully.
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Wait Until Page Contains Summary
Wait Until Page Contains My Projects:
Logout Harbor
Wait Until Element Is Visible css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Enabled css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Click Link css=#bs-harbor-navbar-collapse-1 > optional-menu > div > a
Wait Until Element Is Visible xpath=//a[contains(., 'Log Out')]
Wait Until Element Is Enabled xpath=//a[contains(., 'Log Out')]
Click Link xpath=//a[contains(., 'Log Out')]
Wait Until Keyword Succeeds 5x 1 Page Should Contain Element xpath=//h4[text()='Login Now']
Sign up
[Arguments] ${name} ${email} ${fullName} ${password} ${comments}
Wait Until Element Is Visible xpath=//button[text()='Sign Up']
Wait Until Element Is Enabled xpath=//button[text()='Sign Up']
Click Button xpath=//button[text()='Sign Up']
Wait Until Keyword Succeeds 5x 1 Page Should Contain Element xpath=//button[text()='Sign Up']
Wait Until Element Is Visible username
Wait Until Element Is Enabled username
Wait Until Element Is Visible email
Wait Until Element Is Enabled email
Wait Until Element Is Visible fullName
Wait Until Element Is Enabled fullName
Wait Until Element Is Visible password
Wait Until Element Is Enabled password
Wait Until Element Is Visible confirmPassword
Wait Until Element Is Enabled confirmPassword
Wait Until Element Is Visible comments
Wait Until Element Is Enabled comments
Input Text username ${name}
Input Text email ${email}
Input Text fullName ${fullName}
Input Text password ${password}
Input Text confirmPassword ${password}
Input Text comments ${comments}
Wait Until Element Is Visible xpath=//button[text()='Sign Up']
Wait Until Element Is Enabled xpath=//button[text()='Sign Up']
Click Button xpath=//button[text()='Sign Up']
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Signed up successfully.
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Wait Until Keyword Succeeds 5x 1 Page Should Contain Element xpath=//h4[text()='Login Now']
Add A User To A Project
# role should be one of the strings : 'Project Admin'/'Developer'/'Guest'
[Arguments] ${user} ${project} ${role}
Click Link Projects
Wait Until Keyword Succeeds 5x 1 Table Should Contain css=${MY_PROJECTS_TABLE} ${project}
Wait Until Element Is Visible xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/project/div/div/list-project/clr-datagrid/div/div/div/div[2]/clr-dg-row[2]/clr-dg-cell[2]/a[text()='${project}']
Wait Until Element Is Enabled xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/project/div/div/list-project/clr-datagrid/div/div/div/div[2]/clr-dg-row[2]/clr-dg-cell[2]/a[text()='${project}']
Click Link xpath=/html/body/harbor-app/harbor-shell/clr-main-container/div/div/project/div/div/list-project/clr-datagrid/div/div/div/div[2]/clr-dg-row[2]/clr-dg-cell[2]/a[text()='${project}']
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > nav > ul > li:nth-child(2) > a
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > nav > ul > li:nth-child(2) > a
Click Link Members
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > button
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > button
Click Button css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > button
Wait Until Element Is Visible member_name
Wait Until Element Is Enabled member_name
Input Text member_name ${user}
Wait Until Element Is Visible css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > add-member > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Wait Until Element Is Enabled css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > add-member > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Click Button css=body > harbor-app > harbor-shell > clr-main-container > div > div > project-detail > ng-component > div > div:nth-child(1) > div > div.flex-xs-middle.option-left > add-member > clr-modal > div > div.modal-dialog > div > div.modal-footer > button.btn.btn-primary
Sleep 1
Wait Until Keyword Succeeds 5x 1 Table Should Contain css=${MY_MEMBERS_TABLE} ${user}
Remove A User From A Project
[Arguments] ${user} ${project}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Table Should Contain css=${MY_PROJECTS_TABLE} ${project}
Wait Until Element Is Visible xpath=//td/a[text()='${project}']
Wait Until Element Is Enabled xpath=//td/a[text()='${project}']
Click Link xpath=//td/a[text()='${project}']
Wait Until Element Is Visible xpath=//a[@tag='users']
Wait Until Element Is Enabled xpath=//a[@tag='users']
Click Link Users
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[last()]
Wait Until Element Is Enabled xpath=//td[text()='${user}']/../td[last()]/a[last()]
Click Link xpath=//td[text()='${user}']/../td[last()]/a[last()]
Sleep 1
Wait Until Keyword Succeeds 5x 1 Page Should Not Contain ${user}
Change A User's Role In A Project
[Arguments] ${user} ${project} ${role}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Wait Until Element Is Visible css=${MY_PROJECTS_TABLE}
Table Should Contain css=${MY_PROJECTS_TABLE} ${project}
Click Link xpath=//td/a[text()='${project}']
Wait Until Element Is Visible xpath=//a[@tag='users']
Wait Until Element Is Enabled xpath=//a[@tag='users']
Click Link Users
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Enabled xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]/span[@title='Edit']
Click Link xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Visible css=select.form-control
Wait Until Element Is Enabled css=select.form-control
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Enabled xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]/span[@title='Confirm']
Select From List By Label css=select ${role}
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]
Wait Until Element Is Enabled xpath=//td[text()='${user}']/../td[last()]/a[1]
Click Link xpath=//td[text()='${user}']/../td[last()]/a[1]
Sleep 1
Wait Until Element Is Visible xpath=//td[text()='${user}']/../td[last()]/a[1]/span[@title='Edit']
Wait Until Keyword Succeeds 5x 1 Page Should Contain Element //td[text()='${user}']/../td[2]/switch-role/ng-switch/span[text()='${role}']
Delete A Project
[Arguments] ${project}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Wait Until Element Is Visible xpath=//td/a[text()='${project}']/../../td[last()]/a
Wait Until Element Is Enabled xpath=//td/a[text()='${project}']/../../td[last()]/a
Click Link xpath=//td/a[text()='${project}']/../../td[last()]/a
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Are you sure to delete the project "${project}" ?
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Sleep 1
Wait Until Keyword Succeeds 5x 1 Element Should Not Contain css=${MY_PROJECTS_TABLE} ${project}
Search For A Project
# search for the project contains the keyword, and return all result as a list
[Arguments] ${keyword}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Wait Until Element Is Visible xpath=//input[@ng-model='vm.projectName']
Wait Until Element Is Enabled xpath=//input[@ng-model='vm.projectName']
Input Text xpath=//input[@ng-model='vm.projectName'] ${keyword}
Wait Until Element Is Visible css=span.input-group-btn > button
Wait Until Element Is Enabled css=span.input-group-btn > button
Click Button css=span.input-group-btn > button
Sleep 1
Wait Until Keyword Succeeds 5x 1 Table Should Contain css=${MY_PROJECTS_TABLE} ${keyword}
# check all result contains the search keyword
Wait Until Element Is Visible xpath=//tbody/tr/td[1]
Wait Until Element Is Enabled xpath=//tbody/tr/td[1]
${rowNum}= Get Matching Xpath Count xpath=//tbody/tr/td[1]
${names}= Create List
${realRowNum}= Evaluate ${rowNum} + 2
:FOR ${idx} IN RANGE 2 ${realRowNum}
\ ${searchName}= Get Text xpath=//tbody/tr[${idx}]/td[1]
\ Should Match Regexp ${searchName} .*${keyword}.*
\ Append To List ${names} ${searchName}
[return] ${names}
Delete Repository From Project
[Arguments] ${image} ${project}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Table Should Contain css=${MY_PROJECTS_TABLE} ${project}
Wait Until Element Is Visible xpath=//td/a[text()='${project}']
Wait Until Element Is Enabled xpath=//td/a[text()='${project}']
Click Link xpath=//td/a[text()='${project}']
Wait Until Element Is Visible xpath=//a[contains(., '${project}/${image}')]/../a[last()]
Wait Until Element Is Enabled xpath=//a[contains(., '${project}/${image}')]/../a[last()]
Click Link xpath=//a[contains(., '${project}/${image}')]/../a[last()]
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Delete repository "${project}/${image}" now?
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Sleep 1
Wait Until Keyword Succeeds 5x 1 Element Should Not Contain css=div.sub-pane ${project}/${image}
Delete Image From Project
[Arguments] ${image} ${tag} ${project}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Table Should Contain css=${MY_PROJECTS_TABLE} ${project}
Wait Until Element Is Visible xpath=//td/a[text()='${project}']
Wait Until Element Is Enabled xpath=//td/a[text()='${project}']
Click Link xpath=//td/a[text()='${project}']
Wait Until Element Is Visible xpath=//a[contains(., '${project}/${image}')]
Wait Until Element Is Enabled xpath=//a[contains(., '${project}/${image}')]
Click Link xpath=//a[contains(., '${project}/${image}')]
Wait Until Element Is Visible xpath=//a[contains(., '${project}/${image}')]/../../../div[2]/div/table/tbody/tr/td[text()='${tag}']/../td[last()]/a
Wait Until Element Is Enabled xpath=//a[contains(., '${project}/${image}')]/../../../div[2]/div/table/tbody/tr/td[text()='${tag}']/../td[last()]/a
Click Link xpath=//a[contains(., '${project}/${image}')]/../../../div[2]/div/table/tbody/tr/td[text()='${tag}']/../td[last()]/a
Wait Until Element Is Visible css=div.modal.fade.in > div > div > div:nth-child(2)
Wait Until Element Contains css=div.modal.fade.in > div > div > div:nth-child(2) Delete tag "${tag}" now?
Wait Until Element Is Enabled css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Click Button css=div.modal.fade.in > div > div > div:nth-child(3) > button:nth-child(1)
Sleep 1
# if it is last image in this repo, the repo will be deleted
${imageNum}= Get Text xpath=//a[contains(., '${project}/${image}')]/span[2]
Run Keyword If '${imageNum}'=='1' Wait Until Keyword Succeeds 5x 1 Element Should Not Contain css=div.sub-pane ${tag}
... Else Wait Until Keyword Succeeds 5x 1 Element Should Not Contain xpath=//a[contains(., '${project}/${image}')]/../../../div[2]/div/table/tbody ${tag}
Toggle Publicity On Project
[Arguments] ${project}
Wait Until Element Is Visible //a[@tag='project']
Wait Until Element Is Enabled //a[@tag='project']
Click Link Projects
Wait Until Element Is Visible xpath=//td/a[text()='${project}']/../../td[last()-1]/publicity-button/button
Wait Until Element Is Enabled xpath=//td/a[text()='${project}']/../../td[last()-1]/publicity-button/button
${oldPublicity}= Get Text xpath=//td/a[text()='${project}']/../../td[last()-1]/publicity-button/button
Click Button //td/a[text()='${project}']/../../td[last()-1]/publicity-button/button
Sleep 1
${newPublicity}= Get Text xpath=//td/a[text()='${project}']/../../td[last()-1]/publicity-button/button
Should Not Be Equal ${oldPublicity} ${newPublicity}
[return] ${newPublicity}
Go To HomePage
Wait Until Element Is Visible css=a.navbar-brand
Wait Until Element Is Enabled css=a.navbar-brand
Click Link css=a.navbar-brand
Wait Until Page Contains Summary
Wait Until Page Contains My Projects:
Check That VM Is Removed
[Arguments] ${container}
${rc} ${output}= Run And Return Rc And Output govc ls vm
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} ${container}
Check That Datastore Is Cleaned
[Arguments] ${container}
${rc} ${output}= Run And Return Rc And Output govc datastore.ls
Should Be Equal As Integers ${rc} 0
Should Not Contain ${output} ${container}
Create Project And Three Users For It
[Arguments] ${developer} ${developer2} ${developerEmail} ${developerEmail2} ${developerFullName} ${password} ${userPassword} ${comments} ${guest} ${developerRole} ${guestRole} ${project} ${public}=${False}
# 2 developers, 1 guest
Log To Console Create Three Users For Project..
Open Browser https://%{HARBOR_IP}/ chrome
Log To Console Opened
Log Into Harbor user=admin pw=${password}
Create A New Project name=${project} public=${False}
Log To Console Create a New User..
Create A New User name=${developer} email=${developerEmail} fullName=${developerFullName} password=${userPassword} comments=${comments}
Create A New User name=${guest} email=${guestEmail} fullName=${guestFullName} password=${userPassword} comments=${comments}
Create A New User name=${developer2} email=${developerEmail2} fullName=${developerFullName} password=${userPassword} comments=${comments}
Add A User To A Project user=${developer} project=${project} role=${developerRole}
Add A User To A Project user=${guest} project=${project} role=${guestRole}
Add A User To A Project user=${developer2} project=${project} role=${developerRole}
Log To Console User Creation Complete..
Close All Browsers
Basic Docker Command With Harbor
[Arguments] ${user} ${password} ${project} ${image} ${container_name}
# Docker login
Log To Console \nRunning docker login ${user}...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} login -u ${user} -p ${password} %{HARBOR_IP}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Login Succeeded
Should Not Contain ${output} Error response from daemon
# Docker pull from dockerhub
Log To Console docker pull from dockerhub...
${rc} ${output}= Run And Return Rc And Output docker pull ${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker tag image
Log To Console docker tag...
${rc} ${output}= Run And Return Rc And Output docker tag ${image} %{HARBOR_IP}/${project}/${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker push image
Log To Console push image...
${rc} ${output}= Run And Return Rc And Output docker push %{HARBOR_IP}/${project}/${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} digest:
Should Contain ${output} latest:
Should Not Contain ${output} No such image:
# Docker delete image in local registry
Log To Console docker rmi...
${rc} ${output}= Run And Return Rc And Output docker rmi -f %{HARBOR_IP}/${project}/${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Untagged
# Docker pull from harbor using VCH
Log To Console docker pull from harbor using VCH...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} pull %{HARBOR_IP}/${project}/${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker run image
Log To Console docker run...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} run --name ${container_name} %{HARBOR_IP}/${project}/${image} /bin/ash -c "dmesg;echo END_OF_THE_TEST"
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} END_OF_THE_TEST
# Docker rm container
Log To Console docker rm...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rm -f ${container_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker create
Log To Console docker create...
${rc} ${containerID}= Run And Return Rc And Output docker %{VCH-PARAMS} create --name ${container_name} -i %{HARBOR_IP}/${project}/${image} /bin/top
Log ${containerID}
Should Be Equal As Integers ${rc} 0
# Docker start
Log To Console docker start...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} start ${container_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker attach
Log To Console Starting process Docker attach...
Start Process docker %{VCH-PARAMS} attach ${container_name} < /tmp/fifo shell=True alias=custom
Sleep 3
Run echo q > /tmp/fifo
${ret}= Wait For Process custom
Log ${ret}
Should Be Equal As Integers ${ret.rc} 0
Should Be Empty ${ret.stdout}
Should Be Empty ${ret.stderr}
# Docker start
Log To Console docker start...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} start ${container_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker stop
Log To Console docker stop...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} stop ${container_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
# Docker remove
Log To Console docker rm...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rm -f ${container_name}
Log ${output}
Should Be Equal As Integers ${rc} 0
Wait Until Keyword Succeeds 10x 6s Check That VM Is Removed ${container_name}
Wait Until Keyword Succeeds 10x 6s Check That Datastore Is Cleaned ${container_name}
# Docker delete image
Log To Console docker rmi...
${rc} ${output}= Run And Return Rc And Output docker %{VCH-PARAMS} rmi -f %{HARBOR_IP}/${project}/${image}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Untagged
Fetch Harbor Self Signed Cert
[Tags] secret
[Arguments] ${harbor-ip} ${user}=admin ${password}=%{TEST_PASSWORD}
Remove File ${harbor_cert}
${rc}= Run And Return Rc wget -q --tries=10 --connect-timeout=10 --auth-no-challenge --no-check-certificate --user ${user} --password ${password} https://${harbor-ip}/api/systeminfo/${harbor_cert}
Should Be Equal As Integers ${rc} 0
[Return] ${harbor_cert}
# Requires vc credential for govc
Cleanup Harbor
[Tags] secret
[Arguments] ${harbor-name} ${host}=%{TEST_URL} ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD}
Log To Console \nCleanup Harbor... TEST_URL:%{TEST_URL}
Remove File ${HARBOR_VERSION}.ova
Remove File ${harbor_cert}
${out}= Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc vm.destroy ${harbor-name}
[Return] ${out}

View File

@@ -0,0 +1,482 @@
# 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 contains any keywords related to using the Nimbus cluster
*** Variables ***
${ESX_VERSION} ob-5969303 #6.5 RTM vsphere65u1
${VC_VERSION} ob-5973321 #6.5 RTM vsphere65u1
${NIMBUS_ESX_PASSWORD} e2eFunctionalTest
${NIMBUS_LOCATION} ${EMPTY}
*** Keywords ***
Fetch IP
[Arguments] ${name}
${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl ip %{NIMBUS_USER}-${name} | grep %{NIMBUS_USER}-${name}
Should Not Be Empty ${out}
${len}= Get Line Count ${out}
Should Be Equal As Integers ${len} 1
[Return] ${out}
Get IP
[Arguments] ${name}
${out}= Wait Until Keyword Succeeds 10x 1 minute Fetch IP ${name}
${ip}= Fetch From Right ${out} ${SPACE}
[Return] ${ip}
Fetch POD
[Arguments] ${name}
${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl list | grep ${name}
Should Not Be Empty ${out}
${len}= Get Line Count ${out}
Should Be Equal As Integers ${len} 1
${pod}= Fetch From Left ${out} :
[return] ${pod}
Custom Testbed Keepalive
[Tags] secret
[Arguments] ${folder}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} '%{NIMBUS_PASSWORD}' touch ${folder}
[Return] ${out}
Deploy Nimbus ESXi Server
[Arguments] ${user} ${password} ${version}=${ESX_VERSION} ${tls_disabled}=True
${name}= Evaluate 'ESX-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
Log To Console \nDeploying Nimbus ESXi server: ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command ${NIMBUS_LOCATION} nimbus-esxdeploy ${name} --disk=48000000 --ssd=24000000 --memory=8192 --lease=1 --nics 2 ${version}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} To manage this VM use
\ Exit For Loop If ${status}
\ Log To Console ${out}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
# Let's set a password so govc doesn't complain
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Remove Environment Variable GOVC_DATACENTER
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Run Keyword If ${tls_disabled} Disable TLS On ESX Host
Log To Console Successfully deployed new ESXi server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Set Host Password
[Arguments] ${ip} ${NIMBUS_ESX_PASSWORD}
Remove Environment Variable GOVC_PASSWORD
Remove Environment Variable GOVC_USERNAME
Remove Environment Variable GOVC_DATACENTER
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_URL root:@${ip}
${out}= Run govc host.account.update -id root -password ${NIMBUS_ESX_PASSWORD}
Should Be Empty ${out}
Disable TLS On ESX Host
Log To Console \nNimbus ESXi server IP: ${ip}
Deploy Multiple Nimbus ESXi Servers in Parallel
[Arguments] ${number} ${user}=%{NIMBUS_USER} ${password}=%{NIMBUS_PASSWORD} ${version}=${ESX_VERSION}
@{names}= Create List
${num}= Convert To Integer ${number}
:FOR ${x} IN RANGE ${num}
\ ${name}= Evaluate 'ESX-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
\ Append To List ${names} ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
@{processes}= Create List
:FOR ${name} IN @{names}
\ ${output}= Deploy Nimbus ESXi Server Async ${name}
\ Append To List ${processes} ${output}
:FOR ${process} IN @{processes}
\ ${pid}= Convert To Integer ${process}
\ ${result}= Wait For Process ${pid}
\ Log ${result.stdout}
\ Log ${result.stderr}
&{ips}= Create Dictionary
:FOR ${name} IN @{names}
\ ${ip}= Get IP ${name}
\ ${ip}= Evaluate $ip if $ip else ''
\ Run Keyword If '${ip}' Set To Dictionary ${ips} ${user}-${name} ${ip}
# Let's set a password so govc doesn't complain
${just_ips}= Get Dictionary Values ${ips}
:FOR ${ip} IN @{just_ips}
\ Log To Console Successfully deployed new ESXi server - ${ip}
\ Set Host Password ${ip} ${NIMBUS_ESX_PASSWORD}
Close connection
[Return] ${ips}
Deploy Nimbus vCenter Server
[Arguments] ${user} ${password} ${version}=${VC_VERSION}
${name}= Evaluate 'VC-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
Log To Console \nDeploying Nimbus vCenter server: ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command ${NIMBUS_LOCATION} nimbus-vcvadeploy --lease=1 --vcvaBuild ${version} ${name}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} Overall Status: Succeeded
\ Exit For Loop If ${status}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Cloudvm is running on IP
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
${ip}= Fetch From Right ${line} ${SPACE}
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin!23
Set Environment Variable GOVC_URL ${ip}
Log To Console Successfully deployed new vCenter server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Deploy Nimbus ESXi Server Async
[Tags] secret
[Arguments] ${name} ${version}=${ESX_VERSION}
Log To Console \nDeploying Nimbus ESXi server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} '%{NIMBUS_PASSWORD}' '${NIMBUS_LOCATION} nimbus-esxdeploy ${name} --disk\=48000000 --ssd\=24000000 --memory\=8192 --lease=1 --nics 2 ${version}'
[Return] ${out}
Run Secret SSHPASS command
[Tags] secret
[Arguments] ${user} ${password} ${cmd}
${out}= Start Process sshpass -p ${password} ssh -o StrictHostKeyChecking\=no ${user}@%{NIMBUS_GW} ${cmd} shell=True
[Return] ${out}
Deploy Nimbus vCenter Server Async
[Tags] secret
[Arguments] ${name} ${version}=${VC_VERSION}
Log To Console \nDeploying Nimbus VC server: ${name}
${out}= Run Secret SSHPASS command %{NIMBUS_USER} '%{NIMBUS_PASSWORD}' '${NIMBUS_LOCATION} nimbus-vcvadeploy --lease=1 --vcvaBuild ${version} ${name}'
[Return] ${out}
Deploy Nimbus Testbed
[Arguments] ${user} ${password} ${testbed}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
:FOR ${IDX} IN RANGE 1 5
\ ${out}= Execute Command ${NIMBUS_LOCATION} nimbus-testbeddeploy --lease=1 ${testbed}
\ Log ${out}
\ # Make sure the deploy actually worked
\ ${status}= Run Keyword And Return Status Should Contain ${out} "deployment_result"=>"PASS"
\ Return From Keyword If ${status} ${out}
\ Log To Console Nimbus deployment ${IDX} failed, trying again in 5 minutes
\ Sleep 5 minutes
Fail Deploy Nimbus Testbed Failed 5 times over the course of more than 25 minutes
Kill Nimbus Server
[Arguments] ${user} ${password} ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl kill ${name}
Log ${out}
Close connection
Cleanup Nimbus PXE folder
[Arguments] ${user} ${password}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
${out}= Execute Command ${NIMBUS_LOCATION} rm -rf public_html/pxe/*
Close connection
Nimbus Cleanup
[Arguments] ${vm_list} ${collect_log}=True ${dontDelete}=${false}
Run Keyword If ${collect_log} Run Keyword And Continue On Failure Gather Logs From Test Server
Run Keyword And Ignore Error Cleanup Nimbus PXE folder %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Return From Keyword If ${dontDelete}
${list}= Catenate @{vm_list}
Run Keyword And Ignore Error Kill Nimbus Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${list}
Gather Host IPs
${out}= Run govc ls host/cls
${out}= Split To Lines ${out}
${idx}= Set Variable 1
:FOR ${line} IN @{out}
\ Continue For Loop If '${line}' == '/vcqaDC/host/cls/Resources'
\ ${ip}= Fetch From Right ${line} /
\ Set Suite Variable ${esx${idx}-ip} ${ip}
\ ${idx}= Evaluate ${idx}+1
Create a VSAN Cluster
[Arguments] ${name}=vic-vmotion
[Timeout] 110 minutes
Log To Console \nStarting basic VSAN cluster deploy...
Run Keyword And Ignore Error Nimbus Cleanup ${list} ${false}
${out}= Deploy Nimbus Testbed %{NIMBUS_USER} %{NIMBUS_PASSWORD} --plugin testng --lease 1 --noStatsDump --noSupportBundles --vcvaBuild ${VC_VERSION} --esxPxeDir ${ESX_VERSION} --esxBuild ${ESX_VERSION} --testbedName vcqa-vsan-simple-pxeBoot-vcva --runName ${name}
Should Contain ${out} .vcva-${VC_VERSION}' is up. IP:
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} .vcva-${VC_VERSION}' is up. IP:
\ ${ip}= Run Keyword If ${status} Fetch From Right ${line} ${SPACE}
\ Run Keyword If ${status} Set Suite Variable ${vc-ip} ${ip}
\ Exit For Loop If ${status}
Log To Console Set environment variables up for GOVC
Set Environment Variable GOVC_URL ${vc-ip}
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin\!23
Log To Console Create a distributed switch
${out}= Wait Until Keyword Succeeds 10x 3 minutes Run govc dvs.create -dc=vcqaDC test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=vcqaDC -dvs=test-ds bridge
Should Contain ${out} OK
Log To Console Add all the hosts to the distributed switch
${out}= Run govc dvs.add -dvs=test-ds -pnic=vmnic1 /vcqaDC/host/cls
Should Contain ${out} OK
Log To Console Enable DRS and VSAN on the cluster
${out}= Run govc cluster.change -drs-enabled /vcqaDC/host/cls
Should Be Empty ${out}
Log To Console Deploy VIC to the VC cluster
Set Environment Variable TEST_URL_ARRAY ${vc-ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Set Environment Variable TEST_DATASTORE vsanDatastore
Set Environment Variable TEST_RESOURCE cls
Set Environment Variable TEST_TIMEOUT 15m
Gather Host IPs
Create a Simple VC Cluster
[Arguments] ${datacenter}=ha-datacenter ${cluster}=cls ${esx_number}=3 ${network}=True
Log To Console \nStarting simple VC cluster deploy...
${vc}= Evaluate 'VC-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
${pid}= Deploy Nimbus vCenter Server Async ${vc}
&{esxes}= Deploy Multiple Nimbus ESXi Servers in Parallel ${esx_number} %{NIMBUS_USER} %{NIMBUS_PASSWORD} ${ESX_VERSION}
@{esx_names}= Get Dictionary Keys ${esxes}
@{esx_ips}= Get Dictionary Values ${esxes}
# Finish vCenter deploy
${output}= Wait For Process ${pid}
Should Contain ${output.stdout} Overall Status: Succeeded
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login %{NIMBUS_USER} %{NIMBUS_PASSWORD}
${vc_ip}= Get IP ${vc}
Close Connection
Set Environment Variable GOVC_INSECURE 1
Set Environment Variable GOVC_USERNAME Administrator@vsphere.local
Set Environment Variable GOVC_PASSWORD Admin!23
Set Environment Variable GOVC_URL ${vc_ip}
Log To Console Create a datacenter on the VC
${out}= Run govc datacenter.create ${datacenter}
Should Be Empty ${out}
Log To Console Create a cluster on the VC
${out}= Run govc cluster.create ${cluster}
Should Be Empty ${out}
Log To Console Add ESX host to the VC
:FOR ${IDX} IN RANGE ${esx_number}
\ ${out}= Run govc cluster.add -hostname=@{esx_ips}[${IDX}] -username=root -dc=${datacenter} -password=${NIMBUS_ESX_PASSWORD} -noverify=true
\ Should Contain ${out} OK
Run Keyword If ${network} Setup Network For Simple VC Cluster ${esx_number} ${datacenter} ${cluster}
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable TEST_URL_ARRAY ${vc_ip}
Set Environment Variable TEST_URL ${vc_ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable TEST_DATASTORE datastore1
Set Environment Variable TEST_DATACENTER /${datacenter}
Set Environment Variable TEST_RESOURCE ${cluster}
Set Environment Variable TEST_TIMEOUT 30m
[Return] @{esx_names} ${vc} @{esx_ips} ${vc_ip}
Setup Network For Simple VC Cluster
[Arguments] ${esx_number} ${datacenter} ${cluster}
Log To Console Create a distributed switch
${out}= Run govc dvs.create -dc=${datacenter} test-ds
Should Contain ${out} OK
Log To Console Create three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=test-ds bridge
Should Contain ${out} OK
Wait Until Keyword Succeeds 10x 3 minutes Add Host To Distributed Switch /${datacenter}/host/${cluster} test-ds
Log To Console Enable DRS on the cluster
${out}= Run govc cluster.change -drs-enabled /${datacenter}/host/${cluster}
Should Be Empty ${out}
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Create A Distributed Switch
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate a distributed switch
${out}= Run govc dvs.create -product-version 5.5.0 -dc=${datacenter} ${dvs}
Should Contain ${out} OK
Create Three Distributed Port Groups
[Arguments] ${datacenter} ${dvs}=test-ds
Log To Console \nCreate three new distributed switch port groups for management and vm network traffic
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} management
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} vm-network
Should Contain ${out} OK
${out}= Run govc dvs.portgroup.add -nports 12 -dc=${datacenter} -dvs=${dvs} bridge
Should Contain ${out} OK
Add Host To Distributed Switch
[Arguments] ${host} ${dvs}=test-ds
Log To Console \nAdd host(s) to the distributed switch
${out}= Run govc dvs.add -dvs=${dvs} -pnic=vmnic1 ${host}
Should Contain ${out} OK
Disable TLS On ESX Host
Log To Console \nDisable TLS on the host
${ver}= Get Vsphere Version
${out}= Run Keyword If '${ver}' != '5.5.0' Run govc host.option.set UserVars.ESXiVPsDisabledProtocols sslv3,tlsv1,tlsv1.1
Run Keyword If '${ver}' != '5.5.0' Should Be Empty ${out}
Get Vsphere Version
${out}= Run govc about
${out}= Split To Lines ${out}
:FOR ${line} IN @{out}
\ ${status}= Run Keyword And Return Status Should Contain ${line} Version:
\ Run Keyword And Return If ${status} Fetch From Right ${line} ${SPACE}
Deploy Nimbus NFS Datastore
[Arguments] ${user} ${password} ${additional-args}=
${name}= Evaluate 'NFS-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
Log To Console \nDeploying Nimbus NFS server: ${name}
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 2 min 30 sec Login ${user} ${password}
${out}= Execute Command ${NIMBUS_LOCATION} nimbus-nfsdeploy ${name} ${additional-args}
# Make sure the deploy actually worked
Should Contain ${out} To manage this VM use
# Now grab the IP address and return the name and ip for later use
@{out}= Split To Lines ${out}
:FOR ${item} IN @{out}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} IP is
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
@{gotIP}= Split String ${line} ${SPACE}
${ip}= Remove String @{gotIP}[5] ,
Log To Console Successfully deployed new NFS server - ${user}-${name}
Close connection
[Return] ${user}-${name} ${ip}
Change ESXi Server Password
[Arguments] ${password}
${out}= Run govc host.account.update -id root -password ${password}
Should Be Empty ${out}
Check License Features
${out}= Run govc object.collect -json $(govc object.collect -s - content.licenseManager) licenses | jq '.[].Val.LicenseManagerLicenseInfo[].Properties[] | select(.Key == "feature") | .Value'
Should Contain ${out} serialuri
Should Contain ${out} dvs
# Abruptly power off the host
Power Off Host
[Arguments] ${host}
Open Connection ${host} prompt=:~]
Login root ${NIMBUS_ESX_PASSWORD}
${out}= Execute Command poweroff -d 0 -f
Close connection
Create Static IP Worker
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 10 min 30 sec Login %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Log To Console Create a new static ip address worker...
${name}= Evaluate 'static-worker-' + str(random.randint(1000,9999)) + str(time.clock()) modules=random,time
Log To Console \nDeploying static ip worker: ${name}
${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl --silentObjectNotFoundError kill '%{NIMBUS_USER}-static-worker' && ${NIMBUS_LOCATION} nimbus-worker-deploy --nimbus ${NIMBUS_POD} --enableStaticIpService ${name}
Should Contain ${out} "deploy_status": "success"
${pod}= Fetch POD ${name}
Run Keyword If '${pod}' != '${NIMBUS_POD}' Kill Nimbus Server %{NIMBUS_USER} %{NIMBUS_PASSWORD} %{NIMBUS_USER}-${name}
Run Keyword If '${pod}' != '${NIMBUS_POD}' Fail Nimbus pod suggestion failed
Set Environment Variable STATIC_WORKER_NAME %{NIMBUS_USER}-${name}
${ip}= Get IP ${name}
Set Environment Variable STATIC_WORKER_IP ${ip}
Close Connection
Get Static IP Address
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set STATIC_WORKER_IP
Run Keyword If '${status}' == 'FAIL' Wait Until Keyword Succeeds 10x 10s Create Static IP Worker
Log To Console Curl a new static ip address from the created worker...
${out}= Run curl -s http://%{STATIC_WORKER_IP}:4827/nsips
&{static}= Create Dictionary
${ip}= Run echo '${out}' | jq -r ".ip"
Set To Dictionary ${static} ip ${ip}
${netmask}= Run echo '${out}' | jq -r ".netmask"
${netmask}= Evaluate sum([bin(int(x)).count("1") for x in "${netmask}".split(".")])
Set To Dictionary ${static} netmask ${netmask}
${gateway}= Run echo '${out}' | jq -r ".gateway"
Set To Dictionary ${static} gateway ${gateway}
[Return] ${static}
Is Nimbus Location WDC
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 10 min 30 sec Login %{NIMBUS_USER} %{NIMBUS_PASSWORD}
${out}= Execute Command env | grep NIMBUS_LOCATION=wdc
${status}= Run Keyword And Return Status Should Not Be Empty ${out}
Close Connection
[Return] ${status}

View File

@@ -0,0 +1,116 @@
# 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
*** Settings ***
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_target_vm_name} vic-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
${ova_network_netmask0} 255.255.255.0
${ova_network_gateway} 10.17.109.253
${ova_network_dns} 10.118.81.1
${ova_network_searchpath} eng.vmware.com
${ova_network_domain} mrburns
${ova_network_options} --prop:network.ip0=${ova_network_ip0} --prop:network.netmask0=${ova_network_netmask0} --prop:network.gateway=${ova_network_gateway} --prop:network.DNS=${ova_network_dns} --prop:network.searchpath=${ova_network_searchpath} --prop:network.domain=${ova_network_domain}
${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_options} ${ovftool_options} ${ova_appliance_options} ${ova_service_options}
${ova_options_with_network} ${ova_options} ${ova_network_options}
${tls_not_disabled} False
*** Keywords ***
# Requires vc credential for govc
Deploy VIC-OVA To Test Server
[Arguments] ${dhcp}=True ${protocol}=http ${build}=False ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD} ${host}=%{TEST_URL_ARRAY} ${datastore}=%{TEST_DATASTORE} ${cluster}=%{TEST_RESOURCE} ${datacenter}=%{TEST_DATACENTER}
Set Global Variable ${ova_path} bin/vic-1.1.1-${rev}.ova
Run Keyword if ${build} Build Unified OVA
${rev}= Run git rev-parse --short HEAD
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}
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /${datacenter}/vm/${ova_target_vm_name}
Log To Console \nStarting to deploy unified-ova to test server...
Run Keyword If ${dhcp} Log To Console ovftool --datastore=${datastore} ${ova_options} ${ova_path} 'vi://${user}:${password}@${host}/${cluster}'
... ELSE Log To Console ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${cluster}'
${out}= Run Keyword If ${dhcp} Run ovftool --datastore=${datastore} ${ova_options} --net:"Network"="vm-network" ${ova_path} 'vi://${user}:${password}@${host}/${cluster}'
... ELSE Run ovftool --datastore=${datastore} ${ova_options_with_network} ${ova_path} 'vi://${user}:${password}@${host}/${cluster}'
Should Contain ${out} Received IP address:
Should Not Contain ${out} None
${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
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
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc host.esxcli -host.ip=${esx2-ip} system settings advanced set -o /Net/GuestIPHack -i 1
Run Keyword And Ignore Error Run GOVC_URL=${host} GOVC_USERNAME=${user} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc host.esxcli -host.ip=${esx3-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 vic-unified-ova-integration-test
Set Environment Variable HARBOR_IP ${ip}
Log To Console \nHarbor IP: %{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!
[Return] %{HARBOR_IP}
# Requires vc credential for govc
Cleanup VIC-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}
Should Be Equal As Integers ${rc} 0
Run Keyword And Ignore Error Run GOVC_URL=${url} GOVC_USERNAME=${username} GOVC_PASSWORD=${password} GOVC_INSECURE=1 govc object.destroy /%{TEST_DATACENTER}/vm/${ova_target_vm_name}
Log To Console \nUnified-OVA deployment is cleaned up on test server
Build Unified OVA
[Arguments] ${user}=%{TEST_USERNAME} ${password}=%{TEST_PASSWORD} ${host}=%{TEST_URL}
Log To Console \nStarting to build Unified OVA...
Log To Console \nRemove stale local OVA artifacts
Run Remove OVA Artifacts Locally
${out}= Run PACKER_ESX_HOST=${host} PACKER_USER=${user} PACKER_PASSWORD=${password} make ova-release
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.1-${rev}.ova bin/vic-1.1.1-${rev}.ovf bin/vic-1.1.1-${rev}.mk bin/vic-1.1.1-${rev}-disk*.vmdk

View File

@@ -0,0 +1,21 @@
# 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
*** Settings ***
Documentation This resource contains all keywords related to reading, posting to Slack channels
*** Keywords ***
Post Message To Slack Channel
[Arguments] ${channel} ${message}
${out}= Run curl -s -d "payload={\\"channel\\": \\"#${channel}\\", \\"text\\": \\"${message}\\"}" "%{SLACK_URL}"

View File

@@ -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 ***
Library OperatingSystem
Library String
Library Collections
Library requests
Library Process
Library SSHLibrary 5 minute
Library DateTime
Library Selenium2Library 3 3
Resource Nimbus-Util.robot
Resource Vsphere-Util.robot
Resource VCH-Util.robot
Resource Drone-Util.robot
Resource Github-Util.robot
Resource Harbor-Util.robot
Resource Docker-Util.robot
Resource Admiral-Util.robot
Resource OVA-Util.robot
Resource Cert-Util.robot
Resource Slack-Util.robot
Variables dynamic-vars.py

View File

@@ -0,0 +1,681 @@
# 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 contains all keywords related to creating, deleting, maintaining VCHs
*** Keywords ***
Set Test Environment Variables
# Finish setting up environment variables
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set DRONE_BUILD_NUMBER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable DRONE_BUILD_NUMBER 0
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set BRIDGE_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable BRIDGE_NETWORK network
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set PUBLIC_NETWORK
Run Keyword If '${status}' == 'FAIL' Set Environment Variable PUBLIC_NETWORK 'VM Network'
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_DATACENTER
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_DATACENTER ${SPACE}
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set DRONE_MACHINE
Run Keyword If '${status}' == 'FAIL' Set Environment Variable DRONE_MACHINE 'local'
@{URLs}= Split String %{TEST_URL_ARRAY}
${len}= Get Length ${URLs}
${IDX}= Evaluate %{DRONE_BUILD_NUMBER} \% ${len}
Set Environment Variable TEST_URL @{URLs}[${IDX}]
Set Environment Variable GOVC_URL %{TEST_URL}
Set Environment Variable GOVC_USERNAME %{TEST_USERNAME}
Set Environment Variable GOVC_PASSWORD %{TEST_PASSWORD}
${rc} ${thumbprint}= Run And Return Rc And Output govc about.cert -k -json | jq -r .ThumbprintSHA1
Should Be Equal As Integers ${rc} 0
Set Environment Variable TEST_THUMBPRINT ${thumbprint}
Log To Console \nTEST_URL=%{TEST_URL}
Log To Console \nDRONE_MACHINE=%{DRONE_MACHINE}
${worker_date}= Run date
Log To Console \nWorker_Date=${worker_date}
${rc} ${host}= Run And Return Rc And Output govc ls host
Should Be Equal As Integers ${rc} 0
${out}= Run govc ls -t HostSystem ${host} | xargs -I% -n1 govc host.date.info -host\=% | grep 'date and time'
Log To Console \nTest_Server_Dates=\n${out}\n
${status} ${message}= Run Keyword And Ignore Error Environment Variable Should Be Set TEST_RESOURCE
Run Keyword If '${status}' == 'FAIL' Set Environment Variable TEST_RESOURCE ${host}/Resources
Set Environment Variable GOVC_RESOURCE_POOL %{TEST_RESOURCE}
${noQuotes}= Strip String %{TEST_DATASTORE} characters="
#"
Set Environment Variable GOVC_DATASTORE ${noQuotes}
${about}= Run govc about
${status}= Run Keyword And Return Status Should Contain ${about} VMware ESXi
Run Keyword If ${status} Set Environment Variable HOST_TYPE ESXi
Run Keyword Unless ${status} Set Environment Variable HOST_TYPE VC
${about}= Run govc datastore.info %{TEST_DATASTORE} | grep 'Type'
${status}= Run Keyword And Return Status Should Contain ${about} vsan
Run Keyword If ${status} Set Environment Variable DATASTORE_TYPE VSAN
Run Keyword Unless ${status} Set Environment Variable DATASTORE_TYPE Non_VSAN
# set the TLS config options suitable for vic-machine in this env
${domain}= Get Environment Variable DOMAIN ''
Run Keyword If $domain == '' Set Suite Variable ${vicmachinetls} --no-tlsverify
Run Keyword If $domain != '' Set Suite Variable ${vicmachinetls} --tls-cname=*.${domain}
Set Test VCH Name
# cleanup any potential old certs directories
Remove Directory %{VCH-NAME} recursive=${true}
# Set a unique bridge network for each VCH that has a random VLAN ID
${vlan}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Evaluate str(random.randint(1, 4093)) modules=random
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.add -vlan=${vlan} -vswitch vSwitchLAN %{VCH-NAME}-bridge
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Set Environment Variable BRIDGE_NETWORK %{VCH-NAME}-bridge
Set Test VCH Name
${name}= Evaluate 'VCH-%{DRONE_BUILD_NUMBER}-' + str(random.randint(1000,9999)) modules=random
Set Environment Variable VCH-NAME ${name}
Log Set VCH-NAME as ${name}
Set List Of Env Variables
[Arguments] ${vars}
@{vars}= Split String ${vars}
:FOR ${var} IN @{vars}
\ ${varname} ${varval}= Split String ${var} =
\ Set Environment Variable ${varname} ${varval}
Parse Environment Variables
[Arguments] ${line}
# If using the default logrus format
${status}= Run Keyword And Return Status Should Match Regexp ${line} msg\="([^"]*)"
${match} ${vars}= Run Keyword If ${status} Should Match Regexp ${line} msg\="([^"]*)"
Run Keyword If ${status} Set List Of Env Variables ${vars}
Return From Keyword If ${status}
# If using the old logging format
${status}= Run Keyword And Return Status Should Contain ${line} mINFO
${logdeco} ${vars}= Run Keyword If ${status} Split String ${line} ${SPACE} 1
Run Keyword If ${status} Set List Of Env Variables ${vars}
Return From Keyword If ${status}
# Split the log log into pieces, discarding the initial log decoration, and assign to env vars
${logmon} ${logday} ${logyear} ${logtime} ${loglevel} ${vars}= Split String ${line} max_split=5
Set List Of Env Variables ${vars}
Get Docker Params
# Get VCH docker params e.g. "-H 192.168.218.181:2376 --tls"
[Arguments] ${output} ${certs}
@{output}= Split To Lines ${output}
:FOR ${item} IN @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} DOCKER_HOST=
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
# Ensure we start from a clean slate with docker env vars
Remove Environment Variable DOCKER_HOST DOCKER_TLS_VERIFY DOCKER_CERT_PATH CURL_CA_BUNDLE COMPOSE_PARAMS COMPOSE_TLS_VERSION
Parse Environment Variables ${line}
${dockerHost}= Get Environment Variable DOCKER_HOST
@{hostParts}= Split String ${dockerHost} :
${ip}= Strip String @{hostParts}[0]
${port}= Strip String @{hostParts}[1]
Set Environment Variable VCH-IP ${ip}
Log Set VCH-IP as ${ip}
Set Environment Variable VCH-PORT ${port}
Log Set VCH-PORT as ${port}
:FOR ${index} ${item} IN ENUMERATE @{output}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} http
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${line} ${item}
\ ${status} ${message}= Run Keyword And Ignore Error Should Contain ${item} Published ports can be reached at
\ ${idx} = Evaluate ${index} + 1
\ Run Keyword If '${status}' == 'PASS' Set Suite Variable ${ext-ip} @{output}[${idx}]
${status}= Run Keyword And Return Status Should Match Regexp ${ext-ip} msg\=([^"]*)
${ignore} ${ext-ip}= Run Keyword If ${status} Should Match Regexp ${ext-ip} msg\=([^"]*)
... ELSE Split String From Right ${ext-ip} ${SPACE} 1
${ext-ip}= Strip String ${ext-ip}
Set Environment Variable EXT-IP ${ext-ip}
Log Set EXT-IP as ${ext-ip}
${status}= Run Keyword And Return Status Should Match Regexp ${line} msg\="([^"]*)"
${ignore} ${vic-admin}= Run Keyword If ${status} Should Match Regexp ${line} msg\="([^"]*)"
... ELSE Split String From Right ${line} ${SPACE} 1
Set Environment Variable VIC-ADMIN ${vic-admin}
Run Keyword If ${port} == 2376 Set Environment Variable VCH-PARAMS -H ${dockerHost} --tls
Run Keyword If ${port} == 2375 Set Environment Variable VCH-PARAMS -H ${dockerHost}
### Add environment variables for Compose and TLS
# Check if tls is enable from vic-machine's output and not trust ${certs} which some tests bypasses
${tls_enabled}= Get Environment Variable DOCKER_TLS_VERIFY ${false}
### Compose case for no-tlsverify
# Set environment variables if certs not used to create the VCH. This is NOT the recommended
# approach to running compose. There will be security warnings in the logs and some compose
# operations may not work properly because certs == false currently means we install with
# --no-tlsverify. Add CURL_CA_BUNDLE for a workaround in compose tests. If we change
# certs == false to install with --no-tls, then we need to change this again.
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable CURL_CA_BUNDLE ${EMPTY}
# Get around quirk in compose if no-tlsverify, then CURL_CA_BUNDLE must exist and compose called with --tls
Run Keyword If ${tls_enabled} == ${false} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost} --tls
### Compose case for tlsverify (assumes DOCKER_TLS_VERIFY also set)
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE_TLS_VERSION TLSv1_2
Run Keyword If ${tls_enabled} == ${true} Set Environment Variable COMPOSE-PARAMS -H ${dockerHost}
Convert List to String
[Arguments] @{list}
Should Not Be Empty ${list}
${list-string}= Set Variable ${EMPTY}
:FOR ${item} IN @{list}
\ ${list-was-empty}= Set Variable If '${list-string}' == '${EMPTY}' ${True} ${false}
\ ${list-string}= Run Keyword If ${list-was-empty} Set Variable ${item}
\ ... ELSE Catenate SEPARATOR=| ${list-string} ${item}
[Return] ${list-string}
Add VCH to Removal Exception List
[Arguments] ${vch}=${EMPTY}
${exceptions-string}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
@{exceptions-list}= Run Keyword If '${exceptions-string}' == '${EMPTY}' Create List
@{exceptions-list}= Run Keyword Unless '${exceptions-string}' == '${EMPTY}' Split String ${exceptions-string} separator=|
${set}= Create Dictionary
Add List To Dictionary ${set} ${exceptions-list}
Set To Dictionary ${set} ${vch} 1
${exceptions-list}= Set Variable ${set.keys()}
# Append To List ${exceptions-list} ${vch}
${list-string}= Convert List To String @{exceptions-list}
Set Environment Variable VM_EXCEPTIONS ${list-string}
Log To Console Saved '${list-string}' to removal exceptions
Remove VCH from Removal Exception List
[Arguments] ${vch}=${EMPTY}
${exceptions-string}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
Return From Keyword If '${exceptions-string}' == '${EMPTY}' No Exceptions Found
@{exceptions-list}= Run Keyword Unless '${exceptions-string}' == '${EMPTY}' Split String ${exceptions-string} separator=|
${idx}= Get Index From List ${exceptions-list} ${vch}
Remove From List ${exceptions-list} ${idx}
${len}= Get Length ${exceptions-list}
${list-string}= Run Keyword If ${len} != 0 Convert List To String @{exceptions-list}
... ELSE Set Variable ${EMPTY}
Set Environment Variable VM_EXCEPTIONS ${list-string}
Check If VCH Is In Exception
[Arguments] ${vch}=${EMPTY} ${exceptions}=${EMPTY}
${exceptions}= Run Keyword If '${exceptions}' == '${EMPTY}' Get Environment Variable VM_EXCEPTIONS ${EMPTY}
... ELSE Set Variable ${exceptions}
Return From Keyword If '${exceptions}' == '${EMPTY}' ${false}
${excluded}= Set Variable ${false}
${exceptions-list}= Split String ${exceptions} separator=|
: FOR ${vm-exclude} IN @{exceptions-list}
\ Continue For Loop If '${vm-exclude}' != '${vch}'
\ ${excluded}= Set Variable ${true}
\ Exit For Loop
[Return] ${excluded}
Dump Docker Debug Data From VCH
Log To Console **********
List Existing Images On VCH
List Running Containers On VCH
Log To Console **********
Use Target VIC Appliance
# Use a VIC appliance created outside of CI
[Arguments] ${target-vch}=${EMPTY}
Return From Keyword If '${target-vch}' == '${EMPTY}' ${False}
${debug-vch}= Get Environment Variable DEBUG_VCH ${EMPTY}
Set Test Environment Variables
Set Environment Variable VCH-NAME ${target-vch}
Log To Console Reusing existing vch: ${target-vch}
Run VIC Machine Inspect Command
Add VCH to Removal Exception List vch=${target-vch}
Run Keyword If '${debug-vch}' != '${EMPTY}' Dump Docker Debug Data From VCH
[Return] ${True}
Conditional Install VIC Appliance To Test Server
[Arguments] ${certs}=${true} ${init}=${False}
${target-vch}= Get Environment Variable TARGET_VCH ${EMPTY}
${multi-vch}= Get Environment Variable MULTI_VCH ${EMPTY}
# If TARGET_VCH was defined, use that VCH for tests and exit
Run Keyword If '${target-vch}' != '${EMPTY}' Use Target VIC Appliance target-vch=${target-vch}
Return From Keyword If '${target-vch}' != '${EMPTY}' ${True}
Install VIC Appliance To Test Server certs=${certs}
# If MULT_VCH set to 1, then we are in multi VCH mode, otherwise, we are in single VCH mode
${single-vch-mode}= Run Keyword If '${multi-vch}' == '1' Set Variable ${False}
... ELSE Set Variable ${True}
# In single vch mode, save VCH name to TARGET_VCH and add VCH to exception removal list
Run Keyword If ${init} Set Environment Variable TARGET_VCH %{VCH-NAME}
Install VIC Appliance To Test Server
[Arguments] ${vic-machine}=bin/vic-machine-linux ${appliance-iso}=bin/appliance.iso ${bootstrap-iso}=bin/bootstrap.iso ${certs}=${true} ${vol}=default ${cleanup}=${true} ${debug}=1 ${additional-args}=${EMPTY}
Set Test Environment Variables
${output}= Install VIC Appliance To Test Server With Current Environment Variables ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol} ${cleanup} ${debug} ${additional-args}
Log ${output}
[Return] ${output}
Install VIC Appliance To Test Server With Current Environment Variables
[Arguments] ${vic-machine}=bin/vic-machine-linux ${appliance-iso}=bin/appliance.iso ${bootstrap-iso}=bin/bootstrap.iso ${certs}=${true} ${vol}=default ${cleanup}=${true} ${debug}=1 ${additional-args}=${EMPTY}
# disable firewall
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.esxcli network firewall set -e false
# Attempt to cleanup old/canceled tests
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling VMs On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Datastore On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Networks On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling vSwitches On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Containers On Test Server
Run Keyword If ${cleanup} Run Keyword And Ignore Error Cleanup Dangling Resource Pools On Test Server
# Install the VCH now
Log To Console \nInstalling VCH to test server...
${output}= Run VIC Machine Command ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol} ${debug} ${additional-args}
Log ${output}
Should Contain ${output} Installer completed successfully
Get Docker Params ${output} ${certs}
Log To Console Installer completed successfully: %{VCH-NAME}...
[Return] ${output}
Run VIC Machine Command
[Tags] secret
[Arguments] ${vic-machine} ${appliance-iso} ${bootstrap-iso} ${certs} ${vol} ${debug} ${additional-args}
${output}= Run Keyword If ${certs} Run ${vic-machine} create --debug ${debug} --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --insecure-registry wdc-harbor-ci.eng.vmware.com --volume-store=%{TEST_DATASTORE}/%{VCH-NAME}-VOL:${vol} --container-network=%{PUBLIC_NETWORK}:public ${vicmachinetls} ${additional-args}
Run Keyword If ${certs} Should Contain ${output} Installer completed successfully
Return From Keyword If ${certs} ${output}
${output}= Run Keyword Unless ${certs} Run ${vic-machine} create --debug ${debug} --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --image-store=%{TEST_DATASTORE} --appliance-iso=${appliance-iso} --bootstrap-iso=${bootstrap-iso} --password=%{TEST_PASSWORD} --force=true --bridge-network=%{BRIDGE_NETWORK} --public-network=%{PUBLIC_NETWORK} --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --insecure-registry wdc-harbor-ci.eng.vmware.com --volume-store=%{TEST_DATASTORE}/%{VCH-NAME}-VOL:${vol} --container-network=%{PUBLIC_NETWORK}:public --no-tlsverify ${additional-args}
Run Keyword Unless ${certs} Should Contain ${output} Installer completed successfully
[Return] ${output}
Run Secret VIC Machine Delete Command
[Tags] secret
[Arguments] ${vch-name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux delete --name=${vch-name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
[Return] ${rc} ${output}
Run Secret VIC Machine Inspect Command
[Tags] secret
[Arguments] ${name}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=${name} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --thumbprint=%{TEST_THUMBPRINT} --compute-resource=%{TEST_RESOURCE}
[Return] ${rc} ${output}
Run VIC Machine Delete Command
${rc} ${output}= Run Secret VIC Machine Delete Command %{VCH-NAME}
Log ${output}
Wait Until Keyword Succeeds 6x 5s Check Delete Success %{VCH-NAME}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully
${output}= Run rm -rf %{VCH-NAME}
[Return] ${output}
Run VIC Machine Inspect Command
[Arguments] ${name}=%{VCH-NAME}
${rc} ${output}= Run Secret VIC Machine Inspect Command ${name}
Log ${output}
Get Docker Params ${output} ${true}
Inspect VCH
[Arguments] ${expected}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${expected}
Wait For VCH Initialization
[Arguments] ${attempts}=12x ${interval}=10 seconds ${name}=%{VCH-NAME}
Wait Until Keyword Succeeds ${attempts} ${interval} VCH Docker Info ${name}
VCH Docker Info
[Arguments] ${name}=%{VCH-NAME}
Run VIC Machine Inspect Command ${name}
${rc}= Run And Return Rc docker %{VCH-PARAMS} info
Should Be Equal As Integers ${rc} 0
Check UpdateInProgress
[Arguments] ${expected}
${rc} ${output}= Run And Return Rc And Output govc vm.info -e %{VCH-NAME} | grep UpdateInProgress
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${expected}
Portlayer Log Should Match Regexp
[Tags] secret
[Arguments] ${pattern}
${out}= Run curl -k -D /tmp/cookies-%{VCH-NAME} -Fusername=%{TEST_USERNAME} -Fpassword=%{TEST_PASSWORD} %{VIC-ADMIN}/authentication
Log ${out}
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/port-layer.log -b /tmp/cookies-%{VCH-NAME} | grep -q -e \'${pattern}\'
Should Be Equal As Integers ${rc} 0
Gather Logs From Test Server
[Arguments] ${name-suffix}=${EMPTY}
Run Keyword And Continue On Failure Run zip %{VCH-NAME}-certs -r %{VCH-NAME}
Secret Curl Container Logs ${name-suffix}
${host}= Get VM Host Name %{VCH-NAME}
Log ${host}
${out}= Run govc datastore.download -host ${host} %{VCH-NAME}/vmware.log %{VCH-NAME}-vmware${name-suffix}.log
Log ${out}
Should Contain ${out} OK
${out}= Run govc datastore.download -host ${host} %{VCH-NAME}/tether.debug %{VCH-NAME}-tether${name-suffix}.debug
Log ${out}
Should Contain ${out} OK
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc logs -log=vmkernel -n=10000 > vmkernel${name-suffix}.log
Secret Curl Container Logs
[Tags] secret
[Arguments] ${name-suffix}=${EMPTY}
${out}= Run curl -k -D vic-admin-cookies -Fusername=%{TEST_USERNAME} -Fpassword=%{TEST_PASSWORD} %{VIC-ADMIN}/authentication
Log ${out}
${out}= Run curl -k -b vic-admin-cookies %{VIC-ADMIN}/container-logs.zip -o ${SUITE NAME}-%{VCH-NAME}-container-logs${name-suffix}.zip
Log ${out}
${out}= Run curl -k -b vic-admin-cookies %{VIC-ADMIN}/logs/port-layer.log
Should Not Contain ${out} SIGSEGV: segmentation violation
Remove File vic-admin-cookies
Check For The Proper Log Files
[Arguments] ${container}
# Ensure container logs are correctly being gathered for debugging purposes
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc} ${output}= Run And Return Rc and Output curl -sk %{VIC-ADMIN}/container-logs.tar.gz -b /tmp/cookies-%{VCH-NAME} | tar tvzf -
Should Be Equal As Integers ${rc} 0
Log ${output}
@{words}= Split String ${container} -
Should Contain Any ${output} @{words}[0]/output.log @{words}[1]/output.log
Should Contain Any ${output} @{words}[0]/vmware.log @{words}[1]/vmware.log
Should Contain Any ${output} @{words}[0]/tether.debug @{words}[1]/tether.debug
Scrape Logs For the Password
[Tags] secret
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/authentication -XPOST -F username=%{TEST_USERNAME} -F password=%{TEST_PASSWORD} -D /tmp/cookies-%{VCH-NAME}
Should Be Equal As Integers ${rc} 0
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/port-layer.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/init.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/docker-personality.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
${rc}= Run And Return Rc curl -sk %{VIC-ADMIN}/logs/vicadmin.log -b /tmp/cookies-%{VCH-NAME} | grep -q "%{TEST_PASSWORD}"
Should Be Equal As Integers ${rc} 1
Remove File /tmp/cookies-%{VCH-NAME}
Cleanup VIC Appliance On Test Server
${sessions}= Run Keyword And Ignore Error Get Session List
Log ${sessions}
${memory}= Run Keyword And Ignore Error Get Hostd Memory Consumption
Log ${memory}
Log To Console Gathering logs from the test server %{VCH-NAME}
Gather Logs From Test Server
Wait Until Keyword Succeeds 3x 5 seconds Remove All Containers
# Exit from Cleanup if VCH-NAME is currently in exception list
${exclude}= Check If VCH Is In Exception vch=%{VCH-NAME}
Return From Keyword If ${exclude}
Log To Console Deleting the VCH appliance %{VCH-NAME}
${output}= Run VIC Machine Delete Command
Log ${output}
Run Keyword And Ignore Error Cleanup VCH Bridge Network %{VCH-NAME}
Run Keyword And Ignore Error Run govc datastore.rm %{VCH-NAME}-VOL
[Return] ${output}
Cleanup VCH Bridge Network
[Arguments] ${name}
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.remove ${name}-bridge
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.portgroup.info
Run Keyword If '%{HOST_TYPE}' == 'ESXi' Should Not Contain ${out} ${name}-bridge
Add VC Distributed Portgroup
[Arguments] ${dvs} ${pg}
${out}= Run govc dvs.portgroup.add -nports 12 -dc=%{TEST_DATACENTER} -dvs=${dvs} ${pg}
Log ${out}
Remove VC Distributed Portgroup
[Arguments] ${pg}
${out}= Run govc object.destroy %{TEST_DATACENTER}/network/${pg}
Log ${out}
Cleanup Datastore On Test Server
${out}= Run govc datastore.ls
Log ${out}
${exceptions}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
${items}= Split To Lines ${out}
:FOR ${item} IN @{items}
\ ${build}= Split String ${item} -
\ # Skip any item that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any item in the exception list
\ @{name}= Split String ${item} -VOL
\ ${skip}= Check If VCH Is In Exception vch=@{name}[0] exceptions=${exceptions}
\ Continue For Loop If ${skip}
\ # Skip any item that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ Log To Console Removing the following item from datastore: ${item}
\ ${out}= Run govc datastore.rm ${item}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${item}
Cleanup Dangling VMs On Test Server
${out}= Run govc ls vm
Log ${out}
${exceptions}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
${vms}= Split To Lines ${out}
:FOR ${vm} IN @{vms}
\ ${vm}= Fetch From Right ${vm} /
\ ${build}= Split String ${vm} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ ${skip}= Check If VCH Is In Exception vch=${vm} exceptions=${exceptions}
\ Continue For Loop If ${skip}
\ # Skip any VM that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc vm.info -json\=true ${vm} | jq -r '.VirtualMachines[0].Config.Uuid'
\ Log To Console Destroying dangling VCH: ${vm}
\ ${rc} ${output}= Run Secret VIC Machine Delete Command ${vm}
\ Run Keyword And Continue On Failure Wait Until Keyword Succeeds 6x 5s Check Delete Success ${vm}
Cleanup Dangling Resource Pools On Test Server
${out}= Run govc ls host/*/Resources/*
Log ${out}
${exceptions}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
${pools}= Split To Lines ${out}
:FOR ${pool} IN @{pools}
\ ${shortPool}= Fetch From Right ${pool} /
\ ${build}= Split String ${shortPool} -
\ # Skip any pool that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip Resource Pools belonging to VCHs in the exception list
\ ${skip}= Check If VCH Is In Exception vch=${shortPool} exceptions=${exceptions}
\ Continue For Loop If ${skip}
\ # Skip any pool that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ Log To Console Destroying dangling resource pool: ${pool}
\ ${output}= Run govc pool.destroy ${pool}
\ Log ${output}
Cleanup Dangling Networks On Test Server
${out}= Run govc ls network
Log ${out}
${exceptions}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} /
\ ${build}= Split String ${net} -
\ # Skip any Network that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any Network that is attached to a VCH in the exception list
\ @{name}= Split String ${net} -bridge
\ ${skip}= Check If VCH Is In Exception vch=@{name}[0] exceptions=${exceptions}
\ Continue For Loop If ${skip}
\ # Skip any Network that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.portgroup.remove ${net}
Cleanup Dangling vSwitches On Test Server
${out}= Run Keyword If '%{HOST_TYPE}' == 'ESXi' Run govc host.vswitch.info | grep VCH
Log ${out}
${exceptions}= Get Environment Variable VM_EXCEPTIONS ${EMPTY}
${nets}= Split To Lines ${out}
:FOR ${net} IN @{nets}
\ ${net}= Fetch From Right ${net} ${SPACE}
\ ${build}= Split String ${net} -
\ # Skip any vSwitch that is not associated with integration tests
\ Continue For Loop If '@{build}[0]' != 'VCH'
\ # Skip any switch that is attached to a VCH in the exception list
\ @{name}= Split String ${net} -bridge
\ ${skip}= Check If VCH Is In Exception vch=@{name}[0] exceptions=${exceptions}
\ Continue For Loop If ${skip}
\ # Skip any vSwitch that is still running
\ ${state}= Get State Of Drone Build @{build}[1]
\ Continue For Loop If '${state}' == 'running'
\ ${uuid}= Run govc host.vswitch.remove ${net}
Get Scratch Disk From VM Info
[Arguments] ${vm}
${disks}= Run govc vm.info -json ${vm} | jq -r '.VirtualMachines[].Layout.Disk[].DiskFile[]'
${disks}= Split To Lines ${disks}
:FOR ${disk} IN @{disks}
\ ${disk}= Fetch From Right ${disk} ${SPACE}
\ ${status}= Run Keyword And Return Status Should Contain ${disk} scratch.vmdk
\ Return From Keyword If ${status} ${disk}
Cleanup Dangling Containers On Test Server
${vms}= Run govc ls vm
${vms}= Split To Lines ${vms}
:FOR ${vm} IN @{vms}
\ # Ignore VCH's, we only care about containers at this point
\ ${status}= Run Keyword And Return Status Should Contain ${vm} VCH
\ Continue For Loop If ${status}
\ ${disk}= Get Scratch Disk From VM Info ${vm}
\ ${vch}= Fetch From Left ${disk} /
\ ${vch}= Split String ${vch} -
\ # Skip any VM that is not associated with integration tests
\ Continue For Loop If '@{vch}[0]' != 'VCH'
\ ${state}= Get State Of Drone Build @{vch}[1]
\ # Skip any VM that is still running
\ Continue For Loop If '${state}' == 'running'
\ # Destroy the VM and remove it from datastore because it is a dangling container
\ Log To Console Cleaning up dangling container: ${vm}
\ ${out}= Run govc vm.destroy ${vm}
\ ${name}= Fetch From Right ${vm} /
\ ${out}= Run govc datastore.rm ${name}
\ Wait Until Keyword Succeeds 6x 5s Check Delete Success ${name}
Get VCH ID
[Arguments] ${vch-name}
${ret}= Run bin/vic-machine-linux ls --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user %{TEST_USERNAME} --password=%{TEST_PASSWORD}
Should Not Contain ${ret} Error
@{lines}= Split To Lines ${ret}
:FOR ${line} IN @{lines}
\ # Get line with name ${vch-name}
\ @{vch}= Split String ${line}
\ ${len}= Get Length ${vch}
\ Continue For Loop If ${len} < 5
\ ${name}= Strip String @{vch}[2]
\ Continue For Loop If '${name}' != '${vch-name}'
\ ${vch-id}= Strip String @{vch}[0]
\ Log To Console \nVCH ID: ${vch-id}
\ Log VCH ID ${vch-id}
\ Return From Keyword ${vch-id}
# VCH upgrade helpers
Install VIC with version to Test Server
[Arguments] ${version}=7315 ${insecureregistry}= ${cleanup}=${true}
Log To Console \nDownloading vic ${version} from gcp...
${rc} ${output}= Run And Return Rc And Output wget https://storage.googleapis.com/vic-engine-builds/vic_${version}.tar.gz -O vic.tar.gz
${rc} ${output}= Run And Return Rc And Output tar zxvf vic.tar.gz
Set Environment Variable TEST_TIMEOUT 20m0s
Install VIC Appliance To Test Server vic-machine=./vic/vic-machine-linux appliance-iso=./vic/appliance.iso bootstrap-iso=./vic/bootstrap.iso certs=${false} cleanup=${cleanup} vol=default ${insecureregistry}
Set Environment Variable VIC-ADMIN %{VCH-IP}:2378
Set Environment Variable INITIAL-VERSION ${version}
Run rm -rf vic.tar.gz vic
Clean up VIC Appliance And Local Binary
Cleanup VIC Appliance On Test Server
Run rm -rf vic.tar.gz vic
Upgrade
Log To Console \nUpgrading VCH...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
Log ${output}
Should Contain ${output} Completed successfully
Should Not Contain ${output} Rolling back upgrade
Should Be Equal As Integers ${rc} 0
Upgrade with ID
Log To Console \nUpgrading VCH using vch ID...
${vch-id}= Get VCH ID %{VCH-NAME}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --id=${vch-id} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT}
Log ${output}
Should Contain ${output} Completed successfully
Should Not Contain ${output} Rolling back upgrade
Should Be Equal As Integers ${rc} 0
Check Upgraded Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Log ${output}
Should Contain ${output} Completed successfully
Should Contain ${output} @{vers}[2]
Should Not Contain ${output} %{INITIAL-VERSION}
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Check Original Version
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux version
@{vers}= Split String ${output}
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux inspect --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE}
Log ${output}
Should Contain ${output} Completed successfully
Should Contain ${output} %{INITIAL-VERSION}
Should Be Equal As Integers ${rc} 0
Log ${output}
Get Docker Params ${output} ${true}
Rollback
Log To Console \nTesting rollback...
${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux upgrade --debug 1 --name=%{VCH-NAME} --target=%{TEST_URL}%{TEST_DATACENTER} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD} --force=true --compute-resource=%{TEST_RESOURCE} --timeout %{TEST_TIMEOUT} --rollback
Log ${output}
Should Contain ${output} Completed successfully
Should Be Equal As Integers ${rc} 0
Enable VCH SSH
[Arguments] ${vic-machine}=bin/vic-machine-linux ${rootpw}=%{TEST_PASSWORD} ${target}=%{TEST_URL}%{TEST_DATACENTER} ${password}=%{TEST_PASSWORD} ${thumbprint}=%{TEST_THUMBPRINT} ${name}=%{VCH-NAME} ${user}=%{TEST_USERNAME} ${resource}=%{TEST_RESOURCE}
Log To Console \nEnable SSH on vch...
${rc} ${output}= Run And Return Rc And Output ${vic-machine} debug --rootpw ${rootpw} --target ${target} --password ${password} --thumbprint ${thumbprint} --name ${name} --user ${user} --compute-resource ${resource} --enable-ssh
Log ${output}
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully

View File

@@ -0,0 +1,278 @@
# 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 contains any keywords dealing with operations being performed on a Vsphere instance, mostly govc wrappers
*** Keywords ***
Power On VM OOB
[Arguments] ${vm}
${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 And Return Rc And Output govc vm.power -off "${vm}"
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 object.method -name Destroy_Task -enable %{TEST_DATACENTER}/vm/${vm}
Run Keyword If '%{HOST_TYPE}' == 'VC' 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}
Should Contain ${output} entering maintenance mode... OK
Remove Host From Maintenance Mode
${rc} ${output}= Run And Return Rc And Output govc host.maintenance.exit -host.ip=%{TEST_URL}
Should Contain ${output} exiting maintenance mode... OK
Reboot VM
[Arguments] ${vm}
Log To Console Rebooting ${vm} ...
Power Off VM OOB ${vm}
Power On VM OOB ${vm}
Log To Console ${vm} Powered On
Wait Until VM Powers On
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${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
Fail VM did not power on within 30 seconds
Wait Until VM Powers Off
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${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
Fail VM did not power off within 30 seconds
Wait Until VM Is Destroyed
[Arguments] ${vm}
:FOR ${idx} IN RANGE 0 30
\ ${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
Fail VM was not destroyed within 30 seconds
Get VM IP
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.ip ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
Get VM Host Name
[Arguments] ${vm}
${out}= Run govc vm.info ${vm}
${out}= Split To Lines ${out}
${host}= Fetch From Right @{out}[-1] ${SPACE}
[Return] ${host}
Get VM Info
[Arguments] ${vm}
${rc} ${out}= Run And Return Rc And Output govc vm.info -r ${vm}
Should Be Equal As Integers ${rc} 0
[Return] ${out}
Get VM Moid
[Arguments] ${vm}
${rc} ${output}= Run And Return Rc And Output govc vm.info -dump -json ${vm} | jq -c '.VirtualMachines[] | .Self.Value'
Should Be Equal As Integers ${rc} 0
[Return] ${output}
Check ImageStore
${rc} ${output}= Run And Return Rc And Output govc datastore.ls -R -ds=%{TEST_DATASTORE} %{VCH-NAME}/VIC
Should Be Equal As Integers ${rc} 0
Log ${output}
vMotion A VM
[Arguments] ${vm}
${host}= Get VM Host Name ${vm}
${status}= Run Keyword And Return Status Should Contain ${host} ${esx1-ip}
Run Keyword If ${status} Run govc vm.migrate -host cls/${esx2-ip} -pool cls/Resources ${vm}
Run Keyword Unless ${status} Run govc vm.migrate -host cls/${esx1-ip} -pool cls/Resources ${vm}
vMotion A VM And Wait
[Arguments] ${vm} ${attempts} ${interval}
${host}= Get VM Host Name ${vm}
${status}= Run Keyword And Return Status Should Contain ${host} ${esx1-ip}
Run Keyword If ${status} Run govc vm.migrate -host cls/${esx2-ip} -pool cls/Resources ${vm}
Run Keyword Unless ${status} Run govc vm.migrate -host cls/${esx1-ip} -pool cls/Resources ${vm}
Wait Until Keyword Succeeds ${attempts} ${interval} VM Host Has Changed ${host} ${vm}
VM Host Has Changed
[Arguments] ${oldHost} ${vm}
${curHost}= Get VM Host Name ${vm}
Should Not Be Equal ${oldHost} ${curHost}
Create Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.create -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Revert Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.revert -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Delete Test Server Snapshot
[Arguments] ${vm} ${snapshot}
Set Environment Variable GOVC_URL %{BUILD_SERVER}
${rc} ${out}= Run And Return Rc And Output govc snapshot.remove -vm ${vm} ${snapshot}
Should Be Equal As Integers ${rc} 0
Should Be Empty ${out}
Set Environment Variable GOVC_URL %{TEST_USERNAME}:%{TEST_PASSWORD}@%{TEST_URL}
Setup Snapshot
${hostname}= Get Test Server Hostname
Set Environment Variable TEST_HOSTNAME ${hostname}
Set Environment Variable SNAPSHOT vic-ci-test-%{DRONE_BUILD_NUMBER}
Create Test Server Snapshot %{TEST_HOSTNAME} %{SNAPSHOT}
Get Datacenter Name
${out}= Run govc datacenter.info
${out}= Split To Lines ${out}
${name}= Fetch From Right @{out}[0] ${SPACE}
[Return] ${name}
Get Datacenter ID
${name}= Get Datacenter Name
${id}= Run govc datacenter.info -k --json -dc ${name} | jq .Datacenters[0].Self.Value
[Return] ${id}
Get Test Server Hostname
[Tags] secret
${hostname}= Run sshpass -p $TEST_PASSWORD ssh $TEST_USERNAME@$TEST_URL hostname
[Return] ${hostname}
Check Delete Success
[Arguments] ${name}
${out}= Run govc ls vm
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc datastore.ls
Log ${out}
Should Not Contain ${out} ${name}
${out}= Run govc ls host/*/Resources/*
Log ${out}
Should Not Contain ${out} ${name}
Gather Logs From ESX Server
Environment Variable Should Be Set TEST_URL
${out}= Run govc logs.download
Change Log Level On Server
[Arguments] ${level}
${out}= Run govc host.option.set Config.HostAgent.log.level ${level}
Should Be Empty ${out}
Add Vsphere License
[Tags] secret
[Arguments] ${license}
${out}= Run govc license.add ${license}
Should Contain ${out} Key:
Assign Vsphere License
[Tags] secret
[Arguments] ${license} ${host}
${out}= Run govc license.assign -host ${host} ${license}
Should Contain ${out} Key:
Assign vCenter License
[Tags] secret
[Arguments] ${license}
${out}= Run govc license.assign ${license}
Should Contain ${out} Key:
Add Host To VCenter
[Arguments] ${host} ${user} ${dc} ${pw}
:FOR ${idx} IN RANGE 1 4
\ ${out}= Run govc cluster.add -hostname=${host} -username=${user} -dc=${dc} -password=${pw} -noverify=true
\ ${status}= Run Keyword And Return Status Should Contain ${out} OK
\ Return From Keyword If ${status}
\ Sleep 3 minutes
Fail Failed to add the host to the VC in 3 attempts
Get Host Firewall Enabled
${output}= Run govc host.esxcli network firewall get
Should Contain ${output} Enabled
@{output}= Split To Lines ${output}
:FOR ${line} IN @{output}
\ Run Keyword If "Enabled" in '''${line}''' Set Test Variable ${out} ${line}
${enabled}= Fetch From Right ${out} :
${enabled}= Strip String ${enabled}
Return From Keyword If '${enabled}' == 'false' ${false}
Return From Keyword If '${enabled}' == 'true' ${true}
Enable Host Firewall
Run govc host.esxcli network firewall set --enabled true
Disable Host Firewall
Run govc host.esxcli network firewall set --enabled false
Check VM Guestinfo
[Arguments] ${vm} ${str}
${rc} ${output}= Run And Return Rc And Output govc vm.info -e ${vm} | grep ${str}
Should Be Equal As Integers ${rc} 0
[Return] ${output}
Get Session List
${rc} ${sessions}= Run And Return Rc And Output govc session.ls
Run Keyword If ${rc} != 0 Fatal Error The host appears to be in an unrecoverable state
[Return] ${sessions}
Get Hostd ID
[Tags] secret
Return From Keyword If '%{HOST_TYPE}' != 'ESXi' Get Hostd ID keyword not valid for non-ESXi servers
Open Connection %{TEST_URL}
Login %{TEST_USERNAME} %{TEST_PASSWORD}
${out}= Execute Command memstats -r group-stats | grep 'hostd '
${out}= Strip String ${out}
${id}= Fetch From Left ${out} ${SPACE}
Close Connection
[Return] ${id}
Get Hostd Memory Consumption
[Tags] secret
Return From Keyword If '%{HOST_TYPE}' != 'ESXi' Get Hostd Memory Consumption keyword not valid for non-ESXi servers
${id}= Get Hostd ID
Log to console ${id}
Open Connection %{TEST_URL}
Login %{TEST_USERNAME} %{TEST_PASSWORD}
${out}= Execute Command memstats -r group-stats -v -g ${id} -s name:min:max:consumed -l 2
Log to console ${out}
Close Connection
[Return] ${out}

Binary file not shown.

View File

@@ -0,0 +1,23 @@
# 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
# docker build --no-cache -t jakedsouza/group-1-19-docker-verify-volume-files:1.0 -f Dockerfile.1-19-Docker-Verify-Volume-Files .
# docker push jakedsouza/group-1-19-docker-verify-volume-files:1.0
FROM alpine:latest
RUN mkdir -p /etc/example/thisshouldexist
RUN echo "TestFile" >> /etc/example/testfile.txt
VOLUME ["/etc/example"]

View File

@@ -0,0 +1,4 @@
FROM busybox:latest
RUN addgroup newuser && adduser -H -S newuser -G newuser
USER newuser
CMD id

View File

@@ -0,0 +1,3 @@
FROM busybox:latest
USER 2000
CMD id

View File

@@ -0,0 +1,3 @@
from busybox:latest
user 2000:2000
cmd id

View File

@@ -0,0 +1,3 @@
simple:
image: busybox:latest
command: ls

View File

@@ -0,0 +1,4 @@
simple:
image: busybox:latest
container_name: my-web-container
command: ls

View File

@@ -0,0 +1,4 @@
FROM busybox:latest
LABEL com.docker.compose.test_image=true
VOLUME /data
CMD top

View File

@@ -0,0 +1,11 @@
version: '2'
services:
web:
image: busybox
depends_on:
- db
- redis
redis:
image: redis
db:
image: postgres

View File

@@ -0,0 +1,4 @@
web:
image: busybox
command: /bin/true
env_file: ./test.env

View File

@@ -0,0 +1 @@
FOO=1

View File

@@ -0,0 +1,7 @@
service:
image: busybox:latest
command: top
environment:
foo: bar
hello: world

View File

@@ -0,0 +1,12 @@
foo:
image: busybox
bar:
image: busybox
web:
extends:
file: circle-2.yml
service: other
baz:
image: busybox
quux:
image: busybox

View File

@@ -0,0 +1,12 @@
foo:
image: busybox
bar:
image: busybox
other:
extends:
file: circle-1.yml
service: web
baz:
image: busybox
quux:
image: busybox

View File

@@ -0,0 +1,13 @@
web:
extends:
file: common.yml
service: web
environment:
- FOO=2
- BAZ=3
labels: ['label=one']
ulimits:
nproc: 65535
memlock:
soft: 1024
hard: 2048

View File

@@ -0,0 +1,7 @@
web:
image: busybox
command: /bin/true
net: host
environment:
- FOO=1
- BAR=1

View File

@@ -0,0 +1,17 @@
myweb:
extends:
file: common.yml
service: web
command: top
links:
- "mydb:db"
environment:
# leave FOO alone
# override BAR
BAR: "2"
# add BAZ
BAZ: "2"
net: bridge
mydb:
image: busybox
command: top

View File

@@ -0,0 +1,9 @@
version: '2.1'
services:
demo:
image: foobar:latest
healthcheck:
test: ["CMD", "/health.sh"]
interval: 10s
timeout: 5s
retries: 36

View File

@@ -0,0 +1,6 @@
version: '2.1'
services:
demo:
extends:
file: healthcheck-1.yml
service: demo

View File

@@ -0,0 +1,11 @@
mydb:
build: '.'
myweb:
build: '.'
extends:
service: web
command: top
web:
build: '.'
links:
- "mydb:db"

View File

@@ -0,0 +1,12 @@
version: "2"
services:
myweb:
build: '.'
extends:
service: web
command: top
web:
build: '.'
network_mode: "service:net"
net:
build: '.'

View File

@@ -0,0 +1,8 @@
myweb:
build: '.'
extends:
service: web
command: top
web:
build: '.'
net: "container:db"

View File

@@ -0,0 +1,9 @@
myweb:
build: '.'
extends:
service: web
command: top
web:
build: '.'
volumes_from:
- "db"

View File

@@ -0,0 +1,6 @@
webintermediate:
extends:
file: common.yml
service: web
environment:
- "FOO=2"

View File

@@ -0,0 +1,6 @@
myweb:
extends:
file: nested-intermediate.yml
service: webintermediate
environment:
- "BAR=2"

View File

@@ -0,0 +1,9 @@
myweb:
extends:
service: web
environment:
- "BAR=1"
web:
image: busybox
environment:
- "BAZ=3"

View File

@@ -0,0 +1,6 @@
dnebase:
build: nonexistent.path
command: /bin/true
environment:
- FOO=1
- BAR=1

View File

@@ -0,0 +1,8 @@
dnechild:
extends:
file: nonexistent-path-base.yml
service: dnebase
image: busybox
command: /bin/true
environment:
- BAR=2

View File

@@ -0,0 +1,4 @@
web:
image: busybox
extends:
service: foo

View File

@@ -0,0 +1,4 @@
myweb:
extends:
file: valid-composite-extends.yml
service: web

View File

@@ -0,0 +1,5 @@
myweb:
build: '.'
extends:
file: 'valid-composite-extends.yml'
service: web

View File

@@ -0,0 +1,17 @@
myweb:
extends:
file: specify-file-as-self.yml
service: web
environment:
- "BAR=1"
web:
extends:
file: specify-file-as-self.yml
service: otherweb
image: busybox
environment:
- "BAZ=3"
otherweb:
image: busybox
environment:
- "YEP=1"

View File

@@ -0,0 +1,6 @@
myweb:
build: '.'
extends:
file: valid-common.yml
service: common-config
command: top

View File

@@ -0,0 +1,3 @@
common-config:
environment:
- FOO=1

View File

@@ -0,0 +1,2 @@
web:
command: top

View File

@@ -0,0 +1,3 @@
web:
build: '.'
hostname: "host-${HOSTNAME_VALUE}"

View File

@@ -0,0 +1,5 @@
myweb:
extends:
service: web
file: valid-interpolation-2.yml
command: top

View File

@@ -0,0 +1,15 @@
base:
image: busybox
environment:
- "BAR=1"
verbose:
extends:
service: base
environment:
- "FOO=1"
shorthand:
extends: base
environment:
- "FOO=2"

View File

@@ -0,0 +1,6 @@
version: '2'
services:
myservice:
image: redis
group_add:
- mail

View File

@@ -0,0 +1,8 @@
simple:
image: busybox:latest
labels:
com.example.department: "Finance"
command: top
another:
image: busybox:latest
command: ls

View File

@@ -0,0 +1,11 @@
db:
image: busybox:latest
command: top
web:
image: busybox:latest
command: top
links:
- db:db
console:
image: busybox:latest
command: top

View File

@@ -0,0 +1,8 @@
version: "2"
networks:
default:
driver: bridge
services:
web:
image: busybox
command: top

View File

@@ -0,0 +1,13 @@
version: "2"
services:
simple:
image: busybox:latest
command: top
another:
image: busybox:latest
command: top
networks:
default:
driver: bridge
driver_opts:
"com.docker.network.bridge.enable_icc": "false"

View File

@@ -0,0 +1,21 @@
version: "2"
services:
web:
image: busybox
command: top
networks: ["front"]
app:
image: busybox
command: top
networks: ["front", "back"]
links:
- "db:database"
db:
image: busybox
command: top
networks: ["back"]
networks:
front: {}
back: {}

View File

@@ -0,0 +1,12 @@
version: "2"
services:
simple:
image: busybox:latest
command: top
another:
image: busybox:latest
command: top
networks:
default:
external:
name: composetest_external_network

View File

@@ -0,0 +1,16 @@
version: "2"
services:
web:
image: busybox
command: top
networks:
- networks_foo
- bar
networks:
networks_foo:
external: true
bar:
external:
name: networks_bar

View File

@@ -0,0 +1,10 @@
version: "2"
services:
web:
image: busybox
command: top
networks: ["foo"]
networks:
bar: {}

View File

@@ -0,0 +1,16 @@
version: "2"
services:
web:
image: busybox
command: top
networks:
front:
aliases:
- forward_facing
- ahead
back:
networks:
front: {}
back: {}

View File

@@ -0,0 +1,13 @@
version: "2"
services:
web:
image: busybox
command: top
networks:
- internal
networks:
internal:
driver: bridge
internal: True

View File

@@ -0,0 +1,13 @@
version: "2.1"
services:
web:
image: busybox
command: top
networks:
- network_with_label
networks:
network_with_label:
labels:
- "label_key=label_val"

View File

@@ -0,0 +1,31 @@
version: "2"
services:
my_container:
image: busybox
command: top
bridge:
image: busybox
command: top
network_mode: bridge
service:
image: busybox
command: top
network_mode: "service:bridge"
container:
image: busybox
command: top
network_mode: "container:my_container"
host:
image: busybox
command: top
network_mode: host
none:
image: busybox
command: top
network_mode: none

View File

@@ -0,0 +1,19 @@
version: '2.1'
services:
app:
image: busybox
command: /bin/top
networks:
app_net:
ipv4_address: 172.20.238.10
networks:
app_net:
driver: bridge
enable_ipv6: true
ipam:
driver: default
config:
- subnet: 172.20.238.0/24
gateway: 172.20.238.1

View File

@@ -0,0 +1,8 @@
simple:
image: busybox:latest
command: top
ports:
- '3000'
- '49152:3001'
- '49153-49154:3002-3003'

View File

@@ -0,0 +1,15 @@
version: '3.2'
services:
simple:
image: busybox:latest
command: top
ports:
- target: 3000
- target: 3001
published: 49152
- target: 3002
published: 49153
protocol: tcp
- target: 3003
published: 49154
protocol: udp

View File

@@ -0,0 +1,10 @@
simple:
image: busybox:latest
command:
- sh
- '-c'
- |
trap 'exit 0' SIGINT
trap 'exit 1' SIGTERM
while true; do :; done
stop_signal: SIGINT

View File

@@ -0,0 +1,2 @@
version: '2.1'
services: {}

View File

@@ -0,0 +1,16 @@
version: "2.1"
services:
web:
image: busybox
command: top
volumes:
- foo:/var/lib/
- bar:/etc/
volumes:
foo:
external: true
bar:
external:
name: some_bar

View File

@@ -0,0 +1,13 @@
version: "2.1"
services:
web:
image: busybox
command: top
volumes:
- volume_with_label:/data
volumes:
volume_with_label:
labels:
- "label_key=label_val"

View File

@@ -0,0 +1,42 @@
# Copyright 2017-2018 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
import os
from enum import Enum
class TestEnvironment(Enum):
LOCAL = 0
DRONE = 1
LONGEVITY = 2
def getEnvironment():
if (os.environ.has_key("DRONE_BUILD_NUMBER") and (int(os.environ['DRONE_BUILD_NUMBER']) != 0)):
return TestEnvironment.DRONE
elif os.environ.has_key("LONGEVITY"):
return TestEnvironment.LONGEVITY
else:
return TestEnvironment.LOCAL
def getName(image):
return {TestEnvironment.DRONE: 'wdc-harbor-ci.eng.vmware.com/default-project/{}'.format(image),
TestEnvironment.LONGEVITY: 'vic-executor1.vcna.io/library/{}'.format(image),
TestEnvironment.LOCAL: image}[getEnvironment()]
# this global variable (images) is used by the Longevity scripts. If you change this, change those!
# and don't inline it!
images = ['busybox', 'alpine', 'nginx','debian', 'ubuntu', 'redis']
for image in images:
exec("{} = '{}'".format(image.upper().replace(':', '_').replace('.', '_'), getName(image)))

View File

@@ -0,0 +1,116 @@
oneGB = 1 * 1000 * 1000 # in KB
$testbed = Proc.new do
{
"name" => "vic-simple-cluster",
"version" => 3,
"esx" => (0..2).map do | idx |
{
"name" => "esx.#{idx}",
"vc" => "vc.0",
"style" => "fullInstall",
"desiredPassword" => "e2eFunctionalTest",
"disks" => [ 30 * oneGB, 30 * oneGB, 30 * oneGB],
"nics" => 2,
"mountNfs" => ["nfs.0"],
"clusterName" => "cls",
}
end,
"nfs" => [
{
"name" => "nfs.0",
"type" => "NFS41"
}
],
"vcs" => [
{
"name" => "vc.0",
"type" => "vcva",
"dcName" => "dc1",
"clusters" => [{"name" => "cls", "vsan" => false, "enableDrs" => true, "enableHA" => true}],
"addHosts" => "allInSameCluster",
}
],
"postBoot" => Proc.new do |runId, testbedSpec, vmList, catApi, logDir|
esxList = vmList['esx']
esxList.each do |host|
host.ssh do |ssh|
ssh.exec!("esxcli network firewall set -e false")
end
end
vc = vmList['vc'][0]
vim = VIM.connect vc.rbvmomiConnectSpec
datacenters = vim.serviceInstance.content.rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
raise "Couldn't find a Datacenter precreated" if datacenters.length == 0
datacenter = datacenters.first
Log.info "Found a datacenter successfully in the system, name: #{datacenter.name}"
clusters = datacenter.hostFolder.children
raise "Couldn't find a cluster precreated" if clusters.length == 0
cluster = clusters.first
Log.info "Found a cluster successfully in the system, name: #{cluster.name}"
dvs = datacenter.networkFolder.CreateDVS_Task(
:spec => {
:configSpec => {
:name => "test-ds"
},
}
).wait_for_completion
Log.info "Vds DSwitch created"
dvpg1 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "management",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "management DPG created"
dvpg2 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "vm-network",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "vm-network DPG created"
dvpg3 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "bridge",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "bridge DPG created"
Log.info "Add hosts to the DVS"
onecluster_pnic_spec = [ VIM::DistributedVirtualSwitchHostMemberPnicSpec({:pnicDevice => 'vmnic1'}) ]
dvs_config = VIM::DVSConfigSpec({
:configVersion => dvs.config.configVersion,
:host => cluster.host.map do |host|
{
:operation => :add,
:host => host,
:backing => VIM::DistributedVirtualSwitchHostMemberPnicBacking({
:pnicSpec => onecluster_pnic_spec
})
}
end
})
dvs.ReconfigureDvs_Task(:spec => dvs_config).wait_for_completion
Log.info "Hosts added to DVS successfully"
end
}
end

View File

@@ -0,0 +1,158 @@
oneGB = 1 * 1000 * 1000 # in KB
$testbed = Proc.new do |type, esxStyle, vcStyle, dbType, location|
esxStyle ||= 'pxeBoot'
vcStyle ||= 'vpxInstall'
esxStyle = esxStyle.to_s
vcStyle = vcStyle.to_s
sharedStorageStyle = 'iscsi'
dbType = dbType.to_s
nameParts = ['vic', 'vsan', type, esxStyle, vcStyle]
if dbType != 'embedded'
nameParts << dbType
end
if type == 'complex'
numEsx = 8
numCPUs = 4
vmsPerHost = 1
addHosts = 'vsan-complex-vcqafvt'
elsif type == 'simple'
numEsx = 4
numCPUs = 4
vmsPerHost = 0
addHosts = 'vsan-simple-vcqafvt'
elsif type == 'complexCPU'
numEsx = 8
numCPUs = 2
vmsPerHost = 1
addHosts = 'vsan-complex-vcqafvt'
else
numEsx = 4
numCPUs = 2
vmsPerHost = 0
addHosts = 'vsan-simple-vcqafvt'
end
testbed = {
'name' => nameParts.join('-'),
'esx' => (0...numEsx).map do |i|
{
'name' => "esx.#{i}",
'style' => esxStyle,
'disks' => [ 30 * oneGB, 30 * oneGB, 30 * oneGB],
'freeLocalLuns' => 1,
'freeSharedLuns' => 2,
'numMem' => 13 * 1024,
'numCPUs' => numCPUs,
'ssds' => [ 5*oneGB ],
'nics' => 2,
'staf' => false,
'desiredPassword' => 'e2eFunctionalTest',
'vmotionNics' => ['vmk0'],
'mountNfs' => ['nfs.0'],
}
end,
'vc' => {
'type' => vcStyle,
'additionalScript' => [], # XXX: Create users
'addHosts' => addHosts,
'linuxCertFile' => TestngLauncher.vcvaCertFile,
'dbType' => dbType,
},
'vsan' => true,
'postBoot' => Proc.new do |runId, testbedSpec, vc, esxList, iscsiList|
ovf = NimbusUtils.get_absolute_ovf("CentOS/VM_OVF10.ovf")
if location && $nimbusEnv && $nimbusEnv['NIMBUS'] =~ /gamma/
ovf = 'http://10.116.111.50/testwareTestCentOS/VM_OVF10.ovf'
end
cloudVc = vc
vim = VIM.connect cloudVc.rbvmomiConnectSpec
datacenters = vim.serviceInstance.content.rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
raise "Couldn't find a Datacenter precreated" if datacenters.length == 0
datacenter = datacenters.first
Log.info "Found a datacenter successfully in the system, name: #{datacenter.name}"
clusters = datacenter.hostFolder.children
raise "Couldn't find a cluster precreated" if clusters.length == 0
cluster = clusters.first
Log.info "Found a cluster successfully in the system, name: #{cluster.name}"
dvs = datacenter.networkFolder.CreateDVS_Task(
:spec => {
:configSpec => {
:name => "test-ds"
},
}
).wait_for_completion
Log.info "Vds DSwitch created"
dvpg1 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "management",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "management DPG created"
dvpg2 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "vm-network",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "vm-network DPG created"
dvpg3 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "bridge",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "bridge DPG created"
VcQaTestbedCommon.postBoot(
vmsPerHost,
NimbusUtils.get_absolute_ovf("CentOS/VM_OVF10.ovf"),
runId, testbedSpec, vc, esxList, iscsiList)
end,
'nfs' => [
{
'name' => "nfs.0"
},
],
}
if dbType == 'mssql'
testbed['genericVM'] ||= []
testbed['genericVM'] << {
'name' => 'vc-mssql',
'type' => 'mssql2k8',
}
testbed['vc']['dbHost'] = 'vc-mssql'
end
testbed = VcQaTestbedCommon.addSharedDisks testbed, [10, 2, 10, 2], sharedStorageStyle # 2 x 10gb shared vmfs, 2 x 2gb free luns as defined by 'freeSharedLuns', DON'T CHANGE THE ORDERING UNLESS YOU KNOW WHAT YOU'RE DOING!
testbed
end
[:pxeBoot, :fullInstall].each do |esxStyle|
[:vpxInstall, :vcva].each do |vcStyle|
[:embedded, :mssql, :oracle].each do |dbType|
['complex', 'simple', 'complexCPU', 'simpleCPU'].each do |type|
testbedSpec = $testbed.call(type, esxStyle, vcStyle, dbType)
Nimbus::TestbedRegistry.registerTestbed testbedSpec
end
end
end
end