Skip to content

The agent that grows with you

fix(ci): enforce strict acceptance for delivery gaps

Tekniumfb5c7e278168
diff --git a/tests/ci/test_e2e_strict_acceptance.py b/tests/ci/test_e2e_strict_acceptance.py
new file mode 100644
index 00000000000..c9b4defd3d8
--- /dev/null
+++ b/tests/ci/test_e2e_strict_acceptance.py
@@ -0,0 +1,66 @@
+"""Delivery gap guards must not excuse failures owned by a strict acceptance run."""
+
+import pytest
+
+from tests.e2e.core._pending_fixes import STRICT_ACCEPTANCE_ENV
+from tests.e2e.core.delivery._pending_fixes import known_failure
+
+
+ ("strict", "reason", "refuse_gap"),
+ [
+ (None, "upd-txn: tracked gap", False),
+ ("", "upd-txn: tracked gap", False),
+ ("0", "upd-txn: tracked gap", False),
+ ("other-batch", "upd-txn: tracked gap", False),
+ ("upd-tx", "upd-txn: tracked gap", False),
+ ("upd-txn", "upd-txn-other: tracked gap", False),
+ ("upd-txn", "other-batch: tracked gap", False),
+ ("upd-txn", "upd-txn: tracked gap", True),
+ (" other-batch, 0, upd-txn ", "upd-txn: tracked gap", True),
+ ("1", "other-batch: tracked gap", True),
+ ],
+)
+def test_delivery_gap_respects_strict_owner_scope(monkeypatch, strict, reason, refuse_gap):
+ if strict is None:
+ monkeypatch.delenv(STRICT_ACCEPTANCE_ENV, raising=False)
+ else:
+ monkeypatch.setenv(STRICT_ACCEPTANCE_ENV, strict)
+ callbacks = []
+ gap = AssertionError("marker survived the update")
+ expected = AssertionError if refuse_gap else pytest.xfail.Exception
+
+ # Catch both outcomes so an unexpected xfail cannot excuse this regression test.
+ with pytest.raises((AssertionError, pytest.xfail.Exception)) as caught:
+ with known_failure("marker survived", reason, on_xfail=lambda: callbacks.append("xfail")):
+ raise gap
+
+ assert isinstance(caught.value, expected)
+ if refuse_gap:
+ assert caught.value is gap
+ assert callbacks == []
+ else:
+ assert reason in str(caught.value)
+ assert callbacks == ["xfail"]
+
+
[email protected]("strict", ["", "upd-txn", "1"])
[email protected]("failure", [None, AssertionError("unrelated failure"), ValueError("marker survived")])
+def test_delivery_guard_preserves_clean_passes_and_unrelated_errors(monkeypatch, strict, failure):
+ monkeypatch.setenv(STRICT_ACCEPTANCE_ENV, strict)
+ callbacks = []
+
+ def run_cell():
+ with known_failure("marker survived", "upd-txn: tracked gap", on_xfail=lambda: callbacks.append("xfail")):
+ if failure is not None:
+ raise failure
+ return "passed"
+
+ try:
+ result = run_cell()
+ except (AssertionError, ValueError, pytest.xfail.Exception) as caught:
+ assert caught is failure
+ else:
+ assert failure is None
+ assert result == "passed"
+ assert callbacks == []
diff --git a/tests/e2e/core/delivery/_pending_fixes.py b/tests/e2e/core/delivery/_pending_fixes.py
index d3fa443bb9c..2efc6675abb 100644
--- a/tests/e2e/core/delivery/_pending_fixes.py
+++ b/tests/e2e/core/delivery/_pending_fixes.py
@@ -31,6 +31,8 @@ from typing import Callable, Dict, Iterator, Optional
import pytest
+from tests.e2e.core._pending_fixes import strict_acceptance
+
REPO_ROOT = Path(__file__).resolve().parents[4]
_PRELUDE = "import json, os, sys\nsys.path.insert(0, os.getcwd())\n"
@@ -77,11 +79,12 @@ def known_failure(pattern: str, reason: str,
"""Run-time xfail for a live gap without a fix PR: an ``AssertionError`` raised inside the
block whose message matches ``pattern`` XFAILs the cell; any other failure propagates, and a
clean pass stays a pass. Wrap only the final assertions, after every wait has settled, so a
- lost reply, a failed restart or a timeout can never be mistaken for the gap."""
+ lost reply, a failed restart or a timeout can never be mistaken for the gap. Strict
+ acceptance refuses owned gaps before running any xfail-only bookkeeping."""
try:
yield
except AssertionError as exc:
- if not re.search(pattern, str(exc)):
+ if not re.search(pattern, str(exc)) or strict_acceptance(reason):
raise
if on_xfail is not None:
on_xfail()