mirror of
https://github.com/elder-plinius/OBLITERATUS.git
synced 2026-12-05 10:34:23 +01:00
Rebaselines the release suite and marker duration budgets to the slowest measured hosted release time + 25% (run 45678651612; suite 3910 s on py3.11 and 5340 s on py3.12; cpu 2010, integration 700, unmarked 2460) and owns every test whose time + 25% exceeds 15 s under #679 with a 90-day review (follow-up #684). Speeds up test_smaller_change rank1 (geometry environments built lazily) and the recipe-search fake edit step (a light helper module). The PR core gate now enforces per-test budgets on each shard's JUnit with a new --testcase-budgets-only mode; suite and marker totals stay release-only. Refs #679
50 lines
2.4 KiB
Python
50 lines
2.4 KiB
Python
"""All shard execution durations count toward the unchanged serial CPU budget."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from xml.etree import ElementTree as ET
|
|
|
|
import pytest
|
|
|
|
from scripts.check_quality_policy import validate_duration_evidence
|
|
from scripts.write_test_evidence import junit_snapshot
|
|
|
|
|
|
SUITE_BUDGETS = {"3.11": 3910.0, "3.12": 5340.0} # #679 rebaseline: measured + 25%
|
|
|
|
|
|
@pytest.mark.parametrize("slow_first", [False, True])
|
|
@pytest.mark.parametrize("version", ["3.11", "3.12"])
|
|
def test_later_or_earlier_slow_shard_exceeds_existing_suite_budget(tmp_path, slow_first, version):
|
|
budget = SUITE_BUDGETS[version]
|
|
times = (budget, 1) if slow_first else (1, budget)
|
|
root = ET.Element("testsuites")
|
|
for index, seconds in enumerate(times):
|
|
suite = ET.SubElement(root, "testsuite", {"time": str(seconds)})
|
|
case = ET.SubElement(suite, "testcase", {"classname": "tests.example", "name": f"test_{index}", "time": "0.01"})
|
|
props = ET.SubElement(case, "properties")
|
|
ET.SubElement(props, "property", {"name": "duration_markers", "value": "cpu"})
|
|
path = tmp_path / "junit.xml"
|
|
ET.ElementTree(root).write(path)
|
|
snapshot = junit_snapshot(path)
|
|
assert snapshot["suite_duration_seconds"] == budget + 1
|
|
assert snapshot["duration_seconds"] == 0.02 # Case budgets remain a separate measure.
|
|
policy = json.loads((Path(__file__).parents[1] / "ci/test-quality-policy.json").read_text())
|
|
assert policy["test_evidence"]["duration_budgets"]["mandatory_cpu"]["max_suite_seconds_by_python"][version] == budget
|
|
failures = validate_duration_evidence({"python": version, "tests": snapshot}, policy)
|
|
assert f"test trend Python {version} suite duration {budget + 1:.3f}s exceeds {budget:.3f}s" in failures
|
|
|
|
|
|
@pytest.mark.parametrize("bad", ["nan", "inf", "-1", "invalid"])
|
|
def test_invalid_later_suite_cannot_hide_behind_first_suite(tmp_path, bad):
|
|
path = tmp_path / "junit.xml"
|
|
path.write_text(f'<testsuites><testsuite time="1"/><testsuite time="{bad}"/></testsuites>')
|
|
with pytest.raises(ValueError, match="testsuite has invalid time"):
|
|
junit_snapshot(path)
|
|
|
|
|
|
def test_missing_time_falls_back_per_suite_without_dropping_other_suites(tmp_path):
|
|
path = tmp_path / "junit.xml"
|
|
path.write_text('<testsuites><testsuite time="2"/><testsuite><testcase time="3"/></testsuite></testsuites>')
|
|
assert junit_snapshot(path)["suite_duration_seconds"] == 5.0
|