server/tests-py: If a port is busy, try to figure out why.

Every now and again, I see in CI that a test will abort early because port 8080 is busy. Given that we're running in a fresh Docker container, this makes no sense to me.

On failure, it will now run `lsof -i :$PORT` to try and figure out what's listening on that port.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6285
GitOrigin-RevId: 5eb58d016b2f43872e2c78a7d89d27cfc3e22312
This commit is contained in:
Samir Talwar 2022-10-12 15:26:35 +02:00 committed by hasura-bot
parent 391d8570a1
commit bebff269a6

View File

@ -36,7 +36,12 @@ time_elapsed() {
fail_if_port_busy() {
local PORT="$1"
if nc -z localhost "$PORT"; then
echo "Port $PORT is busy. Exiting"
echo "ERROR:"
echo "Port $PORT is busy."
echo "Output of \`lsof -i :$PORT\`:"
lsof -i ":$PORT"
echo
echo 'Exiting immediately.'
exit 1
fi
}