Skip to content

test: share expensive fixtures and report setup timing - #28432

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/systematic-ut-duration
Sep 8, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/systematic-ut-duration

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Consolidate the six Issue 26875 foreign-key action tests behind one shared two-CN connection/database fixture while keeping every scenario as a named subtest with disjoint table names.
  • Add structured MO_UT_SETUP timing for shared-cluster startup, task-service readiness, database setup, and rollback/cleanup paths.
  • Summarize the slowest setup phases in the UT report with bounded, cumulative output and add parser/lifecycle tests.
  • Preserve a five-minute deadline for each named scenario under a ten-minute shared fixture deadline, so a hung case fails with a bounded context while other cases retain their names and diagnostics.
  • Harden report parsing for Go's compound durations such as 1m2.5s and 1h2m3s, skip valid non-object JSON records, and register database cleanup before the second connection selects the test database.

In the focused race runs, the six test events totaled about 17.8s before and about 3.6s after the refactor. The observed package elapsed moved from about 19.2s to about 17.7s; startup variance dominates that wall time, so the change reports embedded-cluster startup separately (about 11–12s in the measured runs) instead of treating it as SQL-case work.

Validation

  • mo-cgo-test -count=1 -timeout=10m -json -run '^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues — PASS (13.2s)
  • mo-cgo-test -race -count=1 -timeout=10m -json -run '^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues — PASS (17.8s)
  • mo-cgo-test -count=1 -timeout=10m ./pkg/embed — PASS (46.6s)
  • mo-cgo-test -race -count=1 -timeout=10m ./pkg/embed — PASS (60.6s)
  • GOWORK=off go test ./optools -count=1 — PASS
  • go test -list '^TestIssue26875ForeignKeyActions' ./pkg/tests/issues — selected the intended parent test
  • git diff --check, python3 -m py_compile optools/summarize_ut_setup.py, and bash -n optools/run_ut.sh — PASS

Two complete normal runs of ./pkg/tests/issues were also attempted. They were blocked by timing failures in unchanged tests on this base: TestIssue28313EmptyRemoteDispatch and TestIssue27666CDCWatermarkWriteSerializesWithDrop; each failing focused case was rerun separately and the Issue 28313 case passed on rerun. The changed Issue 26875 selection and owning pkg/embed package pass in both normal and race modes.

@XuPeng-SH
XuPeng-SH requested a review from fengttt as a code owner September 8, 2026 14:48
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Deep review of exact head 26ecb7c. Self-authored PR: COMMENT only.

One confirmed reporting-correctness issue:

[P2] Parse the compound duration strings emitted by Go (optools/summarize_ut_setup.py:31, duration_seconds at lines 42-46). The producers use time.Duration's %s representation, so a 62.5-second phase is logged as duration=1m2.5s, not 62.5s or 1.04m. DURATION_RE accepts only one value/unit pair and summarize silently skips the event. Thus precisely the long startup/cleanup phases this feature is meant to surface disappear from the slow-phase summary, including their error counts. Reproduced by running this exact head's script on two JSON output events: phase=fast duration=2s and phase=slow duration=1m2.5s; exit status was zero and only fast appeared. Emit a machine-readable scalar duration (e.g. integer nanoseconds or fixed seconds), or parse Go's full compound duration format, and add minute/hour-boundary tests. This affects reporting rather than database execution, but is a concrete defect rather than missing-test speculation.

Complete change-map review: all seven files and all changed hunks read, including the full large test extraction. The six scenarios remain named serial subtests with disjoint table prefixes; the two-CN cross-connection checks, prepared reuse, forced-index checks, unique constraints, self-reference, and multilevel cases are preserved. No t.Parallel was introduced. Prepared statements still close in their scenario, database cleanup precedes connection closure, and sql.DB cleanup is registered with the parent test. SharedTestCluster remains serialized by its mutex and retains failed initialization/cleanup ownership; logging introduces no new goroutine or close owner. Setup summary failures remain warning-only in run_ut.sh rather than replacing the UT result. The output is top-20, and accumulation is per fixture/phase rather than per event.

Non-blocking hardening: JSON reports containing a syntactically valid non-object line (e.g. null) currently raise at event.get; consider treating these as malformed records, like invalid JSON. Also register database cleanup immediately after creation/selection rather than after the second connection's USE, so a failure there cannot bypass fixture cleanup.

Evidence scope: the standalone summary reproducer above was executed independently. I did not rerun the embedded/native/race SQL suites; normal/race passes and elapsed-time measurements in the PR body remain author-reported, and the unrelated full-package failures were not reclassified as passing.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GPT-6 Astra (medium) deep review of exact head d36c90c against base/merge-base 4b43f8c.

No confirmed blocking finding in this revision. This is a fresh full-diff review; the earlier-head review is not used as evidence. COMMENT only because this PR is authored by XuPeng-SH.

All seven changed files and all hunks were reviewed. The design gate is exempt: this is focused test-fixture consolidation and setup-report maintenance, with no new kernel feature or major architectural refactor.

Closure Risk and review result
Issue 26875 shared fixture R3 for shared fixture lifetime. All six previous scenarios remain named serial subtests. Reviewed literal/prepared/select variants, cross-CN visibility, unique-rejection and forced-index oracles, self-reference and multilevel cascades. Table prefixes are disjoint; no session/global mutations or parallel subtests are introduced. Each scenario derives a five-minute context, subject to the enclosing ten-minute budget.
Embedded-cluster timing R2 instrumentation on an existing R3 owner. Initialization remains under the same mutex/Once; tracing is synchronous and is not retained for later callbacks. Failed initialization retains the cluster when Close fails, and successful cleanup clears ownership. Logging does not add a worker, generation, lock order, or cleanup owner.
Parser and report integration R1 sequential reporting. Compound Go duration output is accepted; malformed and non-object JSON is ignored. Accumulation is per fixture/phase, output is top-20 by cumulative time, and summary failure remains warning-only without replacing UT status. The executable Python artifact is included by the ignore exception.

Unhappy-path closure: prepared statements close within their scenarios; parent defers attempt database cleanup before closing connections, and parent test cleanup closes the sql.DB pools. Cleanup is now registered before the second connection's USE. SQL cancellation and cleanup use separate bounded contexts. Assertions in a child unwind that child's defers while the parent retains final fixture cleanup. Existing cluster admission/Close waits and service cleanup ownership are unchanged. The SQL data/table population is finite, and report memory grows with distinct phase keys rather than event count. No changed API/wire/disk format, tenant boundary, kernel hot path, or generated-code consumer requires additional compatibility/BVT coverage.

Independent validation on source fetched at this exact SHA passed: duration boundaries from nanoseconds through hours and maximum Go duration, malformed/non-object records, repeated-phase totals/error counts, cumulative ordering and the 20-row cap, plus bash syntax. These checks do not substitute for SQL execution.

Verified CI evidence: Ubuntu UT job belongs to this exact SHA and terminates successfully. Its logs identify pkg/tests/issues as an exclusive race package, report the package PASS (336.65s), and list the parent plus all six changed scenarios and nested variants as PASS (parent 9.32s). The PR's focused normal/race and pkg/embed normal/race runs remain author-reported; I did not independently rerun the native suites. The author correctly separates scenario time from package/startup time rather than claiming a proportional wall-time speedup.

Review was read-only; unrelated dirty workspace changes were excluded.

@XuPeng-SH
XuPeng-SH merged commit fe802bd into matrixorigin:main Sep 8, 2026
27 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/systematic-ut-duration branch September 8, 2026 16:14
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…28432)

## Summary

- Consolidate the six Issue 26875 foreign-key action tests behind one
shared two-CN connection/database fixture while keeping every scenario
as a named subtest with disjoint table names.
- Add structured `MO_UT_SETUP` timing for shared-cluster startup,
task-service readiness, database setup, and rollback/cleanup paths.
- Summarize the slowest setup phases in the UT report with bounded,
cumulative output and add parser/lifecycle tests.
- Preserve a five-minute deadline for each named scenario under a
ten-minute shared fixture deadline, so a hung case fails with a bounded
context while other cases retain their names and diagnostics.
- Harden report parsing for Go's compound durations such as `1m2.5s` and
`1h2m3s`, skip valid non-object JSON records, and register database
cleanup before the second connection selects the test database.

In the focused race runs, the six test events totaled about 17.8s before
and about 3.6s after the refactor. The observed package elapsed moved
from about 19.2s to about 17.7s; startup variance dominates that wall
time, so the change reports embedded-cluster startup separately (about
11–12s in the measured runs) instead of treating it as SQL-case work.

## Validation

- `mo-cgo-test -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (13.2s)
- `mo-cgo-test -race -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (17.8s)
- `mo-cgo-test -count=1 -timeout=10m ./pkg/embed` — PASS (46.6s)
- `mo-cgo-test -race -count=1 -timeout=10m ./pkg/embed` — PASS (60.6s)
- `GOWORK=off go test ./optools -count=1` — PASS
- `go test -list '^TestIssue26875ForeignKeyActions' ./pkg/tests/issues`
— selected the intended parent test
- `git diff --check`, `python3 -m py_compile
optools/summarize_ut_setup.py`, and `bash -n optools/run_ut.sh` — PASS

Two complete normal runs of `./pkg/tests/issues` were also attempted.
They were blocked by timing failures in unchanged tests on this base:
`TestIssue28313EmptyRemoteDispatch` and
`TestIssue27666CDCWatermarkWriteSerializesWithDrop`; each failing
focused case was rerun separately and the Issue 28313 case passed on
rerun. The changed Issue 26875 selection and owning `pkg/embed` package
pass in both normal and race modes.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…28432)

## Summary

- Consolidate the six Issue 26875 foreign-key action tests behind one
shared two-CN connection/database fixture while keeping every scenario
as a named subtest with disjoint table names.
- Add structured `MO_UT_SETUP` timing for shared-cluster startup,
task-service readiness, database setup, and rollback/cleanup paths.
- Summarize the slowest setup phases in the UT report with bounded,
cumulative output and add parser/lifecycle tests.
- Preserve a five-minute deadline for each named scenario under a
ten-minute shared fixture deadline, so a hung case fails with a bounded
context while other cases retain their names and diagnostics.
- Harden report parsing for Go's compound durations such as `1m2.5s` and
`1h2m3s`, skip valid non-object JSON records, and register database
cleanup before the second connection selects the test database.

In the focused race runs, the six test events totaled about 17.8s before
and about 3.6s after the refactor. The observed package elapsed moved
from about 19.2s to about 17.7s; startup variance dominates that wall
time, so the change reports embedded-cluster startup separately (about
11–12s in the measured runs) instead of treating it as SQL-case work.

## Validation

- `mo-cgo-test -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (13.2s)
- `mo-cgo-test -race -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (17.8s)
- `mo-cgo-test -count=1 -timeout=10m ./pkg/embed` — PASS (46.6s)
- `mo-cgo-test -race -count=1 -timeout=10m ./pkg/embed` — PASS (60.6s)
- `GOWORK=off go test ./optools -count=1` — PASS
- `go test -list '^TestIssue26875ForeignKeyActions' ./pkg/tests/issues`
— selected the intended parent test
- `git diff --check`, `python3 -m py_compile
optools/summarize_ut_setup.py`, and `bash -n optools/run_ut.sh` — PASS

Two complete normal runs of `./pkg/tests/issues` were also attempted.
They were blocked by timing failures in unchanged tests on this base:
`TestIssue28313EmptyRemoteDispatch` and
`TestIssue27666CDCWatermarkWriteSerializesWithDrop`; each failing
focused case was rerun separately and the Issue 28313 case passed on
rerun. The changed Issue 26875 selection and owning `pkg/embed` package
pass in both normal and race modes.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…28432)

## Summary

- Consolidate the six Issue 26875 foreign-key action tests behind one
shared two-CN connection/database fixture while keeping every scenario
as a named subtest with disjoint table names.
- Add structured `MO_UT_SETUP` timing for shared-cluster startup,
task-service readiness, database setup, and rollback/cleanup paths.
- Summarize the slowest setup phases in the UT report with bounded,
cumulative output and add parser/lifecycle tests.
- Preserve a five-minute deadline for each named scenario under a
ten-minute shared fixture deadline, so a hung case fails with a bounded
context while other cases retain their names and diagnostics.
- Harden report parsing for Go's compound durations such as `1m2.5s` and
`1h2m3s`, skip valid non-object JSON records, and register database
cleanup before the second connection selects the test database.

In the focused race runs, the six test events totaled about 17.8s before
and about 3.6s after the refactor. The observed package elapsed moved
from about 19.2s to about 17.7s; startup variance dominates that wall
time, so the change reports embedded-cluster startup separately (about
11–12s in the measured runs) instead of treating it as SQL-case work.

## Validation

- `mo-cgo-test -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (13.2s)
- `mo-cgo-test -race -count=1 -timeout=10m -json -run
'^TestIssue26875ForeignKeyActions$' ./pkg/tests/issues` — PASS (17.8s)
- `mo-cgo-test -count=1 -timeout=10m ./pkg/embed` — PASS (46.6s)
- `mo-cgo-test -race -count=1 -timeout=10m ./pkg/embed` — PASS (60.6s)
- `GOWORK=off go test ./optools -count=1` — PASS
- `go test -list '^TestIssue26875ForeignKeyActions' ./pkg/tests/issues`
— selected the intended parent test
- `git diff --check`, `python3 -m py_compile
optools/summarize_ut_setup.py`, and `bash -n optools/run_ut.sh` — PASS

Two complete normal runs of `./pkg/tests/issues` were also attempted.
They were blocked by timing failures in unchanged tests on this base:
`TestIssue28313EmptyRemoteDispatch` and
`TestIssue27666CDCWatermarkWriteSerializesWithDrop`; each failing
focused case was rerun separately and the Issue 28313 case passed on
rerun. The changed Issue 26875 selection and owning `pkg/embed` package
pass in both normal and race modes.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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

size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants