Skip to content

Keep the release test split's settings out of pytest runs that tests start - #4140

Merged
anth-volk merged 4 commits into
masterfrom
shard-settings-out-of-subprocesses
Oct 30, 2026
Merged

anth-volk merged 4 commits into
masterfrom
shard-settings-out-of-subprocesses

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #4139

Summary

The first release run with the split release test suite (#4134), run 41063091599, failed on shard 6 of 6, so no deploy job ran.

run_release_tests.sh turns the split on with PYTEST_ADDOPTS="-p tests.release_test_shard_plugin" and the three RELEASE_TEST_SHARD_* variables. test_live_staging_tests_get_one_pytest_worker_each starts its own pytest --collect-only on the two live staging test files, and that process inherited all four, so the plugin ran inside it too: it split just those two files over six shards, kept none on shard 6, and pytest exited with "no tests collected (9 deselected)". The plugin writes the shard's report when it collects, so the inner run also replaced the shard's report; on shards where the inner run kept its tests, check-release-test-shards would have failed instead.

  • tests/release_test_shard_plugin.py: reads its settings once, in pytest_configure, keeps them in the config stash, then removes RELEASE_TEST_SHARD_INDEX, RELEASE_TEST_SHARD_COUNT, RELEASE_TEST_SHARD_REPORT_DIRECTORY and its own -p option (both the -p name and -pname forms) from PYTEST_ADDOPTS in os.environ. Any other PYTEST_ADDOPTS options are kept. A missing or invalid setting still stops the run with the same message.
  • scripts/release_test_shards.py: write_report creates the shard file with exclusive creation and raises FileExistsError if a report is already there, so a second writer fails loudly instead of replacing a shard's report.
  • tests/unit/test_cloud_run_push_workflow.py: removes test_live_staging_tests_get_one_pytest_worker_each and its two helpers. It counted the live staging tests by starting its own pytest process, which is what failed on shard 6. run_live_staging_tests.sh's comment now says a new live test needs -n raised with it; the other checks of the live staging step stay.
  • docs/engineering/skills/testing.md: says how the plugin keeps its settings from pytest runs that tests start.

Red and green

Commit Result
91f4afa0d Test that the release test split stays out of pytest runs that tests start Both new tests fail: the inner test sees the three RELEASE_TEST_SHARD_* variables, and a second write_report does not raise
9cb894439 Keep the release test split's settings out of pytest runs that tests start Both pass
aa6f14a5b Remove the test that the live staging worker count matches the live tests Removes a test, so no failing test applies; the edited new test still passes

The new end-to-end test runs every shard the way run_release_tests.sh does (plugin loaded through PYTEST_ADDOPTS), with a sample test that starts its own pytest process on files the outer run doesn't collect, then runs check-coverage over the reports.

Environment variables

No workflow or script changes. The variables the plugin now removes after reading:

Variable Provider How it reaches the plugin
RELEASE_TEST_SHARD_INDEX push.yml release-tests matrix (matrix.shard_index) Step env: of "Run release tests"
RELEASE_TEST_SHARD_COUNT Literal "6" in push.yml Same step env:
RELEASE_TEST_SHARD_REPORT_DIRECTORY runner.temp in push.yml Same step env:
PYTEST_ADDOPTS Set by .github/scripts/run_release_tests.sh for make test Process environment of make test

Removing them affects only the pytest process that already read them and the processes its tests start. The upload step after make test still reads the report directory from its own ${{ runner.temp }} expression, not from the environment.

Testing

  • The two new tests, run by node ID, at both commits (results above).
  • ruff format --check and ruff check (locked ruff 0.15.12) on the three changed Python files: clean.
  • python scripts/run_quality_guards.py: all guards passed. python -m scripts.rules guard --base-ref origin/master: passed. python -m scripts.rules render: no diff.
  • No new noqa (96 before and after).
  • The rest of the suite, including the existing plugin tests, runs in this PR's CI.

Unverified until the next release run: that all six shards and check-release-test-shards pass on the real suite, and that the deploy jobs then run after the skipped checks.

🤖 Generated with Claude Code

anth-volk and others added 2 commits October 30, 2026 17:56
…start

Release run 41063091599 failed on shard 6 of 6: a test that runs pytest
itself inherited PYTEST_ADDOPTS and the RELEASE_TEST_SHARD_* variables, so
the shard plugin split that inner run's tests too and kept none of them.
The new tests run a shard the way run_release_tests.sh does, with a test
that starts its own pytest process, and check that a shard's report can't
be written twice. Both fail until the plugin and write_report are fixed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…start

The shard plugin now reads RELEASE_TEST_SHARD_INDEX, _COUNT and
_REPORT_DIRECTORY once, in pytest_configure, and then removes them and its
own -p option from PYTEST_ADDOPTS in the process environment. A pytest
process that a test starts, as
test_live_staging_tests_get_one_pytest_worker_each does, therefore collects
its tests without the split instead of deselecting them, and can't replace
the shard's report. write_report now refuses to replace an existing report,
so any second writer fails loudly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 2 commits October 30, 2026 18:26
…ests

test_live_staging_tests_get_one_pytest_worker_each counted the live staging
tests by starting its own pytest process, which is what made release run
41063091599 fail on shard 6. The worker count in run_live_staging_tests.sh
is now kept in step with the live tests by hand; the script's comment says
to raise -n when adding a test. The other live staging step checks stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.15%. Comparing base (6c4d53a) to head (cfad008).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4140       +/-   ##
===========================================
+ Coverage   50.63%   88.15%   +37.52%     
===========================================
  Files         258      274       +16     
  Lines       14955    16393     +1438     
  Branches     2399     2689      +290     
===========================================
+ Hits         7573    14452     +6879     
+ Misses       6751     1271     -5480     
- Partials      631      670       +39     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anth-volk
anth-volk added this pull request to stack #4146 October 30, 2026 16:34
@anth-volk
anth-volk marked this pull request as ready for review October 30, 2026 16:41
@anth-volk
anth-volk merged commit 22c4f36 into master Oct 30, 2026
15 checks passed
@anth-volk
anth-volk deleted the shard-settings-out-of-subprocesses branch October 30, 2026 16:41

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep the release test split's settings out of pytest subprocesses

1 participant