-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathverify.bash
More file actions
executable file
·75 lines (60 loc) · 1.63 KB
/
verify.bash
File metadata and controls
executable file
·75 lines (60 loc) · 1.63 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
#!/usr/bin/env bash
set -euo pipefail
cleanup() {
echo "Running cleanup..."
rm -f verifylogs
docker stop verify 2>/dev/null || true
}
# Handle normal exit and various signals
trap cleanup EXIT
trap cleanup SIGINT
trap cleanup SIGTERM
# Begin Verification
docker build . -t verify-emulator
docker stop verify 2>/dev/null || true
export SPANNER_EMULATOR_HOST=localhost:9010
export SPANNER_DATABASE_ID=db
export SPANNER_INSTANCE_ID=inst
export SPANNER_PROJECT_ID=proj
docker run --rm --env SPANNER_DATABASE_ID=$SPANNER_DATABASE_ID \
--env SPANNER_INSTANCE_ID=$SPANNER_INSTANCE_ID \
--env SPANNER_PROJECT_ID=$SPANNER_PROJECT_ID \
--detach \
--name verify \
-p 9010:9010 \
-p 9020:9020 \
verify-emulator
# wait for emulator to start
MAX_SECONDS_WAIT=30
attempt=1
while [ $attempt -le $MAX_SECONDS_WAIT ]; do
if docker logs verify 2>&1 | grep -q "Cloud Spanner emulator running."; then
break
fi
sleep 1
attempt=$((attempt + 1))
done
if [ $attempt -gt $MAX_SECONDS_WAIT ]; then
echo "Timeout waiting for emulator to start"
exit 1
fi
docker logs verify &> verifylogs
cat verifylogs
echo verifying log output
# Replace multiple greps with
expected_patterns=(
"instance created"
"Cloud Spanner emulator running."
"REST server listening at 0.0.0.0:9020"
"gRPC server listening at 0.0.0.0:9010"
"database created"
)
for pattern in "${expected_patterns[@]}"; do
if ! grep -q "$pattern" verifylogs; then
echo "Error: Missing expected output: $pattern"
exit 1
fi
done
echo logs contain expected output
echo verifying database connection
go run ./tools/connect.go