graphql-engine/.circleci/test-cli.sh
hasura-bot 2099208e4b cli: merges cli-ext with cli
GITHUB_PR_NUMBER: 6640
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6640

Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com>
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 362d82d8ee18afd7efa63e9c8912f6c5444f82dd
2021-03-17 15:10:03 +00:00

46 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
CLI_ROOT="${BASH_SOURCE[0]%/*}/../cli"
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
}
cd "$CLI_ROOT"
mkdir -p /build/_cli_output
touch /build/_cli_output/server.log
touch /build/_cli_output/server-secret.log
export HASURA_GRAPHQL_DATABASE_URL='postgres://gql_test@localhost:5432/gql_test'
# start graphql-engine without admin secret
/build/_server_output/graphql-engine serve > /build/_cli_output/server.log 2>&1 &
PID=$!
wait_for_port 8080
# test cli
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test-all
kill -s INT $PID
# start graphql-engine with admin secret
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_admin_secret";'
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 &
PID=$!
wait_for_port 8080
# test cli
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ADMIN_SECRET="abcd" make test-all
kill -s INT $PID