Skip to content

Commit aa2dc46

Browse files
committed
Enhance dynamic method testing workflow with improved waiting logic and error handling. Increase sleep durations for container initialization, add retry logic for VNC port checks and API health tests, and provide detailed logging for debugging.
1 parent d5779a1 commit aa2dc46

File tree

1 file changed

+122
-27
lines changed

1 file changed

+122
-27
lines changed

.github/workflows/test-dynamic-method.yml

Lines changed: 122 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ jobs:
7878
run: |
7979
echo "=== Testing Dynamic Method - Scale Up to $TEST_SCALE_COUNT ==="
8080
if timeout 300 ./manage-clients-dynamic.sh scale $TEST_SCALE_COUNT; then
81-
sleep 5
81+
echo "Waiting for containers to fully initialize..."
82+
sleep 15
8283
./manage-clients-dynamic.sh status
8384
echo "result=PASS" >> $GITHUB_OUTPUT
8485
echo "message=Scaled up to $TEST_SCALE_COUNT instances successfully" >> $GITHUB_OUTPUT
@@ -91,20 +92,70 @@ jobs:
9192
id: test-multiple-vnc-ports
9293
run: |
9394
echo "=== Testing Multiple VNC Ports after scaling ==="
94-
sleep 5
95+
echo "Waiting for containers to start and VNC servers to initialize..."
96+
97+
# Function to check container logs for errors
98+
check_container_logs() {
99+
local container_name=$1
100+
echo "--- Logs for $container_name ---"
101+
docker logs --tail 20 "$container_name" 2>&1 || echo "No logs available for $container_name"
102+
}
95103
96-
# Check if all VNC ports are listening based on scale count
104+
# Wait for VNC ports with retry logic (max 60 seconds)
97105
vnc_ports_ok=0
98-
for i in $(seq 0 $((TEST_SCALE_COUNT - 1))); do
99-
port=$((5900 + i))
100-
if netstat -tuln | grep -q ":$port "; then
101-
echo "✅ VNC port $port is listening"
102-
((vnc_ports_ok++))
103-
else
104-
echo "❌ VNC port $port is not listening"
106+
max_wait=60
107+
start_time=$(date +%s)
108+
109+
for i in $(seq 1 $TEST_SCALE_COUNT); do
110+
port=$((5900 + i - 1))
111+
container_name="wow-clients-client-$i"
112+
echo "Checking VNC port $port for container $container_name..."
113+
114+
# Reset timer for each port
115+
port_start_time=$(date +%s)
116+
port_ready=false
117+
118+
while [ $(($(date +%s) - port_start_time)) -lt $max_wait ]; do
119+
if netstat -tuln | grep -q ":$port "; then
120+
echo "✅ VNC port $port is listening"
121+
port_ready=true
122+
((vnc_ports_ok++))
123+
break
124+
else
125+
echo "⏳ VNC port $port not ready yet, waiting..."
126+
127+
# Check if container is running
128+
if ! docker ps -q --filter "name=^${container_name}$" | grep -q .; then
129+
echo "❌ Container $container_name is not running!"
130+
check_container_logs "$container_name"
131+
break
132+
fi
133+
134+
# Show container logs every 10 seconds for debugging
135+
elapsed=$(($(date +%s) - port_start_time))
136+
if [ $((elapsed % 10)) -eq 0 ] && [ $elapsed -gt 0 ]; then
137+
echo "Container logs after ${elapsed}s:"
138+
check_container_logs "$container_name"
139+
fi
140+
141+
sleep 2
142+
fi
143+
done
144+
145+
if [ "$port_ready" = false ]; then
146+
echo "❌ VNC port $port failed to become ready within $max_wait seconds"
147+
check_container_logs "$container_name"
105148
fi
106149
done
107150
151+
# Final summary
152+
echo "=== VNC Port Check Summary ==="
153+
echo "Ready ports: $vnc_ports_ok/$TEST_SCALE_COUNT"
154+
155+
# Show all container statuses
156+
echo "=== Container Status ==="
157+
docker ps --filter "name=wow-clients-client-" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
158+
108159
if [ $vnc_ports_ok -eq $TEST_SCALE_COUNT ]; then
109160
echo "result=PASS" >> $GITHUB_OUTPUT
110161
echo "message=All $TEST_SCALE_COUNT VNC ports are listening correctly" >> $GITHUB_OUTPUT
@@ -120,24 +171,43 @@ jobs:
120171
id: test-api
121172
run: |
122173
echo "=== Testing Dynamic Method - API Tests ==="
123-
sleep 10
174+
echo "Waiting for API services to be ready..."
175+
sleep 20
124176
api_success=0
125177
126-
# Test health endpoint
127-
if curl -f http://localhost:5000/health; then
128-
echo "✅ Health check passed"
129-
((api_success++))
130-
else
131-
echo "❌ Health check failed"
132-
fi
178+
# Test health endpoint with retry
179+
echo "Testing health endpoint..."
180+
for attempt in {1..10}; do
181+
if curl -f http://localhost:5000/health; then
182+
echo "✅ Health check passed on attempt $attempt"
183+
((api_success++))
184+
break
185+
else
186+
echo "⏳ Health check attempt $attempt failed, retrying..."
187+
if [ $attempt -eq 10 ]; then
188+
echo "❌ Health check failed after 10 attempts"
189+
echo "Container logs:"
190+
docker logs --tail 20 wow-clients-client-1 2>&1 || echo "No logs available"
191+
fi
192+
sleep 3
193+
fi
194+
done
133195
134-
# Test desktop snapshot
135-
if curl -f http://localhost:5000/desktop-snapshot; then
136-
echo "✅ Desktop snapshot passed"
137-
((api_success++))
138-
else
139-
echo "❌ Desktop snapshot failed"
140-
fi
196+
# Test desktop snapshot with retry
197+
echo "Testing desktop snapshot..."
198+
for attempt in {1..5}; do
199+
if curl -f http://localhost:5000/desktop-snapshot; then
200+
echo "✅ Desktop snapshot passed on attempt $attempt"
201+
((api_success++))
202+
break
203+
else
204+
echo "⏳ Desktop snapshot attempt $attempt failed, retrying..."
205+
if [ $attempt -eq 5 ]; then
206+
echo "❌ Desktop snapshot failed after 5 attempts"
207+
fi
208+
sleep 5
209+
fi
210+
done
141211
142212
if [ $api_success -eq 2 ]; then
143213
echo "result=PASS" >> $GITHUB_OUTPUT
@@ -164,12 +234,37 @@ jobs:
164234
id: test-vnc-port
165235
run: |
166236
echo "=== Testing VNC Port Listening ==="
167-
if netstat -tuln | grep -q ":5900 "; then
237+
echo "Waiting for VNC port 5900 to be ready..."
238+
239+
# Wait for VNC port with retry logic (max 30 seconds)
240+
max_wait=30
241+
start_time=$(date +%s)
242+
port_ready=false
243+
244+
while [ $(($(date +%s) - start_time)) -lt $max_wait ]; do
245+
if netstat -tuln | grep -q ":5900 "; then
246+
echo "✅ VNC port 5900 is listening"
247+
port_ready=true
248+
break
249+
else
250+
echo "⏳ VNC port 5900 not ready yet, waiting..."
251+
252+
# Check container logs for debugging
253+
if docker ps -q --filter "name=wow-clients-client-1" | grep -q .; then
254+
echo "Container logs:"
255+
docker logs --tail 10 wow-clients-client-1 2>&1 || echo "No logs available"
256+
fi
257+
258+
sleep 2
259+
fi
260+
done
261+
262+
if [ "$port_ready" = true ]; then
168263
echo "result=PASS" >> $GITHUB_OUTPUT
169264
echo "message=VNC port 5900 is listening" >> $GITHUB_OUTPUT
170265
else
171266
echo "result=FAIL" >> $GITHUB_OUTPUT
172-
echo "message=VNC port 5900 is not listening" >> $GITHUB_OUTPUT
267+
echo "message=VNC port 5900 is not listening after $max_wait seconds" >> $GITHUB_OUTPUT
173268
fi
174269
175270
- name: Test VNC Connection Script

0 commit comments

Comments
 (0)