-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_docker.sh
executable file
·50 lines (44 loc) · 1.46 KB
/
test_docker.sh
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
#!/bin/bash
# Test building and starting Docker container.
# Test basic functionality.
# Requires working SMTP server.
set -e # Exit immediately on any error
set -o pipefail # Fail if any part of a pipeline fails
echo "Starting Beacon test."
echo "---------------------"
echo "Building Docker image..."
echo "---------------------"
DOCKER_BUILDKIT=1 docker build -t beacon-test .
# try to read env file, but ignore it if it does not exist
# in CI the env will be set without this file
source ~/beacon.github.env || echo "Ignore missing file in CI"
echo "Running test..."
echo "---------------------"
docker run --rm \
--entrypoint bash \
-e BEACON_EMAIL_SMTP_SERVER=${BEACON_EMAIL_SMTP_SERVER} \
-e BEACON_EMAIL_SMTP_PORT=${BEACON_EMAIL_SMTP_PORT} \
-e BEACON_EMAIL_SMTP_USERNAME=${BEACON_EMAIL_SMTP_USERNAME} \
-e BEACON_EMAIL_SMTP_PASSWORD=${BEACON_EMAIL_SMTP_PASSWORD} \
-e BEACON_EMAIL_SEND_TO=${BEACON_EMAIL_SEND_TO} \
-e BEACON_EMAIL_SENDER=${BEACON_EMAIL_SENDER} \
-e BEACON_EMAIL_PREFIX='[staging]' \
beacon-test -c '
set -e
/app/beacon start &
echo "executing POST"
curl --retry 3 --retry-connrefused -sS -X POST http://localhost:8088/services/sly-fox/beat
echo "executing GET"
curl -sS -X GET http://localhost:8088/services/sly-fox/status
/app/beacon report --send-mail
'
TEST_RESULT=$?
if [ "$TEST_RESULT" -eq "0" ]; then
echo "Testing: SUCCESS"
echo "----------------"
else
echo "Testing: FAIL"
echo "-------------"
fi
echo "Done."
exit $TEST_RESULT