-
Notifications
You must be signed in to change notification settings - Fork 30
/
integrationTest.sh
executable file
·68 lines (57 loc) · 1.44 KB
/
integrationTest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Unit tests first
set +u
if [ -z "$CIRCLECI" ]; then
go test ./... 2>&1 | grep -v 'no test files'
fi
# Attempt to build the docs
set +u
if [ -z "$CIRCLECI" ]; then
cd docs/
make html 2>&1 > /dev/null
echo "Successfully built documentation"
cd ../
fi
# Ensure we have the correct environment variables
if [[ -f "tests/env.sh" ]]; then
echo "env.sh already exists, skipping configuring new accounts..."
source tests/env.sh
else
if [ -n "$CIRCLECI" ]; then
echo "Running in circle with configured environment variables"
else
python3 tests/configure_accounts.py
source tests/env.sh
fi
fi
set -u
# Some colors for pretty output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
# A function used to indent the log output from the tests
indent() { sed 's/^/ /'; }
# Reset docker and wipe all volumes
reset_docker() {
docker-compose down -v --remove-orphans --rmi local
}
cd tests/
reset_docker
echo "Building containers..."
cd ../docker/ && make && cd ../tests/
docker-compose build
echo "Running integration tests..."
docker-compose up -d
docker logs kssh -f | indent
TEST_EXIT_CODE=`docker wait kssh`
if [ -z ${TEST_EXIT_CODE+x} ] || [ "$TEST_EXIT_CODE" -ne 0 ] ; then
printf "${RED}Tests Failed${NC} - Exit Code: $TEST_EXIT_CODE\n"
else
printf "${GREEN}Tests Passed${NC}\n"
fi
docker-compose stop 2>&1 > /dev/null
docker-compose kill 2>&1 > /dev/null
docker-compose rm -f
reset_docker