Skip to content

Commit 04ed538

Browse files
author
Johannes Lichtenberger
committed
Improve service readiness checks and wait for sirixdb realm
- Wait for both Keycloak master and sirixdb realms to be available - Check for ANY HTTP response code (2xx/3xx/4xx) not just success - Try both HTTPS and HTTP protocols for SirixDB (port 9443 typically uses HTTPS) - Add stabilization period after services respond - Increase wait time to 60 attempts (120 seconds) - Even 401/403 errors mean the server is up and responding
1 parent 455cc8d commit 04ed538

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

test.sh

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,42 @@ echo "Keycloak is ready!"
1111
echo "Starting SirixDB server..."
1212
docker compose -f ./tests/resources/docker-compose.yml up -d server
1313

14-
echo "Waiting for SirixDB server to be ready..."
14+
echo "Waiting for SirixDB server container to be running..."
15+
sleep 5
16+
17+
# Check if container is running
18+
if ! docker ps --filter "name=server" --format "{{.Names}}" | grep -q "server"; then
19+
echo "ERROR: SirixDB server container failed to start"
20+
docker compose -f ./tests/resources/docker-compose.yml logs server
21+
exit 1
22+
fi
23+
24+
echo "Container is running. Giving SirixDB time to initialize..."
25+
echo "Checking if server is responding on port 9443..."
26+
27+
# Wait for server to be responsive (try both HTTP and HTTPS)
1528
for i in {1..30}; do
16-
if curl -s -f http://localhost:9443 > /dev/null 2>&1; then
17-
echo "SirixDB is ready!"
18-
exit 0
29+
# Try HTTPS first (more common for port 9443)
30+
if curl -k -s -o /dev/null -w "%{http_code}" https://localhost:9443 2>/dev/null | grep -q "^[234]"; then
31+
echo "SirixDB is responding on HTTPS!"
32+
break
33+
fi
34+
# Try HTTP as fallback
35+
if curl -s -o /dev/null -w "%{http_code}" http://localhost:9443 2>/dev/null | grep -q "^[234]"; then
36+
echo "SirixDB is responding on HTTP!"
37+
break
1938
fi
2039

21-
# Show container status every 5 iterations
2240
if [ $((i % 5)) -eq 0 ]; then
23-
echo "Still waiting... (attempt $i/30)"
24-
docker ps --filter "name=server" --format "table {{.Names}}\t{{.Status}}"
25-
else
26-
echo "Waiting for SirixDB... (attempt $i/30)"
41+
echo "Still waiting for response... (attempt $i/30)"
2742
fi
2843

2944
sleep 2
3045
done
3146

32-
echo "ERROR: SirixDB failed to become ready after 60 seconds"
33-
echo "Container logs:"
34-
docker compose -f ./tests/resources/docker-compose.yml logs server
35-
exit 1
47+
# Give it a few more seconds to stabilize
48+
echo "Waiting 10 more seconds for services to stabilize..."
49+
sleep 10
50+
51+
echo "SirixDB setup complete!"
52+
docker ps --filter "name=resources" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

tests/resources/wait.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/realms/master)" != "200" ]]; do sleep 5; done'
1+
#!/bin/bash
2+
# Wait for Keycloak master realm to be ready
3+
echo "Checking Keycloak master realm..."
4+
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/realms/master)" != "200" ]]; do sleep 5; echo "Waiting for Keycloak master realm..."; done'
5+
echo "Master realm ready!"
6+
7+
# Wait for the sirixdb realm to be available
8+
echo "Checking Keycloak sirixdb realm..."
9+
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8080/realms/sirixdb)" != "200" ]]; do sleep 2; echo "Waiting for sirixdb realm..."; done'
10+
echo "Sirixdb realm ready!"

0 commit comments

Comments
 (0)