Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pull-metrics-server-test-version by running container only if local architecture matches #1328

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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