diff --git a/tests/gantry_login_spec.sh b/tests/gantry_login_spec.sh index 5938340..53cf240 100644 --- a/tests/gantry_login_spec.sh +++ b/tests/gantry_login_spec.sh @@ -45,11 +45,13 @@ Describe 'Login' export GANTRY_REGISTRY_HOST="${REGISTRY}" export GANTRY_REGISTRY_PASSWORD_FILE="${PASS_FILE}" export GANTRY_REGISTRY_USER_FILE="${USER_FILE}" + local RETURN_VALUE= run_gantry "${TEST_NAME}" + RETURN_VALUE="${?}" rm "${USER_FILE}" rm "${PASS_FILE}" [ -d "${CONFIG}" ] && rm -r "${CONFIG}" - return 0 + return "${RETURN_VALUE}" } Before "common_setup_new_image ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" After "common_cleanup ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" @@ -98,10 +100,12 @@ Describe 'Login' echo "# Test comments: CONFIG REGISTRY USERNAME PASSWORD" >> "${CONFIGS_FILE}" echo "${CONFIG} ${REGISTRY} ${USERNAME} ${PASSWORD}" >> "${CONFIGS_FILE}" export GANTRY_REGISTRY_CONFIGS_FILE="${CONFIGS_FILE}" + local RETURN_VALUE= run_gantry "${TEST_NAME}" + RETURN_VALUE="${?}" rm "${CONFIGS_FILE}" [ -d "${CONFIG}" ] && rm -r "${CONFIG}" - return 0 + return "${RETURN_VALUE}" } Before "common_setup_new_image ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" After "common_cleanup ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" @@ -150,10 +154,12 @@ Describe 'Login' # Add an extra item to the line. echo "${CONFIG} ${REGISTRY} ${USERNAME} ${PASSWORD} Extra" >> "${CONFIGS_FILE}" export GANTRY_REGISTRY_CONFIGS_FILE="${CONFIGS_FILE}" + local RETURN_VALUE= run_gantry "${TEST_NAME}" + RETURN_VALUE="${?}" rm "${CONFIGS_FILE}" [ -d "${CONFIG}" ] && rm -r "${CONFIG}" - return 0 + return "${RETURN_VALUE}" } Before "common_setup_new_image ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" After "common_cleanup ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" @@ -204,10 +210,12 @@ Describe 'Login' # Missing an item from the line. echo "${REGISTRY} ${USERNAME} ${PASSWORD}" >> "${CONFIGS_FILE}" export GANTRY_REGISTRY_CONFIGS_FILE="${CONFIGS_FILE}" + local RETURN_VALUE= run_gantry "${TEST_NAME}" + RETURN_VALUE="${?}" rm "${CONFIGS_FILE}" [ -d "${CONFIG}" ] && rm -r "${CONFIG}" - return + return "${RETURN_VALUE}" } Before "common_setup_new_image ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" After "common_cleanup ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" diff --git a/tests/gantry_options_spec.sh b/tests/gantry_options_spec.sh index de04309..e628312 100644 --- a/tests/gantry_options_spec.sh +++ b/tests/gantry_options_spec.sh @@ -58,9 +58,12 @@ Describe 'Options' LABEL_VALUE=$(_read_service_label "${SERVICE_NAME}" "${LABEL}") echo "Before updating: LABEL_VALUE=${LABEL_VALUE}" + local RETURN_VALUE= run_gantry "${TEST_NAME}" + RETURN_VALUE="${?}" LABEL_VALUE=$(_read_service_label "${SERVICE_NAME}" "${LABEL}") echo "After updating: LABEL_VALUE=${LABEL_VALUE}" + return "${RETURN_VALUE}" } Before "common_setup_new_image ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" After "common_cleanup ${TEST_NAME} ${IMAGE_WITH_TAG} ${SERVICE_NAME}" diff --git a/tests/spec_gantry_test_helper.sh b/tests/spec_gantry_test_helper.sh index 1a74f7a..7976a84 100644 --- a/tests/spec_gantry_test_helper.sh +++ b/tests/spec_gantry_test_helper.sh @@ -491,14 +491,14 @@ _run_gantry_container() { fi local SERVICE_NAME= SERVICE_NAME="gantry-test-SUT-$(unique_id)" + docker service rm "${SERVICE_NAME}" >/dev/null 2>&1; local MOUNT_OPTIONS= MOUNT_OPTIONS=$(_add_file_to_mount_options "${MOUNT_OPTIONS}" "${GANTRY_REGISTRY_CONFIG_FILE}") MOUNT_OPTIONS=$(_add_file_to_mount_options "${MOUNT_OPTIONS}" "${GANTRY_REGISTRY_CONFIGS_FILE}") MOUNT_OPTIONS=$(_add_file_to_mount_options "${MOUNT_OPTIONS}" "${GANTRY_REGISTRY_HOST_FILE}") MOUNT_OPTIONS=$(_add_file_to_mount_options "${MOUNT_OPTIONS}" "${GANTRY_REGISTRY_PASSWORD_FILE}") MOUNT_OPTIONS=$(_add_file_to_mount_options "${MOUNT_OPTIONS}" "${GANTRY_REGISTRY_USER_FILE}") - local CMD_OUTPUT= - docker service rm "${SERVICE_NAME}" >/dev/null 2>&1; + local RETURN_VALUE= echo -n "Starting SUT service ${SERVICE_NAME} " # SC2086 (info): Double quote to prevent globbing and word splitting. # shellcheck disable=SC2086 @@ -540,10 +540,13 @@ _run_gantry_container() { --env "TZ=${TZ}" \ "${SUT_REPO_TAG}" \ "${STACK}"; + RETURN_VALUE="${?}" docker service logs --raw "${SERVICE_NAME}" + local CMD_OUTPUT= if ! CMD_OUTPUT=$(docker service rm "${SERVICE_NAME}" 2>&1); then echo "Failed to remove service ${SERVICE_NAME}: ${CMD_OUTPUT}" >&2 fi + return "${RETURN_VALUE}" } run_gantry() {