Skip to content

chore: add test sharding to unit tests - #17438

Merged
daniel-sanche merged 127 commits into
mainfrom
ci_sharding
Jul 30, 2026
Merged

chore: add test sharding to unit tests#17438
daniel-sanche merged 127 commits into
mainfrom
ci_sharding

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Added test sharding for unit and mypy tests:

  • added initialize job to unit test CI. It analyzes the modified packages, and spawns up to MAX_SHARDS jobs for each supported Python runtime
  • long-running packages can have a multiplier added in PACKAGE_WEIGHTS. This will cause the system to reserve more time for long-running tests, to better distribute the workload across shards
  • shards are added according to the formula `shards_used = min(1, max(MAX_SHARDS, total_package_weight / 10))
  • adds an end unit test complete step, which is only green if all shards pass. This can be our new required check for unit tests
  • if any single unit test shard fails, the remaining end early to provide quick feedback
  • preview packages will also be selected when modified, and put in the same shard as their parent package (for easier discovery)

Before merge:

  • we need to update the required checks. We can do this after approval, but before merging

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces parallel execution for system tests and implements a sharding mechanism for CI jobs, including a new Python script to group packages and updates to the test runner script. Feedback on these changes focuses on improving reliability and safety: first, by using an EXIT trap in .kokoro/system.sh to guarantee cleanup of isolated gcloud configuration directories in case of test failures; and second, by avoiding global toggles of set -e in ci/run_conditional_tests.sh and instead capturing test exit codes using the || operator.

Comment thread .kokoro/system.sh Outdated
Comment thread .kokoro/system.sh Outdated
Comment thread ci/run_conditional_tests.sh Outdated
@daniel-sanche daniel-sanche changed the title [DRAFT] chore: add test sharding [DRAFT] experiment: add test sharding Jun 12, 2026

@parthea parthea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread .github/workflows/unittest.yml Outdated
Comment thread .github/workflows/unittest.yml
Comment thread .github/workflows/unittest.yml Outdated
Comment thread packages/google-crc32c/.coveragerc Outdated
@daniel-sanche daniel-sanche removed unit_test:all_packages api: firestore Issues related to the Firestore API. labels Jul 30, 2026
@daniel-sanche
daniel-sanche marked this pull request as ready for review July 30, 2026 21:03
@daniel-sanche
daniel-sanche merged commit ec949e9 into main Jul 30, 2026
39 checks passed
@daniel-sanche
daniel-sanche deleted the ci_sharding branch July 30, 2026 22:02
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.

4 participants