Skip to content

server/join: add unit and integration test coverage#10977

Closed
ljluestc wants to merge 1 commit into
tikv:masterfrom
ljluestc:private/issue-2288-server-join-ut-coverage
Closed

server/join: add unit and integration test coverage#10977
ljluestc wants to merge 1 commit into
tikv:masterfrom
ljluestc:private/issue-2288-server-join-ut-coverage

Conversation

@ljluestc

@ljluestc ljluestc commented Jul 5, 2026

Copy link
Copy Markdown

Add server/join/join_test.go with white-box unit tests for the two previously untested code paths:

  • TestIsDataExist: covers all three branches of the isDataExist helper (non-existent directory, empty directory, directory with content).
  • TestPrepareJoinClusterEmptyJoin: verifies the no-op path when Join is empty (new initial leader).
  • TestPrepareJoinClusterJoinSelf: verifies the 'join self is forbidden' guard.
  • TestPrepareJoinClusterWithExistingDataDir: verifies that when the member data directory already has content the function sets InitialCluster to "" and InitialClusterState to "existing" without dialling the join address.

Also add TestJoinWithAbnormalExistingMember to the existing integration test suite (tests/server/join/join_test.go). It exercises the error path where the member list contains an entry with an empty Name (a node that completed MemberAdd but never started) whose peer URLs differ from those of the new PD attempting to join.

Issue Number: ref #2288

What problem does this PR solve?

Issue Number: Close #xxx

What is changed and how does it work?

Check List

Tests

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

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Add server/join/join_test.go with white-box unit tests for the two
previously untested code paths:

- TestIsDataExist: covers all three branches of the isDataExist helper
  (non-existent directory, empty directory, directory with content).
- TestPrepareJoinClusterEmptyJoin: verifies the no-op path when Join is
  empty (new initial leader).
- TestPrepareJoinClusterJoinSelf: verifies the 'join self is forbidden'
  guard.
- TestPrepareJoinClusterWithExistingDataDir: verifies that when the
  member data directory already has content the function sets
  InitialCluster to "" and InitialClusterState to "existing" without
  dialling the join address.

Also add TestJoinWithAbnormalExistingMember to the existing integration
test suite (tests/server/join/join_test.go).  It exercises the error
path where the member list contains an entry with an empty Name (a node
that completed MemberAdd but never started) whose peer URLs differ from
those of the new PD attempting to join.

Issue Number: ref tikv#2288

Co-Authored-By: Oz <oz-agent@warp.dev>
Signed-off-by: Jiale Lin <ljluestc@users.noreply.github.com>
@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. labels Jul 5, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

[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 qiuyesuifeng 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

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f9658c0-ab88-4a1e-adb1-1d08fd646c2b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ti-chi-bot

ti-chi-bot Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Hi @ljluestc. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 5, 2026
@ljluestc ljluestc closed this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant