test/api: move govc installation to common/vsphere.sh

Move the installation of the VSphere client out of the
`api/common/aws.sh` `installClient()` function into a dedicated
`installClientVSphere()` function in `api/common/vsphere.sh`.

Rename the `installClient()` in `api/common/aws.sh` to
`installAWSClient()`. Introduce `installClient()` in both,
`api/aws.sh` and `api/aws.s3.sh`, which calls `installAWSClient()`.

Call `installClientVSphere()` conditionally when testing VMDK image type
in `api/aws.s3.sh` and `api/generic.s3.sh`.
This commit is contained in:
Tomáš Hozza 2022-09-14 22:09:00 +02:00 committed by Tomáš Hozza
parent 2f6c238b7a
commit 9e9aec5b53
5 changed files with 44 additions and 20 deletions

View file

@ -2,6 +2,7 @@
source /usr/libexec/tests/osbuild-composer/api/common/aws.sh
source /usr/libexec/tests/osbuild-composer/api/common/common.sh
source /usr/libexec/tests/osbuild-composer/api/common/vsphere.sh
source /usr/libexec/tests/osbuild-composer/api/common/s3.sh
# Check that needed variables are set to access AWS.
@ -33,6 +34,14 @@ function cleanup() {
fi
}
function installClient() {
installAWSClient
if [ "${IMAGE_TYPE}" == "${IMAGE_TYPE_VSPHERE}" ]; then
installClientVSphere
fi
}
function createReqFile() {
case ${IMAGE_TYPE} in
"$IMAGE_TYPE_EDGE_COMMIT"|"$IMAGE_TYPE_EDGE_CONTAINER"|"$IMAGE_TYPE_EDGE_INSTALLER"|"$IMAGE_TYPE_IMAGE_INSTALLER")

View file

@ -27,6 +27,9 @@ function cleanup() {
fi
}
function installClient() {
installAWSClient
}
function createReqFile() {
AWS_SNAPSHOT_NAME=${TEST_ID}

View file

@ -1,7 +1,7 @@
#!/usr/bin/bash
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function installClient() {
function installAWSClient() {
if ! hash aws; then
echo "Using 'awscli' from a container"
sudo "${CONTAINER_RUNTIME}" pull "${CONTAINER_IMAGE_CLOUD_TOOLS}"
@ -16,25 +16,6 @@ function installClient() {
AWS_CMD="aws --region $AWS_REGION --output json --color on"
fi
$AWS_CMD --version
if ! hash govc; then
ARCH="$(uname -m)"
if [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
greenprint "Installing govc"
pushd "${WORKDIR}" || exit 1
curl -Ls --retry 5 --output govc.tar.gz \
"https://github.com/vmware/govmomi/releases/download/v0.29.0/govc_Linux_$ARCH.tar.gz"
tar -xvf govc.tar.gz
GOVC_CMD="${WORKDIR}/govc"
chmod +x "${GOVC_CMD}"
popd || exit 1
else
echo "Using pre-installed 'govc' from the system"
GOVC_CMD="govc"
fi
$GOVC_CMD version
}
# Log into AWS

View file

@ -0,0 +1,26 @@
#!/usr/bin/bash
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function installClientVSphere() {
if ! hash govc; then
ARCH="$(uname -m)"
if [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi
greenprint "Installing govc"
pushd "${WORKDIR}" || exit 1
curl -Ls --retry 5 --output govc.tar.gz \
"https://github.com/vmware/govmomi/releases/download/v0.29.0/govc_Linux_$ARCH.tar.gz"
tar -xvf govc.tar.gz
GOVC_CMD="${WORKDIR}/govc"
chmod +x "${GOVC_CMD}"
popd || exit 1
else
echo "Using pre-installed 'govc' from the system"
GOVC_CMD="govc"
fi
$GOVC_CMD version
}

View file

@ -1,6 +1,7 @@
#!/usr/bin/bash
source /usr/libexec/tests/osbuild-composer/api/common/common.sh
source /usr/libexec/tests/osbuild-composer/api/common/vsphere.sh
source /usr/libexec/tests/osbuild-composer/api/common/s3.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
@ -56,6 +57,10 @@ function installClient() {
AWS_CMD+=" --region $MINIO_REGION --output json --color on --endpoint-url $MINIO_ENDPOINT"
$AWS_CMD --version
if [ "${IMAGE_TYPE}" == "${IMAGE_TYPE_VSPHERE}" ]; then
installClientVSphere
fi
# Configure the local server (retry until the service is up)
MINIO_CONFIGURE_RETRY=0
MINIO_CONFIGURE_MAX_RETRY=5