Skip to content

Commit

Permalink
modify tests to verify that inconsistent metadata prevents startup wh…
Browse files Browse the repository at this point in the history
…en new flag is set
  • Loading branch information
chardo committed Nov 15, 2024
1 parent b68a407 commit 034fd38
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packaging/cli-migrations/v2/test/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ services:
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
HASURA_GRAPHQL_DISALLOW_INCONSISTENT_METADATA: "true"
18 changes: 16 additions & 2 deletions packaging/cli-migrations/v2/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,24 @@ docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"

# stop the graphql-engine container
docker compose stop graphql-engine

# overwrite existing metadata with intentionally inconsistent metadata
docker cp bad_metadata/tables.yaml graphql-engine:/hasura-metadata/tables.yaml

# TODO: start up the container with inconsistent metadata disallowed, verify that it fails to start
# start the container with new, inconsistent metadata
docker compose up -d --no-recreate graphql-engine
# confirm that the service does not become available for at least 10 seconds
for _ in $(seq 1 10); do
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
echo "Server became available when it should not have"
exit 1
fi
sleep 1
done
# confirm that the service's log contain the expected error
if ! docker compose logs graphql-engine | grep -qi "error applying metadata"; then
echo "Expected error message not found in logs"
exit 1
fi

# delete postgres and graphql-engine
docker compose down -v
18 changes: 16 additions & 2 deletions packaging/cli-migrations/v3/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,24 @@ docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"ty

# stop the graphql-engine container
docker compose stop graphql-engine

# overwrite existing metadata with intentionally inconsistent metadata
docker cp bad_metadata/public_test.yaml graphql-engine:/hasura-metadata/databases/default/tables/public_test.yaml

# TODO: start up the container with inconsistent metadata disallowed, verify that it fails to start
# start the container with new, inconsistent metadata
docker compose up -d --no-recreate graphql-engine
# confirm that the service does not become available for at least 10 seconds
for _ in $(seq 1 10); do
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
echo "Server became available when it should not have"
exit 1
fi
sleep 1
done
# confirm that the service's log contain the expected error
if ! docker compose logs graphql-engine | grep -qi "error applying metadata"; then
echo "Expected error message not found in logs"
exit 1
fi

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

0 comments on commit 034fd38

Please sign in to comment.