make: Don't stop test database containers after running tests.

The tests no longer need a fresh, clean database, so we don't need to spend the time spinning them up and shutting them down again.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7732
GitOrigin-RevId: f2b412f4a8c762ee6699bd1bec1eef89f7682712
This commit is contained in:
Samir Talwar 2023-01-31 17:58:43 +01:00 committed by hasura-bot
parent ab088cad25
commit 87be5db9df
2 changed files with 29 additions and 55 deletions

View File

@ -14,17 +14,6 @@ export MSSQL_IMAGE
TEST_MSSQL_CONNECTION_STRING = Driver={ODBC Driver 18 for SQL Server};Server=localhost,65003;Uid=sa;Pwd=Password!;Encrypt=optional
TEST_POSTGRES_URL = postgres://hasura:hasura@localhost:65002/hasura
define stop_after
@ echo $1 >&2
@ $1 || EXIT_STATUS=$$?; \
if [[ -z "$${EXIT_STATUS:-}" ]]; then \
$(MAKE) stop-everything; \
else \
$(MAKE) stop-everything; \
exit $$EXIT_STATUS; \
fi
endef
.PHONY: build-backends
## build-backends: build Docker images for any backends that need them
build-backends:

View File

@ -6,47 +6,42 @@ GRAPHQL_ENGINE_PRO_PATH=$(shell cabal list-bin exe:graphql-engine-pro)
# will require some setup detailed here: https://github.com/hasura/graphql-engine-mono/tree/main/server/lib/api-tests#required-setup-for-bigquery-tests
test-bigquery: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=BigQuery \
HASURA_TEST_BACKEND_TYPE=BigQuery \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-sqlserver
## test-sqlserver: run tests for MS SQL Server backend
test-sqlserver: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres sqlserver-healthcheck
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=SQLServer \
HASURA_TEST_BACKEND_TYPE=SQLServer \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-citus
## test-citus: run tests for Citus backend
test-citus: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres citus
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=Citus \
HASURA_TEST_BACKEND_TYPE=Citus \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-data-connectors
## test-data-connectors: run tests for Data Connectors
test-data-connectors: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) build
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres dc-reference-agent dc-sqlite-agent
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=DataConnector \
HASURA_TEST_BACKEND_TYPE=DataConnector \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-cockroach
## test-cockroach: run tests for Cockroach backend
test-cockroach: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres cockroach
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=Cockroach \
HASURA_TEST_BACKEND_TYPE=Cockroach \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-postgres
## test-postgres: run tests for Postgres backend
@ -54,58 +49,51 @@ test-cockroach: build remove-tix-file
# so this also starts containers for Postgres variants
test-postgres: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres cockroach citus dc-sqlite-agent
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=Postgres \
HASURA_TEST_BACKEND_TYPE=Postgres \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-no-backends
## test-no-backends
# the leftover tests with no particular backend, like Remote Schemas
test-no-backends: build start-backends remove-tix-file
$(call stop_after, \
HASURA_TEST_BACKEND_TYPE=None \
HASURA_TEST_BACKEND_TYPE=None \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
cabal run api-tests:exe:api-tests
.PHONY: test-backends
## test-backends: run tests for all backends
# BigQuery tests will require some setup detailed here: https://github.com/hasura/graphql-engine-mono/tree/main/server/lib/api-tests#required-setup-for-bigquery-tests
test-backends: build start-backends remove-tix-file
$(call stop_after, \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests)
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:api-tests
.PHONY: test-matrix
## test-matrix: postgres test matrix generator
test-matrix: build remove-tix-file
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres cockroach citus dc-sqlite-agent
$(call stop_after, \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:produce-feature-matrix +RTS -N4 -RTS)
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
cabal run api-tests:exe:produce-feature-matrix +RTS -N4 -RTS
.PHONY: test-data-connectors-pro
## test-backends-pro: run tests for HGE pro for all backends
test-data-connectors-pro: build-pro remove-tix-file
docker compose up -d --wait postgres dc-sqlite-agent
$(call stop_after, \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro)
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro
.PHONY: test-data-connectors-snowflake-pro
## test-data-connectors-snowflake-pro: run tests for HGE pro for all backends
test-data-connectors-snowflake-pro: build-pro remove-tix-file
docker compose up -d --wait postgres dc-sqlite-agent
$(call stop_after, \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro -- --match "DataConnector \"snowflake\"")
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro -- --match "DataConnector \"snowflake\""
.PHONY: test-backends-pro
## test-backends-pro: run tests for HGE pro for all backends
test-backends-pro: build-pro start-backends remove-tix-file
$(call stop_after, \
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro)
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
cabal run api-tests-pro:exe:api-tests-pro
.PHONY: test-unit
## test-unit: run unit tests from main suite
@ -116,20 +104,17 @@ test-unit: remove-tix-file
## test-integration-mssql: run MS SQL Server integration tests
test-integration-mssql: remove-tix-file
docker compose up -d --wait sqlserver{,-healthcheck,-init}
$(call stop_after, \
HASURA_MSSQL_CONN_STR='$(TEST_MSSQL_CONNECTION_STRING)' \
cabal run graphql-engine:test:graphql-engine-test-mssql)
HASURA_MSSQL_CONN_STR='$(TEST_MSSQL_CONNECTION_STRING)' \
cabal run graphql-engine:test:graphql-engine-test-mssql
.PHONY: test-integration-postgres
## test-integration-postgres: run PostgreSQL integration tests
test-integration-postgres: remove-tix-file
docker compose up -d --wait postgres
$(call stop_after, \
HASURA_GRAPHQL_DATABASE_URL='$(TEST_POSTGRES_URL)' \
cabal run graphql-engine:test:graphql-engine-test-postgres)
HASURA_GRAPHQL_DATABASE_URL='$(TEST_POSTGRES_URL)' \
cabal run graphql-engine:test:graphql-engine-test-postgres
.PHONY: py-tests
## py-tests: run the python-based test suite
py-tests:
$(call stop_after, \
./server/tests-py/run-new.sh)
./server/tests-py/run-new.sh