Skip to content

test(gateway): find the child's listen marker after libtest's test-name prefix - #2667

Merged
zhanghuidinah merged 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/gateway-watchdog-test-thread-prefix
Nov 16, 2026
Merged

zhanghuidinah merged 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/gateway-watchdog-test-thread-prefix

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No issue is filed. This fixes the gateway-validation / check failure on master since #2538 (push runs 43678871410 and 43735852108, nightly runs 43646075459 and 43770083890).

Rationale for this change

shutdown::tests::default_watchdog_exits_when_request_runtime_cannot_yield and shutdown::tests::default_watchdog_remains_armed_through_runtime_shutdown fail in every master push and nightly run of this job since #2538. Both panic at crates/pc-gateway-app/src/shutdown.rs:342:68 with called Result::unwrap() on an Err value: Timeout, while waiting for the child's LISTEN <addr> line.

The tests re-run the test binary as a child (--exact shutdown::tests::stalled_process_child --nocapture) and read its stdout line by line. When libtest runs with one test thread, it prints test <name> ... without a newline before the test body runs. The child's first marker then arrives as:

test shutdown::tests::stalled_process_child ... LISTEN 127.0.0.1:63753

The parent matched the marker with strip_prefix("LISTEN "), so it never saw it and timed out after 5 s. With several test threads, libtest prints the test name only after the test finishes, and LISTEN starts its own line.

Master pushes and the nightly run this job on the self-hosted powercontext-ci-light runner, which runs libtest with one test thread. Two things show it: the two failures were reported 5 s apart, and the binary's run took 12.06 s in total, so the tests ran one after the other. Fork pull requests, including #2538, run on GitHub-hosted ubuntu-24.04 runners, which have several CPUs, so the tests passed there in 30.12 s with both running at once. The workflow does not set RUST_TEST_THREADS. The single thread most likely comes from the runner exposing one CPU, but that was not observed on the runner.

What changes are included in this PR?

Test-only, in gateway/crates/pc-gateway-app/src/shutdown.rs:

  • The parent looks for LISTEN anywhere in the line (split_once) instead of at its start. The only stdout before the marker is a blank line, running 1 test, and libtest's test <name> ... prefix, and none of them contains LISTEN .
  • The child runs with --test-threads=1, so its output is the same on every host and every run takes the path the self-hosted runner takes. A regression to prefix matching then fails on any machine.

STALLED and OWNERS_JOINED are unchanged. They are printed after LISTEN's newline, so they always start their own lines. The timing assertions and the injected faults are unchanged.

Are there any user-facing changes?

No.

How was this change tested?

On macOS with 18 CPUs and Rust 1.99.1 (CI pins 1.95.0), against upstream/master 303b32cc0:

  • Reproduced the CI failure: RUST_TEST_THREADS=1 cargo test --locked --offline -p pc-gateway-app --bin pc-gateway shutdown::tests::default_watchdog fails both tests at shutdown.rs:342:68 with Timeout, as in CI. Without the variable, both pass.
  • Recorded the child's stdout directly: with RUST_TEST_THREADS=1 the marker shares the test ... line, and with 4 threads it is on its own line.
  • With only the --test-threads=1 pin (prefix matching kept), both tests fail on this multi-CPU host. With the full change:
    • cargo test --locked --offline -p pc-gateway-app --bin pc-gateway shutdown::tests: 5 passed (30.0 s).
    • The same with RUST_TEST_THREADS=1: 5 passed (60.0 s). Both watchdog kinds exited with status 1 after about 30.008 s, inside the 29.99–32 s window.
  • Before the change, cargo test --locked --offline --workspace from gateway/ passed on this host.
  • cargo fmt --all --check and cargo clippy --locked --offline --all-targets -- -D warnings passed.

Self-review against REVIEW.md and an independent Opus review of the diff found no blocking defect, no false marker match, and no effect on the timing assertions.

The fix was not run on the self-hosted runner. The CI run on this PR uses a GitHub-hosted runner unless it comes from a branch of oceanbase/powercontext.

AI usage statement

This change was written by Claude Code (Claude Opus 5.5). Claude Code traced the failure from the CI logs, reproduced it locally, ran the checks listed above, had the diff reviewed by an independent Claude Code agent, and wrote this description.

…me prefix

With one test thread, libtest prints "test <name> ... " without a newline
before the test body runs, so the child's "LISTEN <addr>" line arrives as
"test shutdown::tests::stalled_process_child ... LISTEN <addr>". The parent
matched the marker as a line prefix, never saw it, and timed out after 5 s.
GitHub-hosted runners have several CPUs and passed; the self-hosted runner
used for master pushes and the nightly runs one test thread, so both
default-watchdog tests failed there on every run since oceanbase#2538.

Pin the child to --test-threads=1 so every host produces the same output,
and match the marker anywhere in the line.

@PsiACE PsiACE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@zhanghuidinah zhanghuidinah 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.

/lgtm

@zhanghuidinah
zhanghuidinah merged commit b333cd2 into oceanbase:master Nov 16, 2026
41 checks passed
@hidb4ai hidb4ai added the 1.6.0 v1.6.0 release tracking label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6.0 v1.6.0 release tracking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants