diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 456455b5461..a93335a977a 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -164,4 +164,3 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Release credentials off main](/quest/m0/ci/publish-release-only.md) - `publish` admits only `release` and release tags once its `workflow_run` publishers run on their tag - [The queue host keeps the queue's disk](/quest/m0/ci/queue-host-disk.md) - agent sessions can't starve the queue runner of disk, and a crashed runner restarts - [Biome checks every file it can parse](/quest/m0/ci/biome-whole-repo.md) - Biome runs over the whole repository and main is clean under it -- [dispatch.sh's tests pass without KVM](/quest/m0/ci/dispatch-test-kvm.md) - `sh/dispatch-query.test.py` fakes the KVM probe instead of failing 20 tests on hosts without `/dev/kvm` diff --git a/quest/m0/ci/dispatch-test-kvm.md b/quest/m0/ci/dispatch-test-kvm.md deleted file mode 100644 index e80d80efb04..00000000000 --- a/quest/m0/ci/dispatch-test-kvm.md +++ /dev/null @@ -1,22 +0,0 @@ -# [XS] dispatch.sh's tests pass without KVM - -## Goal - -`sh/dispatch-query.test.py` passes on a Linux x86_64 host without -`/dev/kvm`, as it does on CI's KVM runners. dispatch.sh still refuses -`check flake` on a host without KVM, the refusal that -[moq-dev/moq#7281](https://github.com/moq-dev/moq/pull/7281) added. - -## Plan - -Decided by the maintainer on 2026-11-01: plan it in m0 ✅ / m1 / drop. - -- Today 20 of its 30 tests fail on such a host. Every run whose selection - includes `check flake` reaches the real `/dev/kvm` probe in - `sh/dispatch.sh`, so the mocked CI run exits 1. `just check` on main - fails locally there too. -- The test harness owns the fix: let it fake the probe's answer, for example - by pointing dispatch.sh at a probe path the test sets. Don't loosen the - refusal, and don't skip the tests when KVM is missing. -- Add a case for the refusal itself: with the probe reporting no KVM, a run - selecting `check flake` fails and names the missing `/dev/kvm`. diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 5fbfbb1a193..f9618820530 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -26,6 +26,8 @@ def setUp(self): (self.repo / "sh").mkdir(parents=True) for script in ("dispatch.sh", "changed.sh", "local.sh"): shutil.copy(ROOT / "sh" / script, self.repo / "sh" / script) + # The stub belongs in the base so it does not widen every test's diff. + (self.repo / "sh/kvm.sh").write_text("#!/bin/sh\nexit 0\n") self.bin = self.root / "bin" self.bin.mkdir() for command in ("bash", "git", "sort", "mktemp", "rm", "grep", "cat", "sed", "tr", "xargs", "sleep"): @@ -127,9 +129,12 @@ def test_selected_tests_do_not_depend_on_installed_tools(self): (self.repo / path).unlink() def test_orchestration_and_all_select_work(self): - self.expect(True, base="--all") + self.expect(True, base="--all", rust=True) self.change("justfile") - self.expect(True) + self.expect(True, rust=True) + (self.repo / "justfile").unlink() + self.change("sh/kvm.sh") + self.expect(True, rust=True) def test_working_tree_changes_and_deletions_count(self): self.change("rs/moq-net/src/lib.rs") @@ -484,7 +489,32 @@ def test_local_flake_probe_errors_are_failures_without_cancelling_other_modules( self.assertNotIn("nix flake check --print-build-logs", calls) self.assertIn("gh test", calls) - def test_strict_ci_runs_the_full_flake_without_a_probe(self): + @unittest.skipUnless(sys.platform == "linux" and os.uname().machine == "x86_64", "Linux VM checks only") + def test_missing_kvm_refuses_flake_without_skipping_or_cancelling_other_modules(self): + for strict in (False, True): + with self.subTest(strict=strict): + self.stub_ci() + self.change("flake.nix") + (self.repo / "sh/kvm.sh").write_text("#!/bin/sh\nexit 1\n") + env = dict(self.env) + if not strict: + env.pop("CI_STRICT") + result = subprocess.run( + ["bash", "sh/dispatch.sh", "ci" if strict else "check", "origin/main"], + cwd=self.repo, + env=env, + text=True, + capture_output=True, + ) + self.assertEqual(result.returncode, 1, result.stderr) + self.assertIn("/dev/kvm is missing", result.stdout + result.stderr) + self.assertRegex(result.stderr, r"\d+ check flake \(failed\)") + self.assertNotIn("(skipped)", result.stderr) + calls = (self.root / "calls").read_text().splitlines() + self.assertNotIn("nix flake check --print-build-logs", calls) + self.assertIn("gh test", calls) + + def test_strict_ci_runs_the_full_flake_without_a_namespace_probe(self): self.change("flake.nix") calls = self.run_ci() self.assertIn("nix flake check --print-build-logs", calls) diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 2a4a4e3f461..ebbb53c14f5 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -50,7 +50,7 @@ else # These files hold the map and the recipes that call it, and match no # module, so a change to them would otherwise validate none of it. - if grep -qE '^(justfile|sh/(dispatch|changed)\.sh|sh/local\.(sh|ts))$' "$changed"; then + if grep -qE '^(justfile|sh/(dispatch|changed|kvm)\.sh|sh/local\.(sh|ts))$' "$changed"; then echo "$action: root orchestration changed; running everything." >&2 all=1 fi @@ -351,7 +351,7 @@ step() { # Without KVM, QEMU falls back to emulation and the VM tests time # out long after. Refuse rather than skip, so a local gate never # reads as passing without them. - if [[ "$OSTYPE" == linux* && "$HOSTTYPE" == x86_64 && ! -e /dev/kvm ]]; then + if [[ "$OSTYPE" == linux* && "$HOSTTYPE" == x86_64 ]] && ! bash sh/kvm.sh; then echo "$action: flake's NixOS VM tests need KVM, but /dev/kvm is missing; run them on a KVM host, as CI does" >&2 return 1 fi diff --git a/sh/kvm.sh b/sh/kvm.sh new file mode 100644 index 00000000000..2d6dac79fad --- /dev/null +++ b/sh/kvm.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Keep the host probe separate so dispatcher fixtures can supply its result. +[[ -e /dev/kvm ]]