test/api/common: add cleanupVSphere() and use it where appropriate
Clean up VSphere in all S3 test case implementations, which were previously not cleaning up after themselves.
This commit is contained in:
parent
f1bf5b32f9
commit
ff82dec37f
3 changed files with 38 additions and 0 deletions
|
|
@ -31,6 +31,10 @@ function cleanup() {
|
|||
if [ -n "$AWS_CMD" ]; then
|
||||
$AWS_CMD s3 rm "${S3_URI}"
|
||||
fi
|
||||
|
||||
if [ "${IMAGE_TYPE}" == "${IMAGE_TYPE_VSPHERE}" ]; then
|
||||
cleanupVSphere
|
||||
fi
|
||||
}
|
||||
|
||||
function installClient() {
|
||||
|
|
|
|||
|
|
@ -215,3 +215,34 @@ function verifyInVSphere() {
|
|||
|
||||
greenprint "✅ Successfully verified VSphere image with cloud-init"
|
||||
}
|
||||
|
||||
function cleanupVSphere() {
|
||||
# since this function can be called at any time, ensure that we don't expand unbound variables
|
||||
GOVC_CMD="${GOVC_CMD:-}"
|
||||
VSPHERE_VM_NAME="${VSPHERE_VM_NAME:-}"
|
||||
VSPHERE_CIDATA_ISO_PATH="${VSPHERE_CIDATA_ISO_PATH:-}"
|
||||
|
||||
greenprint "🧹 Cleaning up the VSphere VM"
|
||||
$GOVC_CMD vm.destroy \
|
||||
-u "${GOVMOMI_USERNAME}:${GOVMOMI_PASSWORD}@${GOVMOMI_URL}" \
|
||||
-k=true \
|
||||
-dc="${GOVC_DATACENTER}" \
|
||||
"${VSPHERE_VM_NAME}"
|
||||
|
||||
greenprint "🧹 Cleaning up the VSphere Datastore"
|
||||
$GOVC_CMD datastore.rm \
|
||||
-u "${GOVMOMI_USERNAME}:${GOVMOMI_PASSWORD}@${GOVMOMI_URL}" \
|
||||
-k=true \
|
||||
-dc="${GOVC_DATACENTER}" \
|
||||
-ds="${GOVMOMI_DATASTORE}" \
|
||||
-f \
|
||||
"${VSPHERE_CIDATA_ISO_PATH}"
|
||||
|
||||
$GOVC_CMD datastore.rm \
|
||||
-u "${GOVMOMI_USERNAME}:${GOVMOMI_PASSWORD}@${GOVMOMI_URL}" \
|
||||
-k=true \
|
||||
-dc="${GOVC_DATACENTER}" \
|
||||
-ds="${GOVMOMI_DATASTORE}" \
|
||||
-f \
|
||||
"${VSPHERE_VM_NAME}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ function cleanup() {
|
|||
if [ -n "${MINIO_CONTAINER_NAME}" ]; then
|
||||
sudo "${CONTAINER_RUNTIME}" kill "${MINIO_CONTAINER_NAME}"
|
||||
fi
|
||||
if [ "${IMAGE_TYPE}" == "${IMAGE_TYPE_VSPHERE}" ]; then
|
||||
cleanupVSphere
|
||||
fi
|
||||
}
|
||||
|
||||
function installClient() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue