Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: reduce redundant code about etcd server and logger #7007

Merged
merged 8 commits into from
Sep 4, 2023

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Aug 30, 2023

What problem does this PR solve?

Issue Number: Close #6890 #6936

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 30, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. labels Aug 30, 2023
@ti-chi-bot ti-chi-bot bot requested review from JmPotato and rleungx August 30, 2023 04:53
@ti-chi-bot ti-chi-bot bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 30, 2023
Signed-off-by: lhy1024 <[email protected]>
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 30, 2023
Signed-off-by: lhy1024 <[email protected]>
// Start the new etcd member.
etcd2, err := embed.StartEtcd(cfg2)
if err != nil {
re.Contains(err.Error(), "error validating peerURLs")
Copy link
Member

Choose a reason for hiding this comment

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

When will this error happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In #6890, it occurs with "member count is unequal"

Copy link
Member

Choose a reason for hiding this comment

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

Is the error expected?

Copy link
Contributor Author

@lhy1024 lhy1024 Aug 30, 2023

Choose a reason for hiding this comment

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

No, we have sent MemberAdd before starting a new etcd server, but it still returns error validating peerURLs with member count is unequal in #6890 case, which frequency is extremely low, only appearing once.

Signed-off-by: lhy1024 <[email protected]>
@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #7007 (3923233) into master (91648e5) will decrease coverage by 0.10%.
The diff coverage is 98.24%.

@@            Coverage Diff             @@
##           master    #7007      +/-   ##
==========================================
- Coverage   74.46%   74.37%   -0.10%     
==========================================
  Files         435      435              
  Lines       46218    46264      +46     
==========================================
- Hits        34418    34408      -10     
- Misses       8796     8838      +42     
- Partials     3004     3018      +14     
Flag Coverage Δ
unittests 74.37% <98.24%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Signed-off-by: lhy1024 <[email protected]>
}

// MustAddEtcdMember is used to add a new etcd member to the cluster.
func MustAddEtcdMember(t *testing.T, cfg1 *embed.Config, client *clientv3.Client) *embed.Etcd {
Copy link
Member

Choose a reason for hiding this comment

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

Why call it Mustxxx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any good ideas about the name of this test function?

Copy link
Member

Choose a reason for hiding this comment

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

Here is no guarantee that the member is added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will retry three times, and if it fails all three times, it will report an error re.NoError(err, "addEtcdMemberWithRetry failed after retry")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use another way to make the test stable, which is to wait member number to be normal before adding a new node.

Signed-off-by: lhy1024 <[email protected]>
@lhy1024
Copy link
Contributor Author

lhy1024 commented Sep 2, 2023

I tried to run ci 200 times with CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race github.com/tikv/pd/pkg/election github.com/tikv/pd/pkg/utils/etcdutil in lhy1024#9

And only met once failure in TestEtcdScaleInAndOut about #6892 and no other error about this pr.

@lhy1024 lhy1024 requested a review from rleungx September 4, 2023 02:25
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 4, 2023
@lhy1024
Copy link
Contributor Author

lhy1024 commented Sep 4, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 4, 2023

@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Sep 4, 2023

This pull request has been accepted and is ready to merge.

Commit hash: 3923233

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 4, 2023
@ti-chi-bot ti-chi-bot bot merged commit e1fd64e into tikv:master Sep 4, 2023
23 checks passed
rleungx pushed a commit to rleungx/pd that referenced this pull request Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable test TestRandomKillEtcd
3 participants