2018-07-10 13:01:02 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
CLI_ROOT="${BASH_SOURCE[0]%/*}/../cli"
|
|
|
|
|
2018-07-11 09:47:51 +03:00
|
|
|
wait_for_port() {
|
|
|
|
local PORT=$1
|
|
|
|
echo "waiting for $PORT"
|
|
|
|
for i in `seq 1 60`;
|
|
|
|
do
|
|
|
|
nc -z localhost $PORT && echo "port $PORT is ready" && return
|
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Failed waiting for $PORT" && exit 1
|
|
|
|
}
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
cd "$CLI_ROOT"
|
|
|
|
mkdir -p /build/_cli_output
|
|
|
|
touch /build/_cli_output/server.log
|
2019-02-14 12:37:47 +03:00
|
|
|
touch /build/_cli_output/server-secret.log
|
2018-07-10 13:01:02 +03:00
|
|
|
|
2021-01-18 20:11:05 +03:00
|
|
|
export HASURA_GRAPHQL_DATABASE_URL='postgres://gql_test@localhost:5432/gql_test'
|
2019-02-14 12:37:47 +03:00
|
|
|
# start graphql-engine without admin secret
|
2021-01-18 20:11:05 +03:00
|
|
|
/build/_server_output/graphql-engine serve > /build/_cli_output/server.log 2>&1 &
|
2018-08-30 18:54:12 +03:00
|
|
|
PID=$!
|
2018-07-10 13:01:02 +03:00
|
|
|
|
2018-07-11 09:47:51 +03:00
|
|
|
wait_for_port 8080
|
|
|
|
|
2018-07-10 13:01:02 +03:00
|
|
|
# test cli
|
2021-03-17 18:09:03 +03:00
|
|
|
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test-all
|
2019-08-26 08:31:27 +03:00
|
|
|
kill -s INT $PID
|
2018-08-30 18:54:12 +03:00
|
|
|
|
2019-02-14 12:37:47 +03:00
|
|
|
# start graphql-engine with admin secret
|
|
|
|
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_admin_secret";'
|
2021-01-18 20:11:05 +03:00
|
|
|
export HASURA_GRAPHQL_DATABASE_URL='postgres://gql_test@localhost:5432/gql_test_with_admin_secret'
|
|
|
|
/build/_server_output/graphql-engine serve --admin-secret "abcd" > /build/_cli_output/server-secret.log 2>&1 &
|
2018-08-30 18:54:12 +03:00
|
|
|
PID=$!
|
|
|
|
|
|
|
|
wait_for_port 8080
|
|
|
|
|
|
|
|
# test cli
|
2021-03-17 18:09:03 +03:00
|
|
|
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ADMIN_SECRET="abcd" make test-all
|
2019-08-26 08:31:27 +03:00
|
|
|
kill -s INT $PID
|