mirror of
https://github.com/hasura/graphql-engine.git
synced 2025-01-05 14:27:59 +03:00
dc-agents/postgres: Test on random ports.
The ports we use for testing often collide with other containers that other test suites leave lying around. This is annoying. This fixes the problem by ensuring that PostgreSQL runs a on random port. FWe can query Docker to find out the allocated port. I also changed the `make` target to run the agent too (though I kept the old behavior under a different target name). PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9053 GitOrigin-RevId: 3ddea297905c0019c5ac42d896f5609f0d079e93
This commit is contained in:
parent
7baac3a5a7
commit
37fe99418c
@ -243,6 +243,36 @@ upgrade-tests:
|
||||
|
||||
.PHONY: test-dc-postgres-agent
|
||||
## test-dc-postgres-agent: run the dc-api test suite against the postgres agent
|
||||
# The commands below are obtuse, so here they are, explained. (We can't comment inline.)
|
||||
# 1. Build the agent.
|
||||
# 2. Bring up the PostgreSQL container.
|
||||
# 3. Run the agent on port 8889, and wait a second for it to start.
|
||||
# 4. Ensure we clean up after ourselves.
|
||||
# 5. Get the port of the PostgreSQL container.
|
||||
# 6. Run the tests, pointing to the correct port for the DB.
|
||||
test-dc-postgres-agent:
|
||||
cabal build postgres-agent:exe:postgres-agent
|
||||
$(DC_POSTGRES_DOCKER_COMPOSE) up --wait
|
||||
cabal run test:tests-dc-api -- test --agent-base-url "http://localhost:8888" --agent-config '{ "connection": "postgresql://hasura:hasura@localhost:65002/hasura"}' sandwich --tui
|
||||
@ echo 'cabal run postgres-agent:exe:postgres-agent'; \
|
||||
cabal run postgres-agent:exe:postgres-agent -- --port 8889 & trap "kill $$!" EXIT; \
|
||||
sleep 1; \
|
||||
PG_PORT="$$($(DC_POSTGRES_DOCKER_COMPOSE) port postgres 5432 | sed 's/.*://')"; \
|
||||
echo 'cabal run test:tests-dc-api -- test'; \
|
||||
cabal run test:tests-dc-api -- \
|
||||
test \
|
||||
--agent-base-url 'http://localhost:8889' \
|
||||
--agent-config "{\"connection\": \"postgresql://postgres:password@localhost:$${PG_PORT}\"}" \
|
||||
sandwich
|
||||
|
||||
.PHONY: test-dc-postgres-agent-only
|
||||
## test-dc-postgres-agent-only: run the dc-api test suite against an already-running postgres agent on port 8888
|
||||
test-dc-postgres-agent-only:
|
||||
# See above for an explanation.
|
||||
$(DC_POSTGRES_DOCKER_COMPOSE) up --wait
|
||||
@ echo 'cabal run test:tests-dc-api -- test'
|
||||
@ PG_PORT="$$($(DC_POSTGRES_DOCKER_COMPOSE) port postgres 5432 | sed 's/.*://')"; \
|
||||
cabal run test:tests-dc-api -- \
|
||||
test \
|
||||
--agent-base-url "http://localhost:8888" \
|
||||
--agent-config "{\"connection\": \"postgresql://postgres:password@localhost:$${PG_PORT}\"}" \
|
||||
sandwich --tui
|
||||
|
Loading…
Reference in New Issue
Block a user