-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathintegration-tests-docker-compose.sh
More file actions
executable file
·59 lines (49 loc) · 1.38 KB
/
Copy pathintegration-tests-docker-compose.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.38 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
#!/bin/bash
## This script is used to run integration tests for the steem load balancer
## It builds the docker image using Docker Compose, runs the server, and sends a GET request to the server
## It checks if the server is up and running and if the response is correct.
## required env var STEEM_LB_PATH
if [ -z "$STEEM_LB_PATH" ]; then
echo "STEEM_LB_PATH is not set"
exit 1
fi
source "$STEEM_LB_PATH/tests/retry-tests.sh"
## build-and-run
if ! pushd "$STEEM_LB_PATH"; then
echo "Failed to pushd to $STEEM_LB_PATH"
exit 1
fi
cleanup() {
docker compose down
popd > /dev/null || true
}
trap cleanup EXIT
docker compose down
echo "Starting the server via docker compose up -d..."
docker compose up -d
MAX_TIMEOUT_SEC=300
while :
do
echo "Waiting for the server to start..."
# check $DOCKER_IMAGE status via docker ps
status=$(docker ps --filter "name=^/${DOCKER_IMAGE}$" --format '{{.Status}}')
if [[ "$status" == Up* ]]; then
break
fi
## check if timeout
if [ $MAX_TIMEOUT_SEC -le 0 ]; then
echo "Timeout: Server did not start"
exit 1
fi
MAX_TIMEOUT_SEC=$((MAX_TIMEOUT_SEC-1))
sleep 1
done
echo "Server is up and running"
## Run the integration tests
source "$STEEM_LB_PATH/tests/tests.sh"
if [ "$RESULT" != "true" ]; then
echo "Integration tests failed!"
exit 1
fi
echo "All integration tests passed!"
exit 0