Skip to content

Commit

Permalink
Revert "More prints in NatLab to inspect missing event from telio"
Browse files Browse the repository at this point in the history
This reverts commit 503a1d3.
  • Loading branch information
lcruz99 committed Mar 4, 2025
1 parent 207437c commit f5e6a0d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 34 deletions.
File renamed without changes.
44 changes: 21 additions & 23 deletions nat-lab/tests/telio.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ async def on_stderr(stderr: str) -> None:
await exit_stack.enter_async_context(
self._process.run(stdout_callback=on_stdout, stderr_callback=on_stderr)
)
name = self._node.name
try:
await self._process.wait_stdin_ready()

Expand All @@ -430,9 +429,7 @@ async def on_stderr(stderr: str) -> None:
else:
object_uri = f"PYRO:{object_name}@localhost:{host_port}"

self._libtelio_proxy = LibtelioProxy(
name, object_uri, self._telio_features
)
self._libtelio_proxy = LibtelioProxy(object_uri, self._telio_features)
try:
await self.get_proxy().create()
except ProxyConnectionError as err:
Expand All @@ -456,57 +453,63 @@ async def on_stderr(stderr: str) -> None:
yield self
finally:
print(
f"[{name}]:{datetime.now()} Test cleanup: Stopping tcpdump and collecting core dumps"
datetime.now(),
"Test cleanup: Stopping tcpdump and collecting core dumps",
)
if isinstance(self._connection, DockerConnection):
await self.collect_core_dumps()

print(
f"[{name}]:{datetime.now()} Test cleanup: Saving MacOS network info"
datetime.now(),
"Test cleanup: Saving MacOS network info",
)
await self.save_mac_network_info()

print(f"[{name}]:{datetime.now()} Test cleanup: Stopping device")
print(datetime.now(), "Test cleanup: Stopping device")
if self._process.is_executing():
if self._libtelio_proxy:
await self.stop_device()
else:
print(
f"[{name}]:{datetime.now()} Test cleanup: We don't have LibtelioProxy instance, Stop() not called."
datetime.now(),
"[Debug] We don't have LibtelioProxy instance, Stop() not called.",
)
self._quit = True

print(f"[{name}]:{datetime.now()} Test cleanup: Shutting down")
print(datetime.now(), "Test cleanup: Shutting down")
if self._libtelio_proxy:
# flush_logs() is allowed to fail here:
try:
await self.get_proxy().flush_logs()
# Since this is clean up code, catching general exceptions is fine:
except Exception as e: # pylint: disable=broad-exception-caught
print(
f"[{name}]:{datetime.now()} Test cleanup: Exception while flushing logs: {e}"
datetime.now(),
f"Test cleanup: Exception while flushing logs: {e}",
)

await self.get_proxy().shutdown(self._connection.target_name())
else:
print(
f"[{name}]:{datetime.now()} We don't have LibtelioProxy instance, Shutdown() not called."
datetime.now(),
"[Debug] We don't have LibtelioProxy instance, Shutdown() not called.",
)

print(f"[{name}]:{datetime.now()} Test cleanup: Clearing up routes")
print(datetime.now(), "Test cleanup: Clearing up routes")
await self._router.delete_vpn_route()
await self._router.delete_exit_node_route()
await self._router.delete_interface()

print(f"[{name}]:{datetime.now()} Test cleanup: Saving moose dbs")
print(datetime.now(), "Test cleanup: Saving moose dbs")
await self.save_moose_db()

print(f"[{name}]:{datetime.now()} Test cleanup: Checking logs")
print(datetime.now(), "Test cleanup: Checking logs")
await self._check_logs_for_errors()

print(f"[{name}]:{datetime.now()} Test cleanup: Saving logs")
print(datetime.now(), "Test cleanup: Saving logs")
await self._save_logs()

print(f"[{name}]:{datetime.now()} Test cleanup complete")
print(datetime.now(), "Test cleanup complete")

async def simple_start(self):
await self.get_proxy().start_named(
Expand Down Expand Up @@ -873,16 +876,11 @@ async def _event_request_loop(self) -> None:
event = await self.get_proxy().next_event()
while event:
if self._runtime:
print(
f"[{self._node.name}]:[{datetime.now()}] event loop processing: {event}"
)
print(f"[{self._node.name}]: event [{datetime.now()}]: {event}")
self._runtime.handle_event(event)
event = await self.get_proxy().next_event()
await asyncio.sleep(1)
except Exception as e:
print(
f"[{self._node.name}]:{datetime.now()} event loop exiting due to: {e}. self._quit: {self._quit}"
)
except:
if self._quit:
return
raise
Expand Down
12 changes: 2 additions & 10 deletions nat-lab/tests/uniffi/libtelio_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ async def wrap(*args, **kwargs):


class LibtelioProxy:
def __init__(self, name: str, object_uri: str, features: libtelio.Features):
self._name = name
def __init__(self, object_uri: str, features: libtelio.Features):
self._uri = object_uri
self._iterations = 20
self._features = features
Expand Down Expand Up @@ -88,14 +87,7 @@ def create(self):

@move_to_async_thread
def next_event(self) -> libtelio.Event:
try:
ev = self._handle_remote_error(lambda r: r.next_event())
print(f"[{self._name}]:{datetime.now()} proxy::next_event returned: {ev}")
except Exception as e:
print(f"[{self._name}]:{datetime.now()} proxy::next_event: exception {e}")
raise

return ev
return self._handle_remote_error(lambda r: r.next_event())

@move_to_async_thread
def stop(self):
Expand Down
1 change: 0 additions & 1 deletion nat-lab/tests/uniffi/libtelio_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def __init__(self):
self._events: list[libtelio.Event] = []

def event(self, payload):
print(f"{datetime.datetime.now()} enqueue event: {payload}")
self._events.append(payload)

def next_event(self) -> libtelio.Event:
Expand Down

0 comments on commit f5e6a0d

Please sign in to comment.