Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back stricter events assertion in test-direct-working-path test #936

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
42 changes: 24 additions & 18 deletions nat-lab/tests/test_direct_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,33 +177,39 @@ async def test_direct_working_paths(

print(datetime.now(), "Test direct connection")
await _check_if_true_direct_connection(env)

print(datetime.now(), "Downgrade to relay connections")
# Start collection just before breaking, to not miss disconnects
relay_events = await asyncio.gather(*[
exit_stack.enter_async_context(
run_async_context(
client.wait_for_event_peer(
node.public_key, [NodeState.CONNECTED], [PathType.RELAY]
)
)
)
for client, node in itertools.product(env.clients, env.nodes)
if not client.is_node(node)
])
async with _disable_direct_connection(env, reflexive_ips):
print(datetime.now(), "Downgrade to relay connections")
await asyncio.gather(*[
await exit_stack.enter_async_context(
await asyncio.gather(*relay_events)
await ping_between_all_nodes(env)

# Start collecting direct events, before drop of blocking
print(datetime.now(), "Reconnect to direct connections")
direct_events = await asyncio.gather(*[
exit_stack.enter_async_context(
run_async_context(
client.wait_for_state_peer(
node.public_key, [NodeState.CONNECTED], [PathType.RELAY]
client.wait_for_event_peer(
node.public_key, [NodeState.CONNECTED], [PathType.DIRECT]
)
)
)
for client, node in itertools.product(env.clients, env.nodes)
if not client.is_node(node)
])
await ping_between_all_nodes(env)

print(datetime.now(), "Reconnect to direct connections")
await asyncio.gather(*[
await exit_stack.enter_async_context(
run_async_context(
client.wait_for_state_peer(
node.public_key, [NodeState.CONNECTED], [PathType.DIRECT]
)
)
)
for client, node in itertools.product(env.clients, env.nodes)
if not client.is_node(node)
])
await asyncio.gather(*direct_events)

print(datetime.now(), "Test direct connection again")
await _check_if_true_direct_connection(env)
Expand Down
2 changes: 1 addition & 1 deletion nat-lab/tests/uniffi/libtelio_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def shutdown(self, container_or_vm_name: Optional[str] = None):
"Unknown" if container_or_vm_name is None else container_or_vm_name,
)

except Pyro5.errors.ConnectionClosedError as e:
except (Pyro5.errors.ConnectionClosedError, Pyro5.errors.ConnectionRefusedError) as e:
# Shutting down the server via client request is naturally racy,
# as sending of response is racing against process shutdown (and
# thus server-side socket being closed).
Expand Down
Loading