Skip to content

Commit 445fdaf

Browse files
committed
fix(tests): Add timeout to wait_for_ws in helper.bash
Adds a 60-second timeout to the `wait_for_ws` function in `agent/test/helper.bash`. Previously, this function could hang indefinitely in CI environments if the web server failed to start but the monitored JVM process (e.g., Gradle wrapper) remained active. This commonly occurred when a forked application server (like Tomcat via Gretty) crashed during startup. With this change: - The test will now fail explicitly after 60 seconds if the web service at `WS_URL` is unreachable. - Upon timeout or JVM failure, the content of the `$LOG` file will be printed, providing crucial debugging information for CI failures.
1 parent 89e0deb commit 445fdaf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

agent/test/helper.bash

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,23 @@ check_ws_running() {
162162

163163
wait_for_ws() {
164164
local url="${1:-$WS_URL}"
165+
local timeout=60
166+
local start_time=$(date +%s)
167+
165168
while ! curl -Isf "${url}" >/dev/null; do
166169
if ! jcmd $JVM_MAIN_CLASS VM.uptime >&/dev/null; then
167170
echo "$JVM_MAIN_CLASS failed"
171+
if [[ -f "$LOG" ]]; then cat "$LOG"; fi
168172
exit 1
169173
fi
174+
175+
local current_time=$(date +%s)
176+
if (( current_time - start_time > timeout )); then
177+
echo "Timed out waiting for $url"
178+
if [[ -f "$LOG" ]]; then cat "$LOG"; fi
179+
exit 1
180+
fi
181+
170182
sleep 1
171183
done
172184
printf ' ok\n\n'

0 commit comments

Comments
 (0)