Skip to content

test: fix unstable unit test TestScaleNode#5366

Open
wk989898 wants to merge 2 commits into
masterfrom
wk989898-patch-6
Open

test: fix unstable unit test TestScaleNode#5366
wk989898 wants to merge 2 commits into
masterfrom
wk989898-patch-6

Conversation

@wk989898

@wk989898 wk989898 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #4837

What is changed and how it works?

TestScaleNode no longer assumes that a NodeManager.Tick has already completed all coordinator bootstrap side effects. After adding
nodes, the test now waits until the new nodes are initialized in the coordinator bootstrapper before asserting the 2/2/2 distribution. After removing a node, it waits until that
node has been removed from bootstrap tracking before asserting the 3/3 distribution

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

Summary by CodeRabbit

  • Tests
    • Improved node-scaling tests to wait for and assert bootstrapper state changes: verifies nodes become initialized after addition and are removed after deletion, using timed polling to ensure reliable membership checks.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 12, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign asddongmen for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a40e4880-38f9-480e-85ae-24bbeddbd1d7

📥 Commits

Reviewing files that changed from the base of the PR and between 77749f6 and 70575df.

📒 Files selected for processing (1)
  • coordinator/coordinator_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/coordinator_test.go

📝 Walkthrough

Walkthrough

TestScaleNode now waits for coordinator.bootstrapper state changes after node additions and removals: it polls NodeInitialized for newly added node IDs and verifies removed node IDs are absent. Two local helpers using require.Eventually implement the polling.

Changes

Bootstrap State Verification in TestScaleNode

Layer / File(s) Summary
Bootstrap state verification in TestScaleNode
coordinator/coordinator_test.go
After adding maintainer nodes, the test waits until those node IDs are marked initialized by coordinator.bootstrapper (requireBootstrapReady). After removing a node, it waits until that node ID is no longer present in the bootstrapper (requireBootstrapNodeRemoved). Both helpers use require.Eventually to poll NodeInitialized / HasNode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

lgtm, approved, size/XS, release-note-none

Suggested reviewers

  • tenfyzhong
  • lidezhu

Poem

🐰 I hopped in tests where nodes would play,
I waited patiently for states to say,
"Initialized" chimed for each new friend,
And gone were nodes that met their end.
A small, steady check — now tests can stay.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing an unstable unit test TestScaleNode by adding proper synchronization for bootstrap operations.
Description check ✅ Passed The description provides issue number, explains what changed and how it works, and addresses the template sections. The release note is not filled but the template allows for flexibility.
Linked Issues check ✅ Passed The PR directly addresses issue #4837 by adding bootstrap-aware assertions that eliminate timing assumptions, making TestScaleNode deterministic and stable in CI.
Out of Scope Changes check ✅ Passed All changes are scoped to stabilizing TestScaleNode through bootstrap synchronization helpers; no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wk989898-patch-6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Copy link
Copy Markdown

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 helper functions requireBootstrapReady and requireBootstrapNodeRemoved in coordinator_test.go to ensure proper synchronization during node scaling tests. These helpers are integrated into TestScaleNode to verify node initialization and removal before checking replication sizes. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Signed-off-by: wk989898 <nhsmwk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unstable unit test TestScaleNode

1 participant