diff options
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/meshbay-node/tests/test_e2e_windows_app.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/packages/meshbay-node/tests/test_e2e_windows_app.py b/packages/meshbay-node/tests/test_e2e_windows_app.py index b407aa8..86e6a62 100644 --- a/packages/meshbay-node/tests/test_e2e_windows_app.py +++ b/packages/meshbay-node/tests/test_e2e_windows_app.py @@ -66,11 +66,20 @@ def _launch(argv: list[str]) -> None: subprocess.Popen(argv, creationflags=0x00000008 | 0x00000200, close_fds=True) -def _node_pids() -> list[int]: +def _node_processes() -> dict[int, int]: + """Every meshbay-node.exe, pid -> Windows session number.""" r = subprocess.run(["tasklist", "/FI", "IMAGENAME eq meshbay-node.exe", "/NH", "/FO", "CSV"], capture_output=True, text=True) - return [int(c[1]) for c in (line.split('","') for line in r.stdout.splitlines()) - if len(c) > 1 and c[1].isdigit()] + rows = (line.strip('"').split('","') for line in r.stdout.splitlines()) + return {int(c[1]): int(c[3]) for c in rows if len(c) > 3 and c[1].isdigit()} + + +def _node_pids() -> list[int]: + return list(_node_processes()) + + +STARTUP_VBS = (APPDATA / "Microsoft" / "Windows" / "Start Menu" / "Programs" / "Startup" + / "MeshBay Node.vbs") def _wait(what: str, cond, timeout: float, every: float = 1.0): @@ -201,9 +210,13 @@ def app(hub): if there.exists(): pytest.fail(f"{there} exists: this test only runs on a machine with no node " "and no app profile -- move them aside, it never deletes them") + task = subprocess.run(["schtasks", "/query", "/tn", "MeshBay Node"], + capture_output=True).returncode == 0 if MODE == "service": - r = subprocess.run(["schtasks", "/query", "/tn", "MeshBay Node"], capture_output=True) - assert r.returncode == 0, "service mode chosen at install, but there is no boot task" + assert task, "service mode chosen at install, but there is no boot task" + else: + assert not task, f"{MODE} mode chosen at install, but the boot task is still there" + assert STARTUP_VBS.exists() == (MODE == "signin"), "the sign-in launcher" APP_PROFILE.mkdir(parents=True) (APP_PROFILE / "config.json").write_text(json.dumps({"hubBase": hub["url"]}), encoding="utf-8") @@ -265,6 +278,10 @@ def test_a_fresh_account_gets_its_node_set_up_and_can_stop_it(app, hub): token = page.eval("JSON.parse(localStorage.getItem('mb_auth')).token") keys = json.loads(_http_get(f"{hub['url']}/v1/users/{username}/pubkeys", token)) assert keys.get("pk_node_ed25519") == status["pk_node_ed25519"] + # Where it runs is the mode: session 0 for the boot task's S4U logon, the + # signed-in session otherwise. + session = _node_processes()[status["pid"]] + assert (session == 0) == (MODE == "service"), f"{MODE} mode, node in session {session}" # Stop: no process left, and only then "Stopped". page.eval("(location.hash = '#/node', 1)") |