forked from interuss/dss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_e2e.sh
More file actions
executable file
·165 lines (136 loc) · 5.03 KB
/
docker_e2e.sh
File metadata and controls
executable file
·165 lines (136 loc) · 5.03 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
set -eo pipefail
echo "Re/Create e2e_test_result file"
RESULTFILE="$(pwd)/e2e_test_result"
touch "${RESULTFILE}"
cat /dev/null > "${RESULTFILE}"
OS=$(uname)
if [[ $OS == "Darwin" ]]; then
# OSX uses BSD readlink
BASEDIR="$(dirname "$0")/.."
else
BASEDIR=$(readlink -e "$(dirname "$0")/..")
fi
echo "e2e base directory is ${BASEDIR}"
cd "${BASEDIR}"
function gather_logs() {
docker logs http-gateway-for-testing 2> http-gateway-for-testing.log
docker logs grpc-backend-for-testing 2> grpc-backend-for-testing.log
}
function cleanup() {
# ----------- clean up -----------
echo "Stopping dummy oauth container"
docker rm -f dummy-oauth-for-testing &> /dev/null || true
echo "Stopping http gateway container"
docker kill -f http-gateway-for-testing &> /dev/null || true
echo "Stopping grpc-backend container"
docker kill -f grpc-backend-for-testing &> /dev/null || true
echo "Stopping crdb docker"
docker rm -f dss-crdb-for-debugging &> /dev/null || true
}
function on_exit() {
gather_logs || true
cleanup
}
function on_sigint() {
cleanup
exit
}
trap on_exit EXIT
trap on_sigint SIGINT
echo " -------------- BOOTSTRAP ----------------- "
echo "Building local container for testing (see grpc-backend-build.log for details)"
docker build --rm . -t local-interuss-dss-image > grpc-backend-build.log
echo "Building db-manager container for testing"
docker build --rm -f cmds/db-manager/Dockerfile . -t local-db-manager > db-manager-build.log
echo " ---------------- CRDB -------------------- "
echo "cleaning up any crdb pre-existing containers"
docker rm -f dss-crdb-for-debugging &> /dev/null || echo "No CRDB to clean up"
echo "Starting cockroachdb with admin port on :8080"
docker run -d --rm --name dss-crdb-for-debugging \
-p 26257:26257 \
-p 8080:8080 \
cockroachdb/cockroach:v20.2.0 start-single-node \
--insecure > /dev/null
sleep 1
echo "Bootstrapping RID Database tables"
docker run --rm --name rid-db-manager \
--link dss-crdb-for-debugging:crdb \
-v "$(pwd)/build/deploy/db_schemas/defaultdb:/db-schemas/defaultdb" \
local-db-manager \
--schemas_dir db-schemas/defaultdb \
--db_version "latest" \
--cockroach_host crdb
sleep 1
echo "Bootstrapping SCD Database tables"
docker run --rm --name scd-db-manager \
--link dss-crdb-for-debugging:crdb \
-v "$(pwd)/build/deploy/db_schemas/scd:/db-schemas/scd" \
local-db-manager \
--schemas_dir db-schemas/scd \
--db_version "latest" \
--cockroach_host crdb
sleep 1
echo " ------------ GRPC BACKEND ---------------- "
echo "Cleaning up any pre-existing grpc-backend container"
docker rm -f grpc-backend-for-testing &> /dev/null || echo "No grpc backend to clean up"
echo "Starting grpc backend on :8081"
docker run -d --name grpc-backend-for-testing \
--link dss-crdb-for-debugging:crdb \
-v "$(pwd)/build/test-certs/auth2.pem:/app/test.crt" \
local-interuss-dss-image \
grpc-backend \
--cockroach_host crdb \
-public_key_files /app/test.crt \
-reflect_api \
-log_format console \
-dump_requests \
-accepted_jwt_audiences local-gateway \
-enable_scd \
-enable_http
sleep 1
echo " ------------- HTTP GATEWAY -------------- "
echo "Cleaning up any pre-existing http-gateway container"
docker rm -f http-gateway-for-testing &> /dev/null || echo "No http gateway to clean up"
echo "Starting http-gateway on :8082"
docker run -d --name http-gateway-for-testing -p 8082:8082 \
--link grpc-backend-for-testing:grpc \
local-interuss-dss-image \
http-gateway \
-grpc-backend grpc:8081 \
-addr :8082 \
-trace-requests \
-enable_scd
echo " -------------- DUMMY OAUTH -------------- "
echo "Building dummy-oauth server container"
docker build --rm -f cmds/dummy-oauth/Dockerfile . -t local-dummy-oauth > dummy-oauth-build.log
echo "Cleaning up any pre-existing dummy-oauth container"
docker rm -f dummy-oauth-for-testing &> /dev/null || echo "No dummy oauth to clean up"
echo "Starting mock oauth server on :8085"
docker run -d --name dummy-oauth-for-testing -p 8085:8085 \
-v "$(pwd)/build/test-certs/auth2.key:/app/test.key" \
local-dummy-oauth \
-private_key_file /app/test.key
sleep 1
echo " -------------- PYTEST -------------- "
echo "Building Integration Test container"
docker build -q --rm -f monitoring/prober/Dockerfile monitoring -t e2e-test
echo "Finally Begin Testing"
docker run --link dummy-oauth-for-testing:oauth \
--link http-gateway-for-testing:local-gateway \
-v "${RESULTFILE}:/app/test_result" \
e2e-test \
"${1:-.}" \
-rsx \
--junitxml=/app/test_result \
--dss-endpoint http://local-gateway:8082 \
--rid-auth "DummyOAuth(http://oauth:8085/token,sub=fake_uss)" \
--scd-auth1 "DummyOAuth(http://oauth:8085/token,sub=fake_uss)" \
--scd-auth2 "DummyOAuth(http://oauth:8085/token,sub=fake_uss2)" \
--scd-api-version 0.3.17
echo "Cleaning up http-gateway container"
docker stop http-gateway-for-testing > /dev/null
test "$(docker inspect http-gateway-for-testing --format='{{.State.ExitCode}}')" = 0
echo "Cleaning up grpc-backend container"
docker stop grpc-backend-for-testing > /dev/null
test "$(docker inspect grpc-backend-for-testing --format='{{.State.ExitCode}}')" = 0