Skip to content

[#6505] improvement(test): Reuse core database fixtures by test class - #13518

Open
nevzheng wants to merge 7 commits into
apache:mainfrom
nevzheng:codex/6505-core-database-fixture-reuse
Open

nevzheng wants to merge 7 commits into
apache:mainfrom
nevzheng:codex/6505-core-database-fixture-reuse

Conversation

@nevzheng

Copy link
Copy Markdown
Collaborator

What changes were proposed in this pull request?

Reuse the selected relational database backend for all test-template methods in a test class.

  • Reset database tables before each test while retaining the class-scoped backend.
  • Rebuild poisoned fixtures after setup, lifecycle, or test failures.
  • Add explicit fresh-namespace isolation for tests that modify database structure.
  • Preserve legacy per-invocation behavior when no backend lane is selected.
  • Keep Docker containers alive for the complete test plan and surface cleanup failures.
  • Avoid repeated disk cleanup when an existing MySQL or PostgreSQL container is reused.

Why are the changes needed?

Core database tests currently recreate the relational backend and schema for nearly every test-template invocation, even though the database server is already shared. This dominates lane runtime.

In the matched H2 run, this change reduced backend initialization from 460 to 48 while preserving the exact 519-test identity multiset.

Fix: #6505

Depends on: #13517

Related to: #13515

Does this PR introduce any user-facing change?

No. The fixture APIs, isolation annotations, and lifecycle changes are test-only.

How was this patch tested?

  • ./gradlew :core:spotlessApply :integration-test-common:spotlessApply
  • ./gradlew :core:coreUnitTest -PskipDockerTests=false
    • 1,970 passed, 2 skipped
  • ./gradlew :core:coreH2Test -PskipDockerTests=false
    • 519 passed
    • 475 unique normalized identities
    • Identity digest unchanged: 22844eb5cc3bf4e6a0d85f494bb0f4a4510e2be6a3451213ac2b5f32f382f035
  • python3 -B -m unittest discover -s dev/ci/tests -p 'test_core_test_identity.py'
    • 9 passed
Measurement Before After Improvement
Full H2 task 324.243s 78.034s 4.15× faster
JUnit duration 188.266s 67.370s 64.2% lower
Backend initializations 460 48 89.6% fewer

MySQL and PostgreSQL timing evidence will be appended after an exclusive Docker-host validation window.

yuqi1129 and others added 7 commits September 23, 2026 11:16
…the aggregate result jobs

- Fold the `client` Backend IT shard into `others`. Both are short, and the
  merged shard still finishes before the slowest build shard, so PR feedback
  time is unchanged while each backend runs one job less.
- Remove `build-result` and `BackendIT-result`. No branch protection rule
  requires them, so they only added checks.
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.

[Improvement] Backend storage repeatedly restarts in a UT class.

2 participants