Skip to content

Commit

Permalink
Fix pull-metrics-server-test-version by running container only if loc…
Browse files Browse the repository at this point in the history
…al architecture matches
  • Loading branch information
serathius committed Sep 11, 2023
1 parent 035dade commit d40aa24
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions test/test-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,31 @@ set -e
: ${EXPECTED_VERSION:?Need to provide environment variable EXPECTED_VERSION}

IMAGE_ARCH=$(docker inspect ${IMAGE} | jq -r ".[].Architecture")
echo "Image architecture ${IMAGE_ARCH}"

if [[ "${IMAGE_ARCH}" != "${EXPECTED_ARCH}" ]] ; then
echo "Unexpected architecture, got ${IMAGE_ARCH}, expected ${EXPECTED_ARCH}"
exit 1
fi

CONTAINER_VERSION=$(docker run --rm ${IMAGE} --version)

if [[ "${CONTAINER_VERSION}" != "${EXPECTED_VERSION}" ]] ; then
echo "Unexpected binary version, got ${CONTAINER_VERSION}, expected ${EXPECTED_VERSION}"
exit 1
if [[ "${IMAGE_ARCH}" == $(dpkg --print-architecture) ]] ; then
CONTAINER_VERSION=$(docker run --rm ${IMAGE} --version)
echo "Image version ${CONTAINER_VERSION}"

if [[ "${CONTAINER_VERSION}" != "${EXPECTED_VERSION}" ]] ; then
echo "Unexpected binary version, got ${CONTAINER_VERSION}, expected ${EXPECTED_VERSION}"
exit 1
fi

CLI_HELP="$(docker run --rm ${IMAGE} --help | sed 's/[ \t]*$//')"
EXPECTED_CLI_HELP="$(cat ./docs/command-line-flags.txt)"
echo "Image help ${CLI_HELP}"

DIFF=$(diff -u <(echo "${EXPECTED_CLI_HELP}") <(echo "${CLI_HELP}") | tail -n +3 || true)
if [ "$DIFF" ]; then
echo "Unexpected cli help, diff:"
echo "$DIFF"
exit 1
fi
fi

CLI_HELP="$(docker run --rm ${IMAGE} --help | sed 's/[ \t]*$//')"
EXPECTED_CLI_HELP="$(cat ./docs/command-line-flags.txt)"

DIFF=$(diff -u <(echo "${EXPECTED_CLI_HELP}") <(echo "${CLI_HELP}") | tail -n +3 || true)
if [ "$DIFF" ]; then
echo "Unexpected cli help, diff:"
echo "$DIFF"
exit 1
fi

0 comments on commit d40aa24

Please sign in to comment.