mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-06-23 00:09:25 +08:00
test(e2e): fix fresh-env failures in customnode_info and git_clone harnesses
Some checks failed
CI / Validate OpenAPI Specification (push) Has been cancelled
CI / Code Quality Checks (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (macos-latest, 3.10) (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (ubuntu-latest, 3.10) (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (windows-latest, 3.10) (push) Has been cancelled
Python Linting / Run Ruff (push) Has been cancelled
Some checks failed
CI / Validate OpenAPI Specification (push) Has been cancelled
CI / Code Quality Checks (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (macos-latest, 3.10) (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (ubuntu-latest, 3.10) (push) Has been cancelled
E2E Tests on Multiple Platforms / E2E (${{ matrix.os }}, py${{ matrix.python-version }}) (windows-latest, 3.10) (push) Has been cancelled
Python Linting / Run Ruff (push) Has been cancelled
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).
This commit is contained in:
parent
7c09be6955
commit
d09afa5fb1
@ -17,13 +17,16 @@ Usage:
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
E2E_ROOT = os.environ.get("E2E_ROOT", "")
|
E2E_ROOT = os.environ.get("E2E_ROOT", "")
|
||||||
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
|
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
|
||||||
|
CUSTOM_NODES = os.path.join(COMFYUI_PATH, "custom_nodes") if COMFYUI_PATH else ""
|
||||||
SCRIPTS_DIR = os.path.join(
|
SCRIPTS_DIR = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)), "scripts"
|
os.path.dirname(os.path.abspath(__file__)), "scripts"
|
||||||
)
|
)
|
||||||
@ -31,6 +34,16 @@ SCRIPTS_DIR = os.path.join(
|
|||||||
PORT = 8199
|
PORT = 8199
|
||||||
BASE_URL = f"http://127.0.0.1:{PORT}"
|
BASE_URL = f"http://127.0.0.1:{PORT}"
|
||||||
|
|
||||||
|
# Seed pack for the `installed` tests — same CNR test package used by
|
||||||
|
# test_e2e_endpoint.py / test_e2e_task_operations.py. Installed by the
|
||||||
|
# `seed_pack_on_disk` autouse fixture below (this module runs
|
||||||
|
# alphabetically BEFORE test_e2e_endpoint.py, so it cannot rely on that
|
||||||
|
# module having installed the pack — on a fresh E2E env nothing else
|
||||||
|
# seeds it).
|
||||||
|
PACK_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||||
|
PACK_DIR_NAME = "ComfyUI_SigmoidOffsetScheduler"
|
||||||
|
PACK_VERSION = "1.0.1"
|
||||||
|
|
||||||
pytestmark = pytest.mark.skipif(
|
pytestmark = pytest.mark.skipif(
|
||||||
not E2E_ROOT
|
not E2E_ROOT
|
||||||
or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
|
or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
|
||||||
@ -84,6 +97,51 @@ def comfyui():
|
|||||||
_stop_comfyui()
|
_stop_comfyui()
|
||||||
|
|
||||||
|
|
||||||
|
def _pack_exists() -> bool:
|
||||||
|
return os.path.isdir(os.path.join(CUSTOM_NODES, PACK_DIR_NAME))
|
||||||
|
|
||||||
|
|
||||||
|
def _cm_cli_path() -> str:
|
||||||
|
if sys.platform == "win32":
|
||||||
|
return os.path.join(E2E_ROOT, "venv", "Scripts", "cm-cli.exe")
|
||||||
|
return os.path.join(E2E_ROOT, "venv", "bin", "cm-cli")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module", autouse=True)
|
||||||
|
def seed_pack_on_disk():
|
||||||
|
"""Ensure the seed pack is on disk BEFORE the server starts.
|
||||||
|
|
||||||
|
The `installed?mode=imported` test asserts against the startup
|
||||||
|
snapshot, which is frozen when the server boots — so the pack must be
|
||||||
|
installed before the module's `comfyui` fixture launches it. Autouse +
|
||||||
|
module scope guarantees this fixture is instantiated ahead of the
|
||||||
|
non-autouse `comfyui` fixture. Installs via cm-cli (no server needed,
|
||||||
|
creates the same CNR `.tracking` layout) and removes the pack on
|
||||||
|
teardown only if this fixture installed it, leaving the environment
|
||||||
|
as found.
|
||||||
|
"""
|
||||||
|
installed_by_fixture = False
|
||||||
|
if not _pack_exists():
|
||||||
|
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
|
||||||
|
r = subprocess.run(
|
||||||
|
[_cm_cli_path(), "install", f"{PACK_ID}@{PACK_VERSION}"],
|
||||||
|
capture_output=True, text=True, timeout=300, env=env,
|
||||||
|
)
|
||||||
|
assert r.returncode == 0 and _pack_exists(), (
|
||||||
|
f"seed fixture failed: cm-cli install {PACK_ID}@{PACK_VERSION} "
|
||||||
|
f"(exit {r.returncode})\nSTDOUT: {r.stdout[-500:]}\n"
|
||||||
|
f"STDERR: {r.stderr[-500:]}"
|
||||||
|
)
|
||||||
|
installed_by_fixture = True
|
||||||
|
|
||||||
|
yield PACK_ID
|
||||||
|
|
||||||
|
if installed_by_fixture:
|
||||||
|
shutil.rmtree(
|
||||||
|
os.path.join(CUSTOM_NODES, PACK_DIR_NAME), ignore_errors=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Tests — getmappings
|
# Tests — getmappings
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@ -164,10 +222,11 @@ class TestInstalledPacks:
|
|||||||
def test_installed_returns_dict(self, comfyui):
|
def test_installed_returns_dict(self, comfyui):
|
||||||
"""GET /v2/customnode/installed returns dict containing seeded E2E pack with valid per-entry schema.
|
"""GET /v2/customnode/installed returns dict containing seeded E2E pack with valid per-entry schema.
|
||||||
|
|
||||||
WI-M strengthening: previously only dict-type check. The E2E setup
|
WI-M strengthening: previously only dict-type check. The module's
|
||||||
seeds `ComfyUI_SigmoidOffsetScheduler` (the test package used across
|
`seed_pack_on_disk` autouse fixture installs
|
||||||
task_operations/endpoint tests); its presence is a hard precondition
|
`ComfyUI_SigmoidOffsetScheduler` (the test package used across
|
||||||
for most other tests. We now assert it's in the installed dict AND
|
task_operations/endpoint tests) before the server starts.
|
||||||
|
We now assert it's in the installed dict AND
|
||||||
that its entry has the documented InstalledPack fields
|
that its entry has the documented InstalledPack fields
|
||||||
(cnr_id/ver/enabled). Defeats a regression where `installed` returns
|
(cnr_id/ver/enabled). Defeats a regression where `installed` returns
|
||||||
an empty dict despite packs existing on disk.
|
an empty dict despite packs existing on disk.
|
||||||
|
|||||||
@ -64,11 +64,16 @@ def _cm_cli_path() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def _ensure_cache():
|
def _ensure_cache():
|
||||||
"""Run cm-cli update-cache (blocking) to populate Manager cache before tests."""
|
"""Run cm-cli update-cache (blocking) to populate Manager cache before tests.
|
||||||
|
|
||||||
|
Timeout is generous (600s): update-cache downloads the full DB lists
|
||||||
|
over the network and routinely exceeds 120s on slow links, which used
|
||||||
|
to fail the whole module at setup.
|
||||||
|
"""
|
||||||
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
|
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
|
||||||
r = subprocess.run(
|
r = subprocess.run(
|
||||||
[_cm_cli_path(), "update-cache"],
|
[_cm_cli_path(), "update-cache"],
|
||||||
capture_output=True, text=True, timeout=120, env=env,
|
capture_output=True, text=True, timeout=600, env=env,
|
||||||
)
|
)
|
||||||
if r.returncode != 0:
|
if r.returncode != 0:
|
||||||
raise RuntimeError(f"update-cache failed:\n{r.stderr}")
|
raise RuntimeError(f"update-cache failed:\n{r.stderr}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user