Skip to content

Commit faa2c1f

Browse files
committed
modify tests to verify that inconsistent metadata prevents startup when new flag is set
1 parent 4570560 commit faa2c1f

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

packaging/cli-migrations/v2/test/docker-compose.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ services:
1616
environment:
1717
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
1818
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
19-
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
19+
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
20+
HASURA_GRAPHQL_DISALLOW_INCONSISTENT_METADATA: "true"

packaging/cli-migrations/v2/test/test.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,24 @@ docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"
4444

4545
# stop the graphql-engine container
4646
docker compose stop graphql-engine
47+
4748
# overwrite existing metadata with intentionally inconsistent metadata
4849
docker cp bad_metadata/tables.yaml graphql-engine:/hasura-metadata/tables.yaml
49-
50-
# TODO: start up the container with inconsistent metadata disallowed, verify that it fails to start
50+
# start the container with new, inconsistent metadata
51+
docker compose up -d --no-recreate graphql-engine
52+
# confirm that the service does not become available for at least 10 seconds
53+
for _ in $(seq 1 10); do
54+
if docker run --rm --network container:graphql-engine curlimages/curl -s -f http://127.0.0.1:8080/v1/version > /dev/null 2>&1; then
55+
echo "Server became available when it should not have"
56+
exit 1
57+
fi
58+
sleep 1
59+
done
60+
# confirm that the service's log contain the expected error
61+
if ! docker compose logs graphql-engine | grep -qi "error applying metadata"; then
62+
echo "Expected error message not found in logs"
63+
exit 1
64+
fi
5165

5266
# delete postgres and graphql-engine
5367
docker compose down -v

packaging/cli-migrations/v3/test/test.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,24 @@ docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"ty
4141

4242
# stop the graphql-engine container
4343
docker compose stop graphql-engine
44+
4445
# overwrite existing metadata with intentionally inconsistent metadata
4546
docker cp bad_metadata/public_test.yaml graphql-engine:/hasura-metadata/databases/default/tables/public_test.yaml
46-
47-
# TODO: start up the container with inconsistent metadata disallowed, verify that it fails to start
47+
# start the container with new, inconsistent metadata
48+
docker compose up -d --no-recreate graphql-engine
49+
# confirm that the service does not become available for at least 10 seconds
50+
for _ in $(seq 1 10); do
51+
if docker run --rm --network container:graphql-engine curlimages/curl -s -f http://127.0.0.1:8080/v1/version > /dev/null 2>&1; then
52+
echo "Server became available when it should not have"
53+
exit 1
54+
fi
55+
sleep 1
56+
done
57+
# confirm that the service's log contain the expected error
58+
if ! docker compose logs graphql-engine | grep -qi "error applying metadata"; then
59+
echo "Expected error message not found in logs"
60+
exit 1
61+
fi
4862

4963
# delete postgres and graphql-engine
5064
docker compose down -v

0 commit comments

Comments
 (0)