From a1b577be8dff6d7ec3beee12f2c973e2cda867a3 Mon Sep 17 00:00:00 2001 From: Jakub Janowski Date: Thu, 16 Jan 2025 10:51:40 +0200 Subject: [PATCH] Fix test_wg_adapter_cleanup Pyro5 wraps ConnectionRefusedError into Pyro5.errors.CommunicationError The reason why the test is flaky is that sometimes ProcessExecError is raised instaed of Pyro exception. That depends on the order of events in the async event loop. --- .unreleased/natlab_fix | 0 nat-lab/tests/test_wg_adapter.py | 5 ++--- 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .unreleased/natlab_fix diff --git a/.unreleased/natlab_fix b/.unreleased/natlab_fix new file mode 100644 index 000000000..e69de29bb diff --git a/nat-lab/tests/test_wg_adapter.py b/nat-lab/tests/test_wg_adapter.py index 861091584..bab78cda5 100644 --- a/nat-lab/tests/test_wg_adapter.py +++ b/nat-lab/tests/test_wg_adapter.py @@ -2,6 +2,7 @@ from contextlib import AsyncExitStack from datetime import datetime from helpers import SetupParameters, setup_environment +from Pyro5.errors import CommunicationError # type:ignore from utils.bindings import TelioAdapterType from utils.connection_util import ConnectionTag, new_connection_by_tag from utils.process import ProcessExecError @@ -43,9 +44,7 @@ async def test_wg_adapter_cleanup(conn_tag: ConnectionTag): await conn.create_process( ["taskkill", "/T", "/F", "/IM", "python.exe"] ).execute() - except ProcessExecError: - pass - except ConnectionRefusedError as e: + except (CommunicationError, ConnectionRefusedError, ProcessExecError) as e: print(datetime.now(), f"First libtelio failed with {e}") # Check if libtelio left hanging wintun adapter, might now always happen, so we just leave test