-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·94 lines (80 loc) · 2.53 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·94 lines (80 loc) · 2.53 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
#!/bin/bash
set -e
COMPOSE_FILE="./tests/resources/docker-compose.yml"
# Use "docker compose" (V2) if available, fall back to "docker-compose" (V1)
if docker compose version >/dev/null 2>&1; then
COMPOSE="docker compose"
else
COMPOSE="docker-compose"
fi
cleanup() {
echo "Stopping and removing containers..."
$COMPOSE -f "$COMPOSE_FILE" down -v --remove-orphans 2>/dev/null || true
}
trap cleanup EXIT
echo "Starting Docker environment..."
$COMPOSE -f "$COMPOSE_FILE" up -d --build
echo "Waiting for Keycloak to become healthy..."
timeout=300
elapsed=0
while [ $elapsed -lt $timeout ]; do
if $COMPOSE -f "$COMPOSE_FILE" ps keycloak | grep -q "healthy"; then
echo "Keycloak is healthy."
break
fi
echo "Keycloak not ready yet (${elapsed}s elapsed), waiting..."
sleep 5
elapsed=$((elapsed + 5))
done
if [ $elapsed -ge $timeout ]; then
echo "ERROR: Keycloak did not become healthy within ${timeout}s"
$COMPOSE -f "$COMPOSE_FILE" logs keycloak
exit 1
fi
echo "Starting SirixDB server..."
$COMPOSE -f "$COMPOSE_FILE" up -d server
echo "Waiting for SirixDB to be ready..."
timeout=120
elapsed=0
while [ $elapsed -lt $timeout ]; do
# Use -s -o /dev/null without -f: SirixDB may return 401 at / but that still means it's up
if curl -s -o /dev/null http://localhost:9443 2>&1; then
echo "SirixDB is ready!"
break
fi
echo "SirixDB not ready yet (${elapsed}s elapsed), waiting..."
sleep 5
elapsed=$((elapsed + 5))
done
if [ $elapsed -ge $timeout ]; then
echo "ERROR: SirixDB did not become ready within ${timeout}s"
$COMPOSE -f "$COMPOSE_FILE" logs server
exit 1
fi
echo "Verifying SirixDB authentication works..."
timeout=60
elapsed=0
while [ $elapsed -lt $timeout ]; do
http_code=$(curl -s -o /dev/null -w '%{http_code}' -X POST http://localhost:9443/token \
-H 'Content-Type: application/json' \
-d '{"username":"admin","password":"admin","grant_type":"password"}')
if [ "$http_code" = "200" ]; then
echo "SirixDB authentication verified!"
break
fi
echo "Auth not ready yet (HTTP $http_code, ${elapsed}s elapsed), waiting..."
sleep 3
elapsed=$((elapsed + 3))
done
if [ $elapsed -ge $timeout ]; then
echo "ERROR: SirixDB authentication did not work within ${timeout}s"
echo "Keycloak logs:"
$COMPOSE -f "$COMPOSE_FILE" logs keycloak
echo "SirixDB logs:"
$COMPOSE -f "$COMPOSE_FILE" logs server
exit 1
fi
echo "Running unit tests..."
cargo test --all-features --verbose --lib
echo "Running integration tests (serial)..."
cargo test --all-features --verbose --test sirix -- --test-threads=1