tests: the install and upgrade e2e run only in the round after a publication

test_release_e2e.py and test_upgrade_e2e.py install from the real index with
pip and uv, download the release from GitHub and walk the GitHub API: PyPI or
GitHub being down or rate limited reddened every pull request. The e2e tests
of those two files are now deselected from any run that does not name the file
(conftest.py, no new marker: the vocabulary is shared with the core), so
scripts/run_e2e.py, the Windows legs and the hunt do not collect them, and
user-install.yml, which names both, still does. A test collects and checks it,
and checks the wiring.
This commit is contained in:
feder-cr committed 2026-11-16 01:15:37 +01:00
1 parent 85e0084a35
commit 4385d5cfe9
4 files changed
+121

No files matched your search

+2
View File
@@ -131,6 +131,8 @@ jobs:
shell: bash
run: python scripts/ci_lab_geoip.py build
# test_release_e2e.py and test_upgrade_e2e.py (pip, uv, PyPI, the GitHub release) are NOT in this run or in the Windows legs below: tests/conftest.py leaves
# them out of every run that does not name their file, and user-install.yml (the round after the publication) names it. tests/_post_publication.py.
- name: Run the full e2e suite under a virtual display, without the root ones
# PYTHONUNBUFFERED, and it is not a nicety. Without it Python block-buffers
# stdout when it is a pipe, and this step printed NOTHING for 39 minutes
+29
View File
@@ -0,0 +1,29 @@
"""The e2e files that need what exists only AFTER a publication: the index, GitHub releases, pip and uv.
``test_release_e2e.py`` installs the README's block from the real index (uv, pip), downloads the 110 MB binary from the GitHub release, walks every
published version against the changelog and the GitHub API; ``test_upgrade_e2e.py`` upgrades from the previous release with pip. They are the one place that
proves what a user receives, and for the same reason they can be red for a reason that is nobody's change: PyPI or GitHub down or slow, a rate limit, an index
mirror that lags. A gate of a pull request or of a candidate must not wait on any of that (the rule of the project: no real site in a gate; the real ones are
in the release round and the round after the publication), so they run only where ``user-install.yml`` runs them: named on the command line, after the upload.
How that is held, with no new pytest marker (the marker vocabulary is shared with ``invisible_core``, which compares the lists of the repositories):
``tests/conftest.py`` deselects the ``e2e`` tests of these files from every run that does not NAME the file. ``scripts/run_e2e.py`` (the run of ``e2e.yml``,
of the hunt and of a candidate) names none, the Windows legs build their lists from a collection that no longer holds them, and ``user-install.yml`` names both.
"""
from __future__ import annotations
from pathlib import Path
from typing import Iterable
FILES = ("test_release_e2e.py", "test_upgrade_e2e.py")
def named(args: Iterable[str]) -> "set[Path]":
"""The files a command line names (``path`` or ``path::test``), resolved."""
return {Path(str(arg).split("::", 1)[0]).resolve() for arg in args}
def is_left_out(path: "str | Path", args: Iterable[str]) -> bool:
"""True for a test of a post-publication file in a run that does not name that file."""
path = Path(str(path))
return path.name in FILES and path.resolve() not in named(args)
+12
View File
@@ -96,6 +96,18 @@ def pytest_runtest_teardown(item, nextitem):
faulthandler.cancel_dump_traceback_later()
def pytest_collection_modifyitems(config, items):
"""The e2e tests of the post-publication files (``tests/_post_publication.py``: pip, uv, PyPI, GitHub) belong to the round after a publication: a run
that does not NAME their file does not run them. ``user-install.yml`` names both files; ``scripts/run_e2e.py`` and every PR or candidate leg do not."""
import _post_publication
left = [item for item in items
if item.get_closest_marker("e2e") is not None and _post_publication.is_left_out(item.path, config.args)]
if left:
items[:] = [item for item in items if item not in left]
config.hook.pytest_deselected(items=left)
def pytest_unconfigure(config):
global _watchdog_handle
if _watchdog_handle is not None:
@@ -0,0 +1,78 @@
"""The e2e files that install from the index and read GitHub run only in the round after a publication (no browser).
``test_release_e2e.py`` and ``test_upgrade_e2e.py`` (pip, uv, PyPI, the GitHub release and API) can be red for a reason that is nobody's change, and the rule
of the project is that no gate depends on a real site: the gates of a pull request and of a candidate (``e2e.yml``, ``scripts/run_e2e.py``, the hunt) must
not collect them, and ``user-install.yml`` (the round after the publication, weekly and by hand) must still run both. See ``tests/_post_publication.py``.
* the helper: a file is left out unless the command line names it (as ``path`` or ``path::test``), and only the files of the list are touched;
* a real collection (``pytest --collect-only``, no browser): ``-m e2e`` over the whole tests directory holds no test of the two files, and naming them
brings them back; a unit-marked test of the same files is not an e2e test and is not touched;
* the wiring: ``user-install.yml`` names both files with ``-m e2e``, no suite of ``ci/required-suites.json`` lists them (a suite that did would be red when
they are left out), and no other workflow names them.
"""
from __future__ import annotations
import json
import re
import subprocess
import sys
from pathlib import Path
import pytest
import _post_publication as post
pytestmark = pytest.mark.unit
ROOT = Path(__file__).resolve().parent.parent
TESTS = ROOT / "tests"
def test_a_file_of_the_list_is_left_out_unless_the_command_line_names_it():
release = TESTS / "test_release_e2e.py"
other = TESTS / "test_doh_through_the_proxy_e2e.py"
assert post.is_left_out(release, [])
assert post.is_left_out(release, [str(TESTS)]) and post.is_left_out(release, ["tests"])
assert not post.is_left_out(release, [str(release)])
assert not post.is_left_out(release, ["%s::test_x" % release])
assert post.is_left_out(release, [str(TESTS / "test_upgrade_e2e.py")]), "naming the other file does not name this one"
assert not post.is_left_out(other, []), "only the files of the list are touched"
def _collect(*args: str) -> str:
out = subprocess.run([sys.executable, "-m", "pytest", "--collect-only", "-q", "-m", "e2e", "-o", "addopts=", "-p", "no:cacheprovider", *args],
cwd=ROOT, capture_output=True, text=True, timeout=300)
assert out.returncode in (0, 5), out.stdout[-2000:] + out.stderr[-2000:]
return out.stdout
def test_a_collection_of_the_e2e_that_names_no_file_holds_none_of_the_two():
listed = _collect("-k", "release_e2e or upgrade_e2e or persistent_profile", "tests")
assert "test_persistent_profile_keeps_state.py" in listed, "the selection finds nothing: the check below would pass for no reason\n" + listed[-500:]
assert "test_release_e2e" not in listed and "test_upgrade_e2e" not in listed, listed
def test_naming_the_two_files_brings_back_their_e2e_tests_and_only_those():
listed = _collect("tests/test_release_e2e.py", "tests/test_upgrade_e2e.py")
assert "test_release_e2e.py::test_clean_install_the_way_a_user_does_it" in listed
assert "test_upgrade_e2e.py::test_upgrading_from_the_previous_release_moves_the_core_too" in listed
assert "test_every_test_that_installs_from_the_index_has_the_install_deadline" not in listed, "a test with no e2e marker is not collected by -m e2e"
def test_the_round_after_the_publication_names_both_files_and_nothing_else_does():
user_install = (ROOT / ".github" / "workflows" / "user-install.yml").read_text(encoding="utf-8")
runs = re.findall(r"python -m pytest (tests/test_release_e2e\.py tests/test_upgrade_e2e\.py) -m e2e", user_install)
assert len(runs) == 2, "user-install.yml runs the two files on Linux and on Windows, each named with -m e2e: %r" % runs
for name in post.FILES:
assert (TESTS / name).is_file(), name
suites = json.loads((ROOT / "ci" / "required-suites.json").read_text(encoding="utf-8"))
listed = [t for row in suites for t in row["tests"] if Path(t.split("::")[0]).name in post.FILES]
assert listed == [], "a required suite lists a file that the runs leave out: %s" % listed
for workflow in sorted((ROOT / ".github" / "workflows").glob("*.yml")):
if workflow.name == "user-install.yml":
continue
text = workflow.read_text(encoding="utf-8")
for line in text.splitlines():
if line.lstrip().startswith("#"):
continue
assert not any(name in line for name in post.FILES), "%s runs a post-publication file outside user-install.yml: %s" % (workflow.name, line.strip())