From 09a576ed07ffaf68e7f8553cf09c938d65cae534 Mon Sep 17 00:00:00 2001 From: Jakub Rusz Date: Wed, 25 Aug 2021 19:45:43 +0200 Subject: [PATCH] tests: update azure.sh and aws.sh for use with weldr-client This enables the tests to run with both original composer-cli and the new weldr-client. --- test/cases/aws.sh | 20 ++++++++++++++++++-- test/cases/azure.sh | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/test/cases/aws.sh b/test/cases/aws.sh index 59b392e32..0164cba01 100755 --- a/test/cases/aws.sh +++ b/test/cases/aws.sh @@ -90,6 +90,14 @@ store_instance_screenshot () { jq -r '.ImageData' "$INSTANCE_CONSOLE" | base64 -d - > "$SCREENSHOT_FILE" } +is_weldr_client_installed () { + if rpm --quiet -q weldr-client; then + echo true + else + echo false + fi +} + # Write an AWS TOML file tee "$AWS_CONFIG" > /dev/null << EOF provider = "aws" @@ -130,13 +138,21 @@ trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose and upload to AWS. greenprint "🚀 Starting compose" sudo composer-cli --json compose start bash ami "$IMAGE_KEY" "$AWS_CONFIG" | tee "$COMPOSE_START" -COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START") +if [ "$(is_weldr_client_installed)" == true ]; then + COMPOSE_ID=$(jq -r '.body.build_id' "$COMPOSE_START") +else + COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START") +fi # Wait for the compose to finish. greenprint "⏱ Waiting for compose to finish: ${COMPOSE_ID}" while true; do sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null - COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO") + if [ "$(is_weldr_client_installed)" == true ]; then + COMPOSE_STATUS=$(jq -r '.body.queue_status' "$COMPOSE_INFO") + else + COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO") + fi # Is the compose finished? if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then diff --git a/test/cases/azure.sh b/test/cases/azure.sh index b7acdb8ac..bacac97a7 100755 --- a/test/cases/azure.sh +++ b/test/cases/azure.sh @@ -99,6 +99,14 @@ get_compose_metadata () { cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null } +is_weldr_client_installed () { + if rpm --quiet -q weldr-client; then + echo true + else + echo false + fi +} + # Export Azure credentials if running on Jenkins set +u if [ -n "$AZURE_CREDS" ] @@ -151,13 +159,21 @@ trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT # Start the compose and upload to Azure. greenprint "🚀 Starting compose" sudo composer-cli --json compose start bash vhd "$IMAGE_KEY" "$AZURE_CONFIG" | tee "$COMPOSE_START" -COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START") +if [ "$(is_weldr_client_installed)" == true ]; then + COMPOSE_ID=$(jq -r '.body.build_id' "$COMPOSE_START") +else + COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START") +fi # Wait for the compose to finish. greenprint "⏱ Waiting for compose to finish: ${COMPOSE_ID}" while true; do sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null - COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO") + if [ "$(is_weldr_client_installed)" == true ]; then + COMPOSE_STATUS=$(jq -r '.body.queue_status' "$COMPOSE_INFO") + else + COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO") + fi # Is the compose finished? if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then