-
Notifications
You must be signed in to change notification settings - Fork 308
/
test_e2e
executable file
·75 lines (61 loc) · 1.59 KB
/
test_e2e
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
69
70
71
72
73
74
75
#!/usr/bin/env bash
PROJECT_NAME="node_e2e_test"
PROJECT_FILE="e2e/docker-compose.yml"
SUCCESS_COLOR='\033[0;32m' # green
FAILURE_COLOR="\033[0;31m" # red
DEFAULT_COLOR="\033[0m"
dockerComposeCmd="docker-compose -f $PROJECT_FILE -p $PROJECT_NAME"
print_success () {
echo -e $SUCCESS_COLOR$1$DEFAULT_COLOR
}
print_error () {
echo -e $FAILURE_COLOR$1$DEFAULT_COLOR
}
setup () {
${dockerComposeCmd} up -d db # start database first - it takes about 10 sec untils db startsup, and otherwise db migration fails
if [ ! $? -eq 0 ]; then
print_error "Db startup failed"
cleanup
exit 1
fi
${dockerComposeCmd} build
if [ ! $? -eq 0 ]; then
print_error "Building docker images failed"
cleanup
exit 1
fi
echo "Waiting for db to become up"
while ! ${dockerComposeCmd} exec db mysqladmin ping --protocol=TCP --silent; do
echo -n "."
sleep 1
done
echo "Database is up"
${dockerComposeCmd} run --entrypoint bin/db-upgrade discovery
if [ ! $? -eq 0 ]; then
print_error "Db migration failed"
cleanup
exit 1
fi
${dockerComposeCmd} up -d
if [ ! $? -eq 0 ]; then
print_error "Starting built docker images failed"
cleanup
exit 1
fi
${dockerComposeCmd} logs -f > e2e_tests.log &
}
cleanup () {
echo "Cleaning up"
${dockerComposeCmd} down
}
setup
go test -v ./e2e/... -args --tequila.host=localhost --tequila.port=4052
if [ ! $? -eq 0 ]
then
print_error "Tests failed"
cleanup
exit 1
fi
print_success "Tests passed"
cleanup
exit 0