-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·68 lines (53 loc) · 2.05 KB
/
test.sh
File metadata and controls
executable file
·68 lines (53 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -eo pipefail
trap 'docker compose down -v --remove-orphans' EXIT
http_wait() {
printf "$1:\t "
for i in {1..120};
do
local code="$(curl -s -o /dev/null -m 2 -w '%{http_code}' $1)"
if [ "$code" != "200" ]; then
printf "."
sleep 1
else
printf "\r\033[K$1:\t ${GREEN}OK${NC}\n"
return 0
fi
done
printf "\n${RED}ERROR${NC}: cannot connect to $1.\n"
exit 1
}
# start unit tests
rm -rf ./coverage
mkdir -p ./coverage/exhttp
mkdir -p ./coverage/connector
mkdir -p ./coverage/schema
go test -v -race -timeout 3m -cover ./exhttp/... -args -test.gocoverdir=$PWD/coverage/exhttp ./exhttp/...
go test -v -race -timeout 3m -cover ./ndc-http-schema/... -args -test.gocoverdir=$PWD/coverage/schema ./ndc-http-schema/...
docker compose up -d hydra hydra-migrate
http_wait http://localhost:4444/health/ready
go test -v -race -timeout 3m -coverpkg=./... -cover ./... -args -test.gocoverdir=$PWD/coverage/connector ./...
docker compose down -v
go tool covdata textfmt -i=./coverage/connector,./coverage/exhttp,./coverage/schema -o ./coverage/profile.tmp
cat ./coverage/profile.tmp | grep -v "main.go" > ./coverage/profile.tmp2
cat ./coverage/profile.tmp2 | grep -v "version.go" > ./coverage/profile
# start ndc-test
NDC_TEST_VERSION=v0.2.10
CONFIG_PATH="./connector-definition"
if [ -n "$1" ]; then
CONFIG_PATH="$1"
fi
mkdir -p ./tmp
if [ ! -f ./tmp/ndc-test ]; then
if [ "$(uname -m)" == "arm64" ]; then
curl -L https://github.com/hasura/ndc-spec/releases/download/$NDC_TEST_VERSION/ndc-test-aarch64-apple-darwin -o ./tmp/ndc-test
elif [ $(uname) == "Darwin" ]; then
curl -L https://github.com/hasura/ndc-spec/releases/download/$NDC_TEST_VERSION/ndc-test-x86_64-apple-darwin -o ./tmp/ndc-test
else
curl -L https://github.com/hasura/ndc-spec/releases/download/$NDC_TEST_VERSION/ndc-test-x86_64-unknown-linux-gnu -o ./tmp/ndc-test
fi
chmod +x ./tmp/ndc-test
fi
CONFIG_PATH=$CONFIG_PATH docker compose up -d --build ndc-http
http_wait http://localhost:8080/health
./tmp/ndc-test test --endpoint http://localhost:8080