GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(capacity): skip system-manager tests when transient units denied · CortexLM/hypertrain@0f1840b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tests
    • challenge
      • test_capacity_outer_v2.py
      • test_service_capacity_v2.py
    • conftest.py
    • miner
      • test_capacity_runtime_v2.py
      • test_island_launch_v2.py
    • relay
      • test_transport_v2.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/challenge/test_capacity_outer_v2.py‎

Copy file name to clipboardExpand all lines: tests/challenge/test_capacity_outer_v2.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def test_request_metadata_rejects_without_tensor_allocation(tiny, tmp_path, monk
193193
OuterRequest.parse(data)
194194

195195

196+
@pytest.mark.usefixtures("systemd_manager")
196197
def test_actual_bounded_outer_child_matches_original_signed_replay(tiny, tmp_path, monkeypatch):
197198
from hypertrain.aggregator.core import OuterState
198199
from hypertrain.aggregator.tape_v2 import TapeV2, make_tape, replay_tape
@@ -672,6 +673,7 @@ def test_genesis_authority_rejects_before_kernel(genesis_tiny, monkeypatch, atta
672673
).fetchone()
673674

674675

676+
@pytest.mark.usefixtures("systemd_manager")
675677
def test_actual_bounded_genesis_preparation_and_duplicate_debit(
676678
genesis_tiny, tmp_path, monkeypatch
677679
):
Collapse file

‎tests/challenge/test_service_capacity_v2.py‎

Copy file name to clipboardExpand all lines: tests/challenge/test_service_capacity_v2.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ def prior_bytes(path):
716716
assert store._record_v2(run_id, "service-admission", "run") == prior
717717

718718

719+
@pytest.mark.usefixtures("systemd_manager")
719720
def test_real_capacity_launch_failure_keeps_debit_and_prevents_restart_rerun(
720721
tiny, tmp_path, monkeypatch
721722
):
Collapse file

‎tests/conftest.py‎

Copy file name to clipboardExpand all lines: tests/conftest.py
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import json
44
import os
5+
import subprocess
6+
import uuid
57
from pathlib import Path
68

79
import numpy as np
@@ -110,3 +112,38 @@ def corpus_dir(tmp_path_factory: pytest.TempPathFactory) -> Path:
110112
d = build_corpus(tmp_path_factory.mktemp("corpus"))
111113
os.environ["HYPERTRAIN_DATA_DIR"] = str(d)
112114
return d
115+
116+
117+
@pytest.fixture(scope="session")
118+
def systemd_manager() -> None:
119+
"""Skip unless this user may start transient units on the system manager, as the product does.
120+
121+
Root that cannot is a broken host, not an unprivileged one: fail, so the heavy `native` job
122+
(isolated root environment) can never turn green by skipping.
123+
"""
124+
try:
125+
probe = subprocess.run(
126+
[
127+
"systemd-run",
128+
"--unit=ht-probe-" + uuid.uuid4().hex,
129+
"--wait",
130+
"--collect",
131+
"--quiet",
132+
"--no-ask-password",
133+
"--property=MemoryMax=64M",
134+
"--property=CPUQuota=50%",
135+
"/bin/true",
136+
],
137+
capture_output=True,
138+
text=True,
139+
timeout=30,
140+
check=False,
141+
)
142+
ok, reason = probe.returncode == 0, f"rc={probe.returncode} {probe.stderr.strip()[-500:]}"
143+
except (OSError, subprocess.TimeoutExpired) as exc:
144+
ok, reason = False, repr(exc)
145+
if ok:
146+
return
147+
if os.geteuid() == 0:
148+
pytest.fail(f"systemd-run as root failed: {reason}")
149+
pytest.skip(f"system manager transient units unavailable: {reason}")
Collapse file

‎tests/miner/test_capacity_runtime_v2.py‎

Copy file name to clipboardExpand all lines: tests/miner/test_capacity_runtime_v2.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def small(monkeypatch, tmp_path):
2323
return launch.CapacityAttempt("11" * 32, "22" * 32, tmp_path / "runtime.lock", lambda: True)
2424

2525

26+
@pytest.mark.usefixtures("systemd_manager")
2627
@pytest.mark.parametrize("mode", ["success", "oom", "cancel", "deadline"])
2728
def test_actual_small_kernel_attempt_and_cleanup(tmp_path, small, mode):
2829
"""Subscribe readiness before triggering real bounded command and await pidfd exit."""
@@ -145,6 +146,7 @@ def test_missing_manager_permission_has_no_unbounded_fallback(tmp_path, small, m
145146
assert not (tmp_path / "attempt/capacity-observed.json").exists()
146147

147148

149+
@pytest.mark.usefixtures("systemd_manager")
148150
def test_real_runner_parent_death_retains_absolute_manager_timer(tmp_path, small):
149151
"""Fork only a stdlib waiting controller; manager timer survives its SIGKILL."""
150152
path = str(tmp_path / "dead.sock")
Collapse file

‎tests/miner/test_island_launch_v2.py‎

Copy file name to clipboardExpand all lines: tests/miner/test_island_launch_v2.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ def test_noisy_failure_retains_only_bounded_error_tail(
304304
assert not (tmp_path / "published").exists()
305305

306306

307+
@pytest.mark.usefixtures("systemd_manager")
307308
def test_capacity_branch_uses_real_bounded_failure_before_publication(tmp_path, monkeypatch):
308309
import os
309310
import sys
Collapse file

‎tests/relay/test_transport_v2.py‎

Copy file name to clipboardExpand all lines: tests/relay/test_transport_v2.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1822,6 +1822,7 @@ def test_image_archive_stdin_through_capture_and_native_shim(tmp_path: Path) ->
18221822
assert json.loads(journal.read_bytes()) == {"cluster": "hypertrain-v2-stream"}
18231823

18241824

1825+
@pytest.mark.usefixtures("systemd_manager")
18251826
def test_launch_safety_independent_systemd_units(tmp_path: Path) -> None:
18261827
import json
18271828
import os

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.