mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-17 13:37:26 +03:00
server/api-tests: Add a Docker Compose file for the API tests.
We were previously using the Docker Compose file in the root directory for manual testing _and_ the server API tests. This splits them so we can e.g. add Yugabyte for easy manual testing. In the future, this will also allow us to use ephemeral ports for API test databases, while keeping the fixed ports for manual testing. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7524 GitOrigin-RevId: 7244e296b0ed0ace9782b6f44f321933a9d9a49d
This commit is contained in:
parent
e69b0599d3
commit
4175b53395
@ -29,6 +29,8 @@
|
||||
|
||||
version: "3.6"
|
||||
|
||||
name: hge-manual-tests
|
||||
|
||||
services:
|
||||
mariadb:
|
||||
extends:
|
||||
|
@ -69,7 +69,6 @@ services:
|
||||
|
||||
cockroach:
|
||||
image: cockroachdb/cockroach:latest-v22.2
|
||||
platform: linux/amd64
|
||||
command:
|
||||
- start-single-node
|
||||
- --insecure
|
||||
|
@ -1,3 +1,6 @@
|
||||
API_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/lib/api-tests
|
||||
PYTHON_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/tests-py
|
||||
|
||||
# Use the Azure SQL Edge image instead of the SQL Server image on arm64.
|
||||
# The latter doesn't work yet.
|
||||
ifeq ($(shell uname -m),arm64)
|
||||
@ -25,18 +28,18 @@ endef
|
||||
.PHONY: build-backends
|
||||
## build-backends: build Docker images for any backends that need them
|
||||
build-backends:
|
||||
docker compose build
|
||||
$(API_TESTS_DOCKER_COMPOSE) build
|
||||
|
||||
.PHONY: start-backends
|
||||
## start-backends: start all known backends in Docker and wait for them to be ready
|
||||
start-backends: build-backends
|
||||
docker compose up --detach --wait
|
||||
$(API_TESTS_DOCKER_COMPOSE) up --detach --wait
|
||||
|
||||
.PHONY: stop-everything
|
||||
## stop-everything: tear down test databases
|
||||
stop-everything:
|
||||
docker compose down --volumes
|
||||
cd server/tests-py && docker compose down --volumes
|
||||
$(API_TESTS_DOCKER_COMPOSE) down --volumes
|
||||
$(PYTHON_TESTS_DOCKER_COMPOSE) down --volumes
|
||||
|
||||
.PHONY: remove-tix-file
|
||||
remove-tix-file:
|
||||
|
@ -5,7 +5,7 @@ GRAPHQL_ENGINE_PRO_PATH=$(shell cabal list-bin exe:graphql-engine-pro)
|
||||
## test-bigquery: run tests for BigQuery backend
|
||||
# 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
|
||||
docker compose up -d --wait postgres
|
||||
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres
|
||||
$(call stop_after, \
|
||||
HASURA_TEST_BACKEND_TYPE=BigQuery \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -14,7 +14,7 @@ test-bigquery: build remove-tix-file
|
||||
.PHONY: test-sqlserver
|
||||
## test-sqlserver: run tests for MS SQL Server backend
|
||||
test-sqlserver: build remove-tix-file
|
||||
docker compose up -d --wait postgres sqlserver-healthcheck
|
||||
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres sqlserver-healthcheck
|
||||
$(call stop_after, \
|
||||
HASURA_TEST_BACKEND_TYPE=SQLServer \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -23,7 +23,7 @@ test-sqlserver: build remove-tix-file
|
||||
.PHONY: test-citus
|
||||
## test-citus: run tests for Citus backend
|
||||
test-citus: build remove-tix-file
|
||||
docker compose up -d --wait postgres citus
|
||||
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres citus
|
||||
$(call stop_after, \
|
||||
HASURA_TEST_BACKEND_TYPE=Citus \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -32,8 +32,8 @@ test-citus: build remove-tix-file
|
||||
.PHONY: test-data-connectors
|
||||
## test-data-connectors: run tests for Data Connectors
|
||||
test-data-connectors: build remove-tix-file
|
||||
docker compose build
|
||||
docker compose up -d --wait postgres dc-reference-agent dc-sqlite-agent
|
||||
$(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 \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -42,7 +42,7 @@ test-data-connectors: build remove-tix-file
|
||||
.PHONY: test-cockroach
|
||||
## test-cockroach: run tests for Cockroach backend
|
||||
test-cockroach: build remove-tix-file
|
||||
docker compose up -d --wait postgres cockroach
|
||||
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres cockroach
|
||||
$(call stop_after, \
|
||||
HASURA_TEST_BACKEND_TYPE=Cockroach \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -53,7 +53,7 @@ test-cockroach: build remove-tix-file
|
||||
# we have a few tests labeled with 'Postgres' which test their variants, too,
|
||||
# so this also starts containers for Postgres variants
|
||||
test-postgres: build remove-tix-file
|
||||
docker compose up -d --wait postgres cockroach citus dc-sqlite-agent
|
||||
$(API_TESTS_DOCKER_COMPOSE) up -d --wait postgres cockroach citus dc-sqlite-agent
|
||||
$(call stop_after, \
|
||||
HASURA_TEST_BACKEND_TYPE=Postgres \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PATH) \
|
||||
@ -79,7 +79,7 @@ test-backends: build start-backends remove-tix-file
|
||||
.PHONY: test-matrix
|
||||
## test-matrix: postgres test matrix generator
|
||||
test-matrix: build remove-tix-file
|
||||
docker compose up -d --wait postgres cockroach citus dc-sqlite-agent
|
||||
$(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)
|
||||
|
@ -9,7 +9,7 @@ RFC](../../../rfcs/hspec-test-suite.md).
|
||||
|
||||
Most of the required setup concerns (and is documented in the README for)
|
||||
[../test-harness/README.md](the test harness), so please follow that link for
|
||||
more information.
|
||||
more information.
|
||||
|
||||
The tests need to know the location of the `graphql-engine` executable:
|
||||
|
||||
@ -26,11 +26,11 @@ $ export HASURA_BIGQUERY_PROJECT_ID=??? # The project ID
|
||||
$ export HASURA_BIGQUERY_SERVICE_KEY=??? # The service account key
|
||||
```
|
||||
|
||||
After that, BigQuery will be ready to test.
|
||||
After that, BigQuery will be ready to test.
|
||||
|
||||
For everything else, run the following in this directory:
|
||||
|
||||
For everything else, run the following in the root of `graphql-engine`:
|
||||
```
|
||||
```bash
|
||||
$ docker-compose up
|
||||
```
|
||||
|
||||
|
78
server/lib/api-tests/docker-compose.yaml
Normal file
78
server/lib/api-tests/docker-compose.yaml
Normal file
@ -0,0 +1,78 @@
|
||||
version: "3.6"
|
||||
|
||||
name: hge-api-tests
|
||||
|
||||
services:
|
||||
postgres:
|
||||
extends:
|
||||
file: ../../../docker-compose/databases.yaml
|
||||
service: postgres
|
||||
ports:
|
||||
- "65002:5432"
|
||||
environment:
|
||||
POSTGRES_USER: "hasura"
|
||||
POSTGRES_PASSWORD: "hasura"
|
||||
POSTGRES_DB: "hasura"
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
- ../../../docker-compose/postgres/init.sh:/docker-entrypoint-initdb.d/init-hasura.sh:ro
|
||||
|
||||
citus:
|
||||
extends:
|
||||
file: ../../../docker-compose/databases.yaml
|
||||
service: citus
|
||||
ports:
|
||||
- "65004:5432"
|
||||
environment:
|
||||
POSTGRES_USER: "hasura"
|
||||
POSTGRES_PASSWORD: "hasura"
|
||||
POSTGRES_DB: "hasura"
|
||||
volumes:
|
||||
- citus-data:/var/lib/postgresql/data
|
||||
- ../../../docker-compose/postgres/init.sh:/docker-entrypoint-initdb.d/init-hasura.sh:ro
|
||||
|
||||
cockroach:
|
||||
extends:
|
||||
file: ../../../docker-compose/databases.yaml
|
||||
service: cockroach
|
||||
ports:
|
||||
- "65008:26257"
|
||||
environment:
|
||||
COCKROACH_USER: "root"
|
||||
COCKROACH_DATABASE: "hasura"
|
||||
volumes:
|
||||
- cockroach-data:/cockroach/cockroach-data
|
||||
|
||||
sqlserver:
|
||||
extends:
|
||||
file: ../../../docker-compose/databases.yaml
|
||||
service: sqlserver
|
||||
ports:
|
||||
- "65003:1433"
|
||||
volumes:
|
||||
- mssql-data:/var/opt/mssql
|
||||
|
||||
sqlserver-healthcheck:
|
||||
extends:
|
||||
file: ../../../docker-compose/databases.yaml
|
||||
service: sqlserver-healthcheck
|
||||
depends_on:
|
||||
sqlserver:
|
||||
condition: service_started
|
||||
|
||||
dc-reference-agent:
|
||||
extends:
|
||||
file: ../../../dc-agents/docker-compose.yaml
|
||||
service: dc-reference-agent
|
||||
|
||||
dc-sqlite-agent:
|
||||
extends:
|
||||
file: ../../../dc-agents/docker-compose.yaml
|
||||
service: dc-sqlite-agent
|
||||
|
||||
volumes:
|
||||
citus-data:
|
||||
cockroach-data:
|
||||
mariadb-data:
|
||||
mssql-data:
|
||||
postgres-data:
|
@ -2,6 +2,8 @@
|
||||
|
||||
version: "3.6"
|
||||
|
||||
name: hge-python-tests
|
||||
|
||||
services:
|
||||
cabal-update:
|
||||
image: hasura/graphql-engine-server-builder:${DOCKER_PLATFORM:-}-${HASURA_GRAPHQL_ENGINE_SERVER_BUILDER_SHA}
|
||||
|
0
server/tests-py/docker/postgres-init.sh
Normal file → Executable file
0
server/tests-py/docker/postgres-init.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user