Fix Athena test port collision (#39048)

This commit is contained in:
Adeeb Shihadeh
2026-10-06 23:43:16 -07:00
committed by GitHub
parent f59056e5b6
commit 657d3a4f7c
@@ -58,9 +58,7 @@ def host():
class TestAthenadMethods(OpenpilotTestCase):
@classmethod
def setup_class(cls):
cls.SOCKET_PORT = 45454
athenad.Api = MockApi # ty: ignore[invalid-assignment] # test double
athenad.LOCAL_PORT_WHITELIST = {cls.SOCKET_PORT}
def setup_method(self):
self.default_params = {
@@ -434,7 +432,7 @@ class TestAthenadMethods(OpenpilotTestCase):
assert athenad.upload_queue.qsize() == 1
assert asdict(athenad.upload_queue.queue[-1]) == asdict(item1)
def test_start_local_proxy(self, mock_create_connection):
def test_start_local_proxy(self, mock_create_connection, mocker):
end_event = threading.Event()
ws_recv = queue.Queue()
@@ -442,11 +440,13 @@ class TestAthenadMethods(OpenpilotTestCase):
mock_ws = MockWebsocket(ws_recv, ws_send)
mock_create_connection.return_value = mock_ws
echo_socket = EchoSocket(self.SOCKET_PORT)
echo_socket = EchoSocket(0)
port = echo_socket.socket.getsockname()[1]
mocker.patch('openpilot.system.athena.athenad.LOCAL_PORT_WHITELIST', {port})
socket_thread = threading.Thread(target=echo_socket.run)
socket_thread.start()
athenad.startLocalProxy(end_event, 'ws://localhost:1234', self.SOCKET_PORT)
athenad.startLocalProxy(end_event, 'ws://localhost:1234', port)
ws_recv.put_nowait(b'ping')
try: