Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep native installer checks inside bounded package groups

pulse-triage[bot]6099e65ed1dc
diff --git a/scripts/installtests/native_unix_contract_runner_test.go b/scripts/installtests/native_unix_contract_runner_test.go
new file mode 100644
index 0000000000..de21c5a480
--- /dev/null
+++ b/scripts/installtests/native_unix_contract_runner_test.go
@@ -0,0 +1,95 @@
+//go:build !windows
+
+package installtests
+
+import (
+ "context"
+ "os/exec"
+ "testing"
+ "time"
+)
+
+// Exercise the actual Python runner without recursively running the Go suite.
+// The hosted failure had 500 checks under one package alarm; this control uses
+// that inventory size and verifies admission, exact-once execution and failure
+// propagation, not a claimed reproduction of macOS timing.
+func TestNativeUnixContractRunnerPartitionsWithoutDroppingChecks(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ cmd := exec.CommandContext(ctx, "python3", "-c", `
+import importlib.util
+import re
+import subprocess
+import sys
+from types import SimpleNamespace
+from unittest.mock import patch
+
+spec = importlib.util.spec_from_file_location("native_runner", sys.argv[1])
+runner = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(runner)
+names = [f"TestFixture{i:03d}" for i in range(497)]
+names += ["ExampleInstaller", "FuzzInstaller", "TestFutureFixture"]
+reset = ["TestRootInstallResetSafety", "TestRootInstallResetPersistence"]
+inventory = "\n".join(names + reset + ["BenchmarkIgnored", "ok package 0.1s"])
+groups = runner.partition(inventory)
+assert tuple(runner.GROUPS) == ("general-0", "general-1", "reset")
+assert [len(group) for group in groups] == [250, 250, 2]
+assert sorted(sum(groups, [])) == sorted(names + reset)
+assert len(set(sum(groups, []))) == 502
+assert groups[2] == sorted(reset)
+assert groups == runner.partition("\n".join(reversed(names + reset)))
+for unsafe in ["", "TestOnly", "TestOne\nTestTwo", inventory + "\nTestFixture000",
+ inventory + "\nTestUnsafe|TestInjected", inventory + "\nFuzzBad.*"]:
+ try:
+ runner.partition(unsafe)
+ except ValueError:
+ pass
+ else:
+ raise AssertionError("unsafe or incomplete inventory admitted")
+
+def execute(failure_at=None, output=inventory):
+ calls = []
+ def run(argv, **kwargs):
+ calls.append(argv)
+ assert kwargs["cwd"] == runner.ROOT and kwargs["check"] is True
+ if len(calls) == failure_at:
+ raise subprocess.CalledProcessError(23, argv)
+ if len(calls) == 1:
+ assert argv == ["go", "test", "-list", ".", runner.PACKAGE]
+ assert kwargs["capture_output"] is True and kwargs["text"] is True
+ return SimpleNamespace(stdout=output)
+ assert argv[:6] == ["go", "test", "-count=1", "-timeout", "10m", "-run"]
+ assert argv[-1] == runner.PACKAGE
+ assert argv[6] == "^(" + "|".join(groups[len(calls) - 2]) + ")$"
+ assert "-parallel" not in argv
+ return SimpleNamespace(returncode=0)
+ with patch.object(runner.subprocess, "run", side_effect=run):
+ try:
+ runner.main()
+ except subprocess.CalledProcessError as error:
+ assert failure_at == len(calls) and error.returncode == 23
+ except ValueError:
+ assert output != inventory and len(calls) == 1
+ else:
+ assert failure_at is None and output == inventory
+ return calls
+
+calls = execute()
+assert len(calls) == 4
+patterns = [re.compile(call[6]) for call in calls[1:]]
+for name in names + reset:
+ assert sum(bool(pattern.fullmatch(name)) for pattern in patterns) == 1
+for name in ["TestFixture000/child", "TestInjected", "BenchmarkIgnored", "TestFixture000Extra"]:
+ assert not any(pattern.fullmatch(name) for pattern in patterns)
+for failure_at in range(1, 5):
+ assert len(execute(failure_at=failure_at)) == failure_at
+assert len(execute(output=inventory + "\nTestFixture000")) == 1
+`, repoFile("scripts", "installtests", "run_unix_contracts.py"))
+ output, err := cmd.CombinedOutput()
+ if ctx.Err() != nil {
+ t.Fatalf("native installer runner control deadline: %v", ctx.Err())
+ }
+ if err != nil {
+ t.Fatalf("native installer runner control: %v\n%s", err, output)
+ }
+}
diff --git a/scripts/installtests/run_unix_contracts.py b/scripts/installtests/run_unix_contracts.py
index 372a4f6a6e..1e9e278a25 100644
--- a/scripts/installtests/run_unix_contracts.py
+++ b/scripts/installtests/run_unix_contracts.py
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
-"""Keep the expanded reset matrix separate without dropping installer checks.
+"""Keep native installer checks exhaustive inside bounded package invocations.
Each Go invocation retains the existing ten-minute package deadline; individual
fixture, transport and cleanup deadlines are unchanged. Discover the actual
package inventory so future tests, examples and fuzz seeds remain included.
+The general inventory grew to 500 checks and exhausted that package alarm on
+macOS Intel. Split it deterministically rather than extending safety deadlines.
"""
from pathlib import Path
@@ -12,6 +14,7 @@ import subprocess
ROOT = Path(__file__).resolve().parents[2]
PACKAGE = "./scripts/installtests"
+GROUPS = ("general-0", "general-1", "reset")
def partition(output):
@@ -24,9 +27,12 @@ def partition(output):
raise ValueError("invalid or repeated Go test identity")
seen.add(name)
(reset if name.startswith("TestRootInstallReset") else general).append(name)
- if not general or not reset:
+ if len(general) < 2 or not reset:
raise ValueError("missing general or reset installer inventory")
- return general, reset
+ # Interleave sorted identities so adjacent fixture families do not all
+ # consume the same package budget. Never omit or retry a discovered check.
+ general.sort()
+ return general[::2], general[1::2], sorted(reset)
def main():
@@ -34,7 +40,7 @@ def main():
["go", "test", "-list", ".", PACKAGE], cwd=ROOT,
check=True, capture_output=True, text=True,
)
- for group, names in zip(("general", "reset"), partition(inventory.stdout)):
+ for group, names in zip(GROUPS, partition(inventory.stdout)):
print(f"Native Unix installer {group}: {len(names)} discovered checks", flush=True)
subprocess.run(
["go", "test", "-count=1", "-timeout", "10m", "-run", "^(" + "|".join(names) + ")$", PACKAGE],