mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
204ec89c61
This rewrites the last couple of Python tests that were failing when run with a separate HGE binary per test class. The changes are as follows: 1. The event triggers tests, naming conventions tests, and subscriptions tests all generate a new source DB per test, so can run in parallel. 2. The scheduled triggers tests use the correct URL for the trigger service when the port is generated randomly. 3. Whitespace and trailing commas are added to the scheduled triggers tests. 4. Support for SQL Server is added to _hge.py_ so the naming conventions test that runs on SQL Server passes. (The other SQL Server tests do not pass and we're not going to bother with them for now.) 5. Container names are fixed in _run.sh_. 6. _run.sh_ and _run-new.sh_ don't pull images explicitly as it's annoying when running tests a lot. If you want to pull the latest versions, just run `docker compose pull` from the _server/tests-py_ directory, or the root directory. (If you don't have the images at all, they'll still be pulled automatically.) PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7350 GitOrigin-RevId: db58f310f017b2a0884fcf61ccc56d15583f99bd
56 lines
2.0 KiB
Bash
Executable File
56 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This allows a developer to easily run the Python integration tests using the
|
|
# `--hge-bin` flag.
|
|
#
|
|
# The Pytest runner will start a new HGE instance for each test class, with the
|
|
# default arguments and the environment variables provided below.
|
|
#
|
|
# This is a work in progress.
|
|
|
|
set -e
|
|
set -u
|
|
set -o pipefail
|
|
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
|
|
DATABASES=(postgres citus sqlserver sqlserver-healthcheck)
|
|
|
|
(
|
|
cd ../..
|
|
echo '*** Building HGE ***'
|
|
cabal build -j graphql-engine:exe:graphql-engine
|
|
|
|
echo
|
|
echo '*** Installing test dependencies ***'
|
|
make server/tests-py/.hasura-dev-python-venv server/tests-py/node_modules remove-tix-file
|
|
)
|
|
|
|
# shellcheck disable=SC1091
|
|
source .hasura-dev-python-venv/bin/activate
|
|
|
|
# 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
|
|
|
|
echo
|
|
echo '*** Starting databases ***'
|
|
docker compose up -d --wait "${DATABASES[@]}"
|
|
|
|
HASURA_GRAPHQL_PG_SOURCE_URL_1="postgresql://postgres:hasura@localhost:$(docker compose port --index 1 postgres 5432 | sed -E 's/.*://')/postgres"
|
|
HASURA_GRAPHQL_PG_SOURCE_URL_2="postgresql://postgres:hasura@localhost:$(docker compose port --index 2 postgres 5432 | sed -E 's/.*://')/postgres"
|
|
HASURA_GRAPHQL_CITUS_SOURCE_URL="postgresql://postgres:hasura@localhost:$(docker compose port citus 5432 | sed -E 's/.*://')/postgres"
|
|
HASURA_GRAPHQL_MSSQL_SOURCE_URL="DRIVER={ODBC Driver 18 for SQL Server};SERVER=localhost,$(docker compose port sqlserver 1433 | sed -E 's/.*://');Uid=sa;Pwd=Password!;Encrypt=optional"
|
|
export HASURA_GRAPHQL_PG_SOURCE_URL_1 HASURA_GRAPHQL_PG_SOURCE_URL_2 HASURA_GRAPHQL_CITUS_SOURCE_URL HASURA_GRAPHQL_MSSQL_SOURCE_URL
|
|
|
|
echo
|
|
echo '*** Running tests ***'
|
|
pytest \
|
|
--dist=loadscope \
|
|
-n auto \
|
|
--hge-bin="$(cabal list-bin graphql-engine:exe:graphql-engine)" \
|
|
--pg-urls "$HASURA_GRAPHQL_PG_SOURCE_URL_1" "$HASURA_GRAPHQL_PG_SOURCE_URL_2" \
|
|
"$@"
|