78
78
run : |
79
79
echo "=== Testing Dynamic Method - Scale Up to $TEST_SCALE_COUNT ==="
80
80
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
82
83
./manage-clients-dynamic.sh status
83
84
echo "result=PASS" >> $GITHUB_OUTPUT
84
85
echo "message=Scaled up to $TEST_SCALE_COUNT instances successfully" >> $GITHUB_OUTPUT
@@ -91,20 +92,70 @@ jobs:
91
92
id : test-multiple-vnc-ports
92
93
run : |
93
94
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
+ }
95
103
96
- # Check if all VNC ports are listening based on scale count
104
+ # Wait for VNC ports with retry logic (max 60 seconds)
97
105
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"
105
148
fi
106
149
done
107
150
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
+
108
159
if [ $vnc_ports_ok -eq $TEST_SCALE_COUNT ]; then
109
160
echo "result=PASS" >> $GITHUB_OUTPUT
110
161
echo "message=All $TEST_SCALE_COUNT VNC ports are listening correctly" >> $GITHUB_OUTPUT
@@ -120,24 +171,43 @@ jobs:
120
171
id : test-api
121
172
run : |
122
173
echo "=== Testing Dynamic Method - API Tests ==="
123
- sleep 10
174
+ echo "Waiting for API services to be ready..."
175
+ sleep 20
124
176
api_success=0
125
177
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
133
195
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
141
211
142
212
if [ $api_success -eq 2 ]; then
143
213
echo "result=PASS" >> $GITHUB_OUTPUT
@@ -164,12 +234,37 @@ jobs:
164
234
id : test-vnc-port
165
235
run : |
166
236
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
168
263
echo "result=PASS" >> $GITHUB_OUTPUT
169
264
echo "message=VNC port 5900 is listening" >> $GITHUB_OUTPUT
170
265
else
171
266
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
173
268
fi
174
269
175
270
- name : Test VNC Connection Script
0 commit comments