@@ -206,36 +206,60 @@ jobs:
206206 fi
207207 echo "=== Early Squid logs ==="
208208 docker logs squid-test 2>&1 || true
209- echo "Waiting for Squid to accept connections..."
210- READY=0
211- for i in $(seq 1 30); do
212- if curl -sf -o /dev/null -w '%{http_code}' -x http://127.0.0.1:3128 http://127.0.0.1:18080/ip 2>/dev/null; then
213- echo "Squid is ready after ${i}s"
214- READY=1
215- break
209+
210+ - name : Wait for Squid to listen
211+ run : |
212+ echo "Waiting for Squid to listen on port 3128..."
213+ for i in $(seq 1 15); do
214+ if bash -c 'echo > /dev/tcp/127.0.0.1/3128' 2>/dev/null; then
215+ echo "Squid is listening after ${i}s"
216+ exit 0
216217 fi
217218 sleep 1
218219 done
219- if [ "$READY" -eq 0 ]; then
220- echo "ERROR: Squid failed to respond within 30 seconds"
221- docker logs squid-test 2>&1 || true
222- exit 1
223- fi
220+ echo "ERROR: Squid never started listening"
221+ docker logs squid-test 2>&1 || true
222+ exit 1
223+
224+ - name : Verify HTTP server is still up
225+ run : curl -sf http://127.0.0.1:18080/ip
224226
225227 - name : Test HTTP request through SOCKS5 peer
226228 run : |
227- RESPONSE=$(curl -v -x http://127.0.0.1:3128 http://127.0.0.1:18080/ip 2>&1)
228- echo "Response: ${RESPONSE}"
229- echo "${RESPONSE}" | grep -q "test" || { echo "FAIL: unexpected response"; exit 1; }
229+ echo "--- Attempting proxy request ---"
230+ HTTP_CODE=$(curl -s -o /tmp/proxy-response.txt -w '%{http_code}' --max-time 15 -x http://127.0.0.1:3128 http://127.0.0.1:18080/ip 2>/tmp/proxy-stderr.txt || true)
231+ echo "HTTP status: ${HTTP_CODE}"
232+ echo "Response body:"
233+ cat /tmp/proxy-response.txt || true
234+ echo ""
235+ echo "Curl stderr:"
236+ cat /tmp/proxy-stderr.txt || true
237+ echo ""
238+ echo "=== Squid logs after request ==="
239+ docker logs squid-test 2>&1 | tail -30 || true
240+ echo ""
241+ # Now assert
242+ [ "${HTTP_CODE}" = "200" ] || { echo "FAIL: expected 200, got ${HTTP_CODE}"; exit 1; }
243+ grep -q "test" /tmp/proxy-response.txt || { echo "FAIL: unexpected response body"; exit 1; }
230244 echo "--- HTTP via SOCKS5 OK ---"
231245
232- - name : Show Squid logs on failure
233- if : failure ()
246+ - name : Collect logs
247+ if : always ()
234248 run : |
235- echo "=== Squid logs ==="
236- docker logs squid-test 2>&1 || true
237- echo "=== SOCKS5 test server logs ==="
238- docker logs socks5-server 2>&1 || true
249+ mkdir -p /tmp/test-logs
250+ docker logs squid-test > /tmp/test-logs/squid.log 2>&1 || true
251+ docker logs socks5-server > /tmp/test-logs/socks5.log 2>&1 || true
252+ cp /tmp/squid-conf/squid.conf /tmp/test-logs/ 2>/dev/null || true
253+ cp /tmp/proxy-response.txt /tmp/test-logs/ 2>/dev/null || true
254+ cp /tmp/proxy-stderr.txt /tmp/test-logs/ 2>/dev/null || true
255+
256+ - name : Upload test logs
257+ if : always()
258+ uses : actions/upload-artifact@v4
259+ with :
260+ name : e2e-test-logs
261+ path : /tmp/test-logs/
262+ retention-days : 3
239263
240264 - name : Cleanup
241265 if : always()
@@ -320,36 +344,58 @@ jobs:
320344 fi
321345 echo "=== Early Squid logs ==="
322346 docker logs squid-auth 2>&1 || true
323- echo "Waiting for Squid to accept connections..."
324- READY=0
325- for i in $(seq 1 30); do
326- if curl -sf -o /dev/null -w '%{http_code}' -x http://127.0.0.1:3128 http://127.0.0.1:18081/ip 2>/dev/null; then
327- echo "Squid ready after ${i}s"
328- READY=1
329- break
347+
348+ - name : Wait for Squid to listen
349+ run : |
350+ for i in $(seq 1 15); do
351+ if bash -c ' echo > /dev/tcp/127.0.0.1/3128' 2>/dev/null; then
352+ echo "Squid is listening after ${i}s"
353+ exit 0
330354 fi
331355 sleep 1
332356 done
333- if [ "$READY" -eq 0 ]; then
334- echo "ERROR: Squid failed to respond within 30 seconds"
335- docker logs squid-auth 2>&1 || true
336- exit 1
337- fi
357+ echo "ERROR: Squid never started listening"
358+ docker logs squid-auth 2>&1 || true
359+ exit 1
360+
361+ - name : Verify HTTP server is still up
362+ run : curl -sf http://127.0.0.1:18081/ip
338363
339364 - name : Test HTTP through authenticated SOCKS5
340365 run : |
341- RESPONSE=$(curl -v -x http://127.0.0.1:3128 http://127.0.0.1:18081/ip 2>&1)
342- echo "Response: ${RESPONSE}"
343- echo "${RESPONSE}" | grep -q "test" || { echo "FAIL"; exit 1; }
366+ echo "--- Attempting proxy request ---"
367+ HTTP_CODE=$(curl -s -o /tmp/proxy-response.txt -w '%{http_code}' --max-time 15 -x http://127.0.0.1:3128 http://127.0.0.1:18081/ip 2>/tmp/proxy-stderr.txt || true)
368+ echo "HTTP status: ${HTTP_CODE}"
369+ echo "Response body:"
370+ cat /tmp/proxy-response.txt || true
371+ echo ""
372+ echo "Curl stderr:"
373+ cat /tmp/proxy-stderr.txt || true
374+ echo ""
375+ echo "=== Squid logs after request ==="
376+ docker logs squid-auth 2>&1 | tail -30 || true
377+ echo ""
378+ [ "${HTTP_CODE}" = "200" ] || { echo "FAIL: expected 200, got ${HTTP_CODE}"; exit 1; }
379+ grep -q "test" /tmp/proxy-response.txt || { echo "FAIL: unexpected body"; exit 1; }
344380 echo "--- HTTP via SOCKS5 auth OK ---"
345381
346- - name : Show logs on failure
347- if : failure ()
382+ - name : Collect logs
383+ if : always ()
348384 run : |
349- echo "=== Squid logs ==="
350- docker logs squid-auth 2>&1 || true
351- echo "=== SOCKS5 auth server logs ==="
352- docker logs socks5-auth 2>&1 || true
385+ mkdir -p /tmp/test-logs-auth
386+ docker logs squid-auth > /tmp/test-logs-auth/squid.log 2>&1 || true
387+ docker logs socks5-auth > /tmp/test-logs-auth/socks5.log 2>&1 || true
388+ cp /tmp/squid-conf-auth/squid.conf /tmp/test-logs-auth/ 2>/dev/null || true
389+ cp /tmp/proxy-response.txt /tmp/test-logs-auth/ 2>/dev/null || true
390+ cp /tmp/proxy-stderr.txt /tmp/test-logs-auth/ 2>/dev/null || true
391+
392+ - name : Upload test logs
393+ if : always()
394+ uses : actions/upload-artifact@v4
395+ with :
396+ name : auth-test-logs
397+ path : /tmp/test-logs-auth/
398+ retention-days : 3
353399
354400 - name : Cleanup
355401 if : always()
0 commit comments