Skip to content

Commit d09afa5

Browse files
committed
test(e2e): fix fresh-env failures in customnode_info and git_clone harnesses
Two pre-existing harness defects that fail deterministically on a fresh E2E environment (unrelated to the dedicated-install-flags change): - test_e2e_customnode_info: TestInstalledPacks asserted the seed pack ComfyUI_SigmoidOffsetScheduler is installed, but nothing seeded it — the installing module (test_e2e_endpoint) runs alphabetically later and uninstalls it at the end. Add a module-scoped autouse fixture that installs the pack via cm-cli BEFORE the server starts (the imported-mode test asserts against the startup-frozen snapshot, so API-based seeding after boot cannot work) and removes it on teardown only if the fixture installed it. - test_e2e_git_clone: _ensure_cache ran cm-cli update-cache with a 120s timeout; the full DB download routinely exceeds that on slow links, erroring the whole module at setup. Raise to 600s. Verified from a fresh state (seed pack absent): both modules pass (13 tests, incl. previously-failing TestInstalledPacks 2 and TestNightlyInstallCycle 3).
1 parent 7c09be6 commit d09afa5

2 files changed

Lines changed: 70 additions & 6 deletions

File tree

tests/e2e/test_e2e_customnode_info.py

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,33 @@
1717
from __future__ import annotations
1818

1919
import os
20+
import shutil
2021
import subprocess
22+
import sys
2123

2224
import pytest
2325
import requests
2426

2527
E2E_ROOT = os.environ.get("E2E_ROOT", "")
2628
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
29+
CUSTOM_NODES = os.path.join(COMFYUI_PATH, "custom_nodes") if COMFYUI_PATH else ""
2730
SCRIPTS_DIR = os.path.join(
2831
os.path.dirname(os.path.abspath(__file__)), "scripts"
2932
)
3033

3134
PORT = 8199
3235
BASE_URL = f"http://127.0.0.1:{PORT}"
3336

37+
# Seed pack for the `installed` tests — same CNR test package used by
38+
# test_e2e_endpoint.py / test_e2e_task_operations.py. Installed by the
39+
# `seed_pack_on_disk` autouse fixture below (this module runs
40+
# alphabetically BEFORE test_e2e_endpoint.py, so it cannot rely on that
41+
# module having installed the pack — on a fresh E2E env nothing else
42+
# seeds it).
43+
PACK_ID = "ComfyUI_SigmoidOffsetScheduler"
44+
PACK_DIR_NAME = "ComfyUI_SigmoidOffsetScheduler"
45+
PACK_VERSION = "1.0.1"
46+
3447
pytestmark = pytest.mark.skipif(
3548
not E2E_ROOT
3649
or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
@@ -84,6 +97,51 @@ def comfyui():
8497
_stop_comfyui()
8598

8699

100+
def _pack_exists() -> bool:
101+
return os.path.isdir(os.path.join(CUSTOM_NODES, PACK_DIR_NAME))
102+
103+
104+
def _cm_cli_path() -> str:
105+
if sys.platform == "win32":
106+
return os.path.join(E2E_ROOT, "venv", "Scripts", "cm-cli.exe")
107+
return os.path.join(E2E_ROOT, "venv", "bin", "cm-cli")
108+
109+
110+
@pytest.fixture(scope="module", autouse=True)
111+
def seed_pack_on_disk():
112+
"""Ensure the seed pack is on disk BEFORE the server starts.
113+
114+
The `installed?mode=imported` test asserts against the startup
115+
snapshot, which is frozen when the server boots — so the pack must be
116+
installed before the module's `comfyui` fixture launches it. Autouse +
117+
module scope guarantees this fixture is instantiated ahead of the
118+
non-autouse `comfyui` fixture. Installs via cm-cli (no server needed,
119+
creates the same CNR `.tracking` layout) and removes the pack on
120+
teardown only if this fixture installed it, leaving the environment
121+
as found.
122+
"""
123+
installed_by_fixture = False
124+
if not _pack_exists():
125+
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
126+
r = subprocess.run(
127+
[_cm_cli_path(), "install", f"{PACK_ID}@{PACK_VERSION}"],
128+
capture_output=True, text=True, timeout=300, env=env,
129+
)
130+
assert r.returncode == 0 and _pack_exists(), (
131+
f"seed fixture failed: cm-cli install {PACK_ID}@{PACK_VERSION} "
132+
f"(exit {r.returncode})\nSTDOUT: {r.stdout[-500:]}\n"
133+
f"STDERR: {r.stderr[-500:]}"
134+
)
135+
installed_by_fixture = True
136+
137+
yield PACK_ID
138+
139+
if installed_by_fixture:
140+
shutil.rmtree(
141+
os.path.join(CUSTOM_NODES, PACK_DIR_NAME), ignore_errors=True
142+
)
143+
144+
87145
# ---------------------------------------------------------------------------
88146
# Tests — getmappings
89147
# ---------------------------------------------------------------------------
@@ -164,10 +222,11 @@ class TestInstalledPacks:
164222
def test_installed_returns_dict(self, comfyui):
165223
"""GET /v2/customnode/installed returns dict containing seeded E2E pack with valid per-entry schema.
166224
167-
WI-M strengthening: previously only dict-type check. The E2E setup
168-
seeds `ComfyUI_SigmoidOffsetScheduler` (the test package used across
169-
task_operations/endpoint tests); its presence is a hard precondition
170-
for most other tests. We now assert it's in the installed dict AND
225+
WI-M strengthening: previously only dict-type check. The module's
226+
`seed_pack_on_disk` autouse fixture installs
227+
`ComfyUI_SigmoidOffsetScheduler` (the test package used across
228+
task_operations/endpoint tests) before the server starts.
229+
We now assert it's in the installed dict AND
171230
that its entry has the documented InstalledPack fields
172231
(cnr_id/ver/enabled). Defeats a regression where `installed` returns
173232
an empty dict despite packs existing on disk.

tests/e2e/test_e2e_git_clone.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ def _cm_cli_path() -> str:
6464

6565

6666
def _ensure_cache():
67-
"""Run cm-cli update-cache (blocking) to populate Manager cache before tests."""
67+
"""Run cm-cli update-cache (blocking) to populate Manager cache before tests.
68+
69+
Timeout is generous (600s): update-cache downloads the full DB lists
70+
over the network and routinely exceeds 120s on slow links, which used
71+
to fail the whole module at setup.
72+
"""
6873
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
6974
r = subprocess.run(
7075
[_cm_cli_path(), "update-cache"],
71-
capture_output=True, text=True, timeout=120, env=env,
76+
capture_output=True, text=True, timeout=600, env=env,
7277
)
7378
if r.returncode != 0:
7479
raise RuntimeError(f"update-cache failed:\n{r.stderr}")

0 commit comments

Comments
 (0)