Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/bugfix-fix-protocol-mock-server-ready.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "bugfix",
"category": "tools",
"contributor": "sbiscigl",
"description": "Wait for the protocol tests mock server to accept connections before running each protocol test binary, so the first test no longer fails with a connection refused error when the server is slow to start."
}
9 changes: 9 additions & 0 deletions tools/scripts/run_protocol_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import shutil
import signal
import socket
import subprocess
import time

Expand Down Expand Up @@ -276,6 +277,14 @@ def __init__(self):
python_cmd = [shutil.which("python3"), PROTO_TEST_MOCK_HANDLER]
self.process = subprocess.Popen(python_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print(f"Started mock server with PID {self.process.pid}")
seconds_waited = 0
while seconds_waited < 30:
try:
with socket.create_connection(("127.0.0.1", 1994)):
break
except ConnectionRefusedError:
time.sleep(1)
seconds_waited += 1
except Exception as exc:
print(f"ERROR: unable to start Mock server:\n{exc}")
raise exc
Expand Down
Loading