Skip to content

The agent that grows with you

test: wait for a spawned gateway stub's argv before matching it

Tekniumc15e04df399e
diff --git a/tests/hermes_cli/test_update_pause_unmapped_home_proof.py b/tests/hermes_cli/test_update_pause_unmapped_home_proof.py
index 735049bcc5a..1402c2eecc7 100644
--- a/tests/hermes_cli/test_update_pause_unmapped_home_proof.py
+++ b/tests/hermes_cli/test_update_pause_unmapped_home_proof.py
@@ -24,6 +24,7 @@ from gateway.status import get_process_start_time
from hermes_cli import dashboard_procs, gateway, process_identity, update_cmd_windows
from hermes_cli import update_pause_record as pause_record
from hermes_cli.update_cmd_windows import _pause_windows_gateways_for_update, _unmapped_ready_filter
+from tests.waiting import wait_until
@pytest.fixture
@@ -41,6 +42,9 @@ def homes_and_spawn(tmp_path):
def spawn(home) -> subprocess.Popen:
proc = subprocess.Popen(argv, env={**os.environ, "HERMES_HOME": str(home)})
procs.append(proc)
+ # Popen returns once exec has begun, before the kernel publishes the new image's argv and
+ # environment: /proc/<pid>/cmdline reads empty for that instant. A gateway is running.
+ wait_until(psutil.Process(proc.pid).cmdline, interval=0.001, what="the spawned gateway's argv")
return proc
yield home_a, home_b, spawn
diff --git a/tests/hermes_cli/test_update_pause_unmapped_identity.py b/tests/hermes_cli/test_update_pause_unmapped_identity.py
index 43627b97faa..e874388d3c0 100644
--- a/tests/hermes_cli/test_update_pause_unmapped_identity.py
+++ b/tests/hermes_cli/test_update_pause_unmapped_identity.py
@@ -17,10 +17,12 @@ import subprocess
import sys
import time
+import psutil
import pytest
from gateway.status import get_process_start_time
from hermes_cli.update_cmd_windows import _unmapped_ready_filter
+from tests.waiting import wait_until
@pytest.fixture
@@ -33,7 +35,10 @@ def spawn(tmp_path):
def _spawn(home) -> subprocess.Popen:
proc = subprocess.Popen(argv, env={**os.environ, "HERMES_HOME": str(home)})
- procs.append(proc) # Popen returns after exec: the gateway argv and environment are in place
+ procs.append(proc)
+ # Popen returns once exec has begun, before the kernel publishes the new image's argv and
+ # environment: /proc/<pid>/cmdline reads empty for that instant. A gateway is running.
+ wait_until(psutil.Process(proc.pid).cmdline, interval=0.001, what="the spawned gateway's argv")
return proc
yield _spawn, argv