graphql-engine/server/tests-py/run.sh
Samir Talwar 0d4d7e6b1e server/tests-py: Start helper services in the test harness.
This makes it possible for the test harness to start the test JWK server and the test remote schema server.

In order to do this, we still generate the TLS certificates in the test script (because we need to install the generated CA certificate in the OS certificate store), and then pass the certificate and key paths into the test runner.

Because we are still using _test-server.sh_ for now, we don't use the JWK server fixture in that case, as HGE needs the JWK server to be up and running when it starts. Instead, we keep running it outside (for now).

This is also the case for the GraphQL server fixture when we are running the server upgrade/downgrade tests.

I have also refactored _graphql_server.py_ so there isn't a global `HGE_URLS` value, but instead the value is passed through.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6303
GitOrigin-RevId: 06f05ff674372dc5d632e55d68e661f5c7a17c10
2022-10-13 15:45:24 +00:00

75 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# 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`),
# allowing us to more readily diagnose issues locally.
#
# This takes an optional test configuration argument, corresponding to a name in
# `oss-.circleci/server-test-names.txt` (else defaulting to `no-auth`).
#
# 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]}")"
# This `PLATFORM` value is used to pick the correct server builder image.
PLATFORM="$(uname -m)"
if [[ "$PLATFORM" == 'x86_64' ]]; then
PLATFORM='amd64'
fi
if [[ "$PLATFORM" == 'aarch64' ]]; then
PLATFORM='arm64'
fi
export PLATFORM
# 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
# 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
if [[ $# -gt 0 ]]; then
SERVER_TESTS_TO_RUN=("$@")
else
SERVER_TESTS_TO_RUN=('no-auth')
fi
echo '*** Pulling images ***'
docker compose pull
echo
echo '*** Building HGE ***'
docker compose run --rm hge-build
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} ***"
docker compose rm -svf citus mssql mssql-healthcheck postgres # tear down databases beforehand
docker compose run --rm tests-py
done