2022-09-09 08:02:15 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-09-22 22:01:48 +03:00
|
|
|
# This allows a developer, through Docker, to run the Python integration tests in pretty
|
|
|
|
# much exactly the same way as CI does (in contrast to `dev.sh test --integration`),
|
2022-09-09 08:02:15 +03:00
|
|
|
# allowing us to more readily diagnose issues locally.
|
|
|
|
#
|
|
|
|
# This takes an optional test configuration argument, corresponding to a name in
|
2022-09-22 22:01:48 +03:00
|
|
|
# `oss-.circleci/server-test-names.txt` (else defaulting to `no-auth`).
|
|
|
|
#
|
2022-09-09 08:02:15 +03:00
|
|
|
# See `case "$SERVER_TEST_TO_RUN"` in `oss-.circleci/test-server.sh` for what
|
|
|
|
# these actually do.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
|
|
|
2022-10-17 15:07:12 +03:00
|
|
|
# This `PLATFORM` value is used to pick the correct server builder image and HGE binary path.
|
2022-10-06 22:03:40 +03:00
|
|
|
PLATFORM="$(uname -m)"
|
2022-10-17 15:07:12 +03:00
|
|
|
if [[ "$PLATFORM" == 'x86_64' || "$PLATFORM" == 'amd64' ]]; then
|
|
|
|
CABAL_PLATFORM='x86_64'
|
|
|
|
DOCKER_PLATFORM='amd64'
|
2022-10-06 22:03:40 +03:00
|
|
|
fi
|
2022-10-17 15:07:12 +03:00
|
|
|
if [[ "$PLATFORM" == 'aarch64' || "$PLATFORM" == 'arm64' ]]; then
|
|
|
|
CABAL_PLATFORM='aarch64'
|
|
|
|
DOCKER_PLATFORM='arm64'
|
2022-10-06 22:03:40 +03:00
|
|
|
fi
|
2022-10-17 15:07:12 +03:00
|
|
|
export CABAL_PLATFORM DOCKER_PLATFORM
|
2022-10-06 22:03:40 +03:00
|
|
|
|
2022-09-09 08:02:15 +03:00
|
|
|
# copied from images.go
|
|
|
|
HASURA_GRAPHQL_ENGINE_SERVER_BUILDER_SHA="$(
|
|
|
|
sha256sum ../../.buildkite/dockerfiles/ci-builders/server-builder.dockerfile \
|
|
|
|
| awk '{ print $1 }'
|
|
|
|
)"
|
|
|
|
export HASURA_GRAPHQL_ENGINE_SERVER_BUILDER_SHA
|
|
|
|
|
|
|
|
# copied from images.go
|
|
|
|
HASURA_GRAPHQL_ENGINE_SERVER_PYTEST_RUNNER_SHA="$(
|
|
|
|
cat \
|
|
|
|
../../.buildkite/dockerfiles/server-pytest-runner/Dockerfile \
|
|
|
|
./requirements.txt \
|
|
|
|
./package-lock.json \
|
|
|
|
./package.json \
|
|
|
|
./remote_schemas/nodejs/package.json \
|
|
|
|
| sha256sum \
|
|
|
|
| awk '{ print $1 }'
|
|
|
|
)"
|
|
|
|
export HASURA_GRAPHQL_ENGINE_SERVER_PYTEST_RUNNER_SHA
|
|
|
|
|
2022-09-22 22:01:48 +03:00
|
|
|
# Use the Azure SQL Edge image instead of the SQL Server image on arm64.
|
|
|
|
# The latter doesn't work yet.
|
|
|
|
if [[ "$(uname -m)" == 'arm64' ]]; then
|
|
|
|
export MSSQL_IMAGE='mcr.microsoft.com/azure-sql-edge'
|
|
|
|
fi
|
|
|
|
|
2022-09-29 13:42:47 +03:00
|
|
|
if [[ $# -gt 0 ]]; then
|
|
|
|
SERVER_TESTS_TO_RUN=("$@")
|
|
|
|
else
|
|
|
|
SERVER_TESTS_TO_RUN=('no-auth')
|
|
|
|
fi
|
|
|
|
|
2022-10-06 22:03:40 +03:00
|
|
|
echo '*** Pulling images ***'
|
2022-10-17 15:07:12 +03:00
|
|
|
docker compose pull --ignore-pull-failures
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo '*** Building images ***'
|
|
|
|
# We rebuild the images because on arm64, we end up with an amd64 Python test
|
|
|
|
# runner. This won't actually be able to run HGE. Until we build an arm64 image
|
|
|
|
# on CI, we need to instead build it locally. On amd64, this is benign; the
|
|
|
|
# `docker compose run tests-py` step would have built it anyway.
|
|
|
|
docker compose build
|
2022-10-06 22:03:40 +03:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo '*** Building HGE ***'
|
2022-09-29 20:18:49 +03:00
|
|
|
docker compose run --rm hge-build
|
2022-09-09 08:02:15 +03:00
|
|
|
|
2022-09-29 13:42:47 +03:00
|
|
|
for SERVER_TEST_TO_RUN in "${SERVER_TESTS_TO_RUN[@]}"; do
|
|
|
|
export SERVER_TEST_TO_RUN
|
|
|
|
echo
|
|
|
|
echo "*** Running test suite: ${SERVER_TEST_TO_RUN} ***"
|
2022-10-13 18:43:59 +03:00
|
|
|
docker compose rm -svf citus mssql mssql-healthcheck postgres # tear down databases beforehand
|
2022-09-29 20:18:49 +03:00
|
|
|
docker compose run --rm tests-py
|
2022-09-29 13:42:47 +03:00
|
|
|
done
|