GeezerVison is showing github.com — Merge pull request #21 from CortexLM/ci/shard-top-level-tests · CortexLM/hypertrain@2708b7d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .github/workflows/ci.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 87 | 87 | shell: bash | 88 | 88 | run: | | 89 | 89 | set -euo pipefail | 90 | | - mapfile -t ALL < <(git ls-files 'tests/**/test_*.py' \ | | 90 | + mapfile -t ALL < <(git ls-files ':(glob)tests/**/test_*.py' \ | 91 | 91 | | grep -v '^tests/sim/' | grep -v '^tests/e2e/' | sort) | 92 | 92 | SEL=() | 93 | 93 | for i in "${!ALL[@]}"; do | |
Collapse file Copy file name to clipboardExpand all lines: tests/conftest.py +3-18Lines changed: 3 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | import subprocess | 6 | 6 | import uuid | 7 | 7 | from pathlib import Path | 8 | | -from typing import Literal | 9 | 8 |
| 10 | 9 | import numpy as np | 11 | 10 | import pytest | 12 | 11 |
| | 12 | +from systemd_probe import classify_systemd_probe | | 13 | + | 13 | 14 | SEQ_LEN = 1024 | 14 | 15 | SAMPLES_PER_SHARD = 128 | 15 | 16 |
| @@ -115,22 +116,6 @@ def corpus_dir(tmp_path_factory: pytest.TempPathFactory) -> Path: | 115 | 116 | return d | 116 | 117 |
| 117 | 118 |
| 118 | | -# Messages meaning "this user/host has no usable system manager", not "the probe broke". | 119 | | -_SYSTEMD_UNAVAILABLE = ( | 120 | | - "Interactive authentication required", | 121 | | - "Access denied", | 122 | | - "Failed to connect to bus", | 123 | | - "System has not been booted with systemd", | 124 | | - "Permission denied", | 125 | | -) | 126 | | - | 127 | | - | 128 | | -def _classify_systemd_probe(returncode: int, stderr: str) -> Literal["ok", "unavailable", "error"]: | 129 | | - if returncode == 0: | 130 | | - return "ok" | 131 | | - return "unavailable" if any(m in stderr for m in _SYSTEMD_UNAVAILABLE) else "error" | 132 | | - | 133 | | - | 134 | 119 | @pytest.fixture(scope="session") | 135 | 120 | def systemd_manager() -> None: | 136 | 121 | """Skip unless this user may start transient units on the system manager, as the product does. | @@ -158,7 +143,7 @@ def systemd_manager() -> None: | 158 | 143 | timeout=30, | 159 | 144 | check=False, | 160 | 145 | ) | 161 | | - verdict = _classify_systemd_probe(probe.returncode, probe.stderr) | | 146 | + verdict = classify_systemd_probe(probe.returncode, probe.stderr) | 162 | 147 | reason = f"rc={probe.returncode} {probe.stderr.strip()[-500:]}" | 163 | 148 | except FileNotFoundError as exc: | 164 | 149 | verdict, reason = "unavailable", repr(exc) | |
Collapse file Copy file name to clipboard +20Lines changed: 20 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +"""Classification of the `systemd-run` probe result (imported by conftest and its unit test).""" | | 2 | + | | 3 | +from __future__ import annotations | | 4 | + | | 5 | +from typing import Literal | | 6 | + | | 7 | +# Messages meaning "this user/host has no usable system manager", not "the probe broke". | | 8 | +_SYSTEMD_UNAVAILABLE = ( | | 9 | + "Interactive authentication required", | | 10 | + "Access denied", | | 11 | + "Failed to connect to bus", | | 12 | + "System has not been booted with systemd", | | 13 | + "Permission denied", | | 14 | +) | | 15 | + | | 16 | + | | 17 | +def classify_systemd_probe(returncode: int, stderr: str) -> Literal["ok", "unavailable", "error"]: | | 18 | + if returncode == 0: | | 19 | + return "ok" | | 20 | + return "unavailable" if any(m in stderr for m in _SYSTEMD_UNAVAILABLE) else "error" |
Collapse file Copy file name to clipboardExpand all lines: tests/test_systemd_probe_classify.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | import pytest | 4 | 4 |
| 5 | | -from conftest import _classify_systemd_probe | | 5 | +from systemd_probe import classify_systemd_probe | 6 | 6 |
| 7 | 7 | DENIED = [ | 8 | 8 | "Failed to start transient service unit: Interactive authentication required.", | | 14 | 14 |
| 15 | 15 |
| 16 | 16 | def test_ok() -> None: | 17 | | - assert _classify_systemd_probe(0, "") == "ok" | | 17 | + assert classify_systemd_probe(0, "") == "ok" | 18 | 18 |
| 19 | 19 |
| 20 | 20 | @pytest.mark.parametrize("stderr", DENIED) | 21 | 21 | def test_unavailable(stderr: str) -> None: | 22 | | - assert _classify_systemd_probe(1, stderr) == "unavailable" | | 22 | + assert classify_systemd_probe(1, stderr) == "unavailable" | 23 | 23 |
| 24 | 24 |
| 25 | 25 | @pytest.mark.parametrize( | 26 | 26 | "stderr", | 27 | 27 | ["Failed to start transient service unit: Resource temporarily unavailable (EAGAIN)", ""], | 28 | 28 | ) | 29 | 29 | def test_error(stderr: str) -> None: | 30 | | - assert _classify_systemd_probe(1, stderr) == "error" | | 30 | + assert classify_systemd_probe(1, stderr) == "error" |
|