Skip to content

Commit 39bd5e2

Browse files
committed
run_all_tests.sh pre test cleanup
1 parent d8c64b0 commit 39bd5e2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

run_all_tests.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,41 @@ else
223223
fi
224224
fi
225225

226+
################################################################################
227+
# CHECK AND CLEANUP TEST SERVER PORTS
228+
# Port 8018 is used by the embedded Jetty test server (configured in test.default.props)
229+
################################################################################
230+
231+
print_header "Checking Test Server Ports"
232+
log_message "Checking if test server port 8018 is available..."
233+
234+
# Check if port 8018 is in use
235+
if lsof -i :8018 >/dev/null 2>&1; then
236+
log_message "[WARNING] Port 8018 is in use - attempting to kill process"
237+
# Try to kill the process using the port
238+
PORT_PID=$(lsof -t -i :8018 2>/dev/null)
239+
if [ -n "$PORT_PID" ]; then
240+
kill -9 $PORT_PID 2>/dev/null || true
241+
sleep 2
242+
log_message "[OK] Killed process $PORT_PID using port 8018"
243+
fi
244+
else
245+
log_message "[OK] Port 8018 is available"
246+
fi
247+
248+
# Also check for any stale Java test processes
249+
STALE_TEST_PROCS=$(ps aux | grep -E "TestServer|ScalaTest.*obp-api" | grep -v grep | awk '{print $2}' || true)
250+
if [ -n "$STALE_TEST_PROCS" ]; then
251+
log_message "[WARNING] Found stale test processes - cleaning up"
252+
echo "$STALE_TEST_PROCS" | xargs kill -9 2>/dev/null || true
253+
sleep 2
254+
log_message "[OK] Cleaned up stale test processes"
255+
else
256+
log_message "[OK] No stale test processes found"
257+
fi
258+
259+
log_message ""
260+
226261
################################################################################
227262
# CLEAN METRICS DATABASE
228263
################################################################################

0 commit comments

Comments
 (0)