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

tests: fix mock server sends event before kv client is ready #1686

Merged

Conversation

amyangfei
Copy link
Contributor

What problem does this PR solve?

Fix unstable unit test

[2021-04-21T06:27:22.638Z] [2021/04/21 14:26:58.418 +08:00] [ERROR] [client_v2.go:81] ["received an event but neither pending region nor running region was found"] [regionID=3] [requestID=61] [addr=127.0.0.1:15936] [stack="github.com/pingcap/ticdc/cdc/kv.(*eventFeedSession).sendRegionChangeEventV2\n\t/home/jenkins/agent/workspace/cdc_ghpr_leak_test/go/src/github.com/pingcap/ticdc/cdc/kv/client_v2.go:81\ngithub.jparrowsec.cn/pingcap/ticdc/cdc/kv.(*eventFeedSession).receiveFromStreamV2\n\t/home/jenkins/agent/workspace/cdc_ghpr_leak_test/go/src/github.com/pingcap/ticdc/cdc/kv/client_v2.go:274\ngithub.jparrowsec.cn/pingcap/ticdc/cdc/kv.(*eventFeedSession).dispatchRequest.func1\n\t/home/jenkins/agent/workspace/cdc_ghpr_leak_test/go/src/github.com/pingcap/ticdc/cdc/kv/client.go:815\ngolang.org/x/sync/errgroup.(*Group).Go.func1\n\t/go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:57"]
[2021-04-21T06:27:22.638Z] 
[2021-04-21T06:27:22.638Z] ----------------------------------------------------------------------
[2021-04-21T06:27:22.638Z] FAIL: client_test.go:1306: etcdSuite.TestStreamRecvWithErrorAndResolvedGoBack
[2021-04-21T06:27:22.639Z] 
[2021-04-21T06:27:22.639Z] client_test.go:1347:
[2021-04-21T06:27:22.639Z] client_test.go:239:
[2021-04-21T06:27:22.639Z]     s.c.Assert(err, check.IsNil)
[2021-04-21T06:27:22.639Z] ... value *status.statusError = &status.statusError{Code:1, Message:"context canceled", Details:[]*any.Any(nil), XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0} ("rpc error: code = Canceled desc = context canceled")
[2021-04-21T06:27:22.639Z] 
[2021-04-21T06:27:22.639Z]     c.Assert(errors.Cause(err), check.Equals, context.Canceled)
[2021-04-21T06:27:22.639Z] ... obtained *errors.Error = &errors.Error{code:0, codeText:"CDC:ErrNoPendingRegion", message:"received event regionID %v, requestID %v from %v, but neither pending region nor running region was found", redactArgsPos:[]int(nil), cause:error(nil), args:[]interface {}{0x3, 0x3d, "127.0.0.1:15936"}, file:"/home/jenkins/agent/workspace/cdc_ghpr_leak_test/go/src/github.com/pingcap/ticdc/cdc/kv/client_v2.go", line:85} ("[CDC:ErrNoPendingRegion]received event regionID 3, requestID 61 from 127.0.0.1:15936, but neither pending region nor running region was found")
[2021-04-21T06:27:22.639Z] ... expected *errors.errorString = &errors.errorString{s:"context canceled"} ("context canceled")

What is changed and how it works?

The root cause is new request ID is allocated in kv client first, and then pending region is inserted, when the test code detects request ID is ready, the pending region could be not ready.
This is a fix for the test

Check List

Tests

  • Unit test
  • Integration test

Release note

  • No release note

@amyangfei amyangfei added component/test Unit tests and integration tests component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. labels Apr 22, 2021
@amyangfei amyangfei added this to the v5.0.2 milestone Apr 22, 2021
@amyangfei
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot requested review from 5kbpers and zier-one April 22, 2021 07:01
@ti-chi-bot ti-chi-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 22, 2021
@amyangfei amyangfei added the status/ptal Could you please take a look? label Apr 22, 2021
@amyangfei
Copy link
Contributor Author

ptal @liuzix @jinlingchristopher

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 26, 2021
@zier-one
Copy link
Contributor

we should try to simplify testing of kvclient, but LGTM

/lgtm

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lance6716
  • leoppro

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 26, 2021
@zier-one
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: ec3d19b

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 26, 2021
@ti-chi-bot ti-chi-bot merged commit 4be4c1e into pingcap:master Apr 26, 2021
ti-srebot pushed a commit to ti-srebot/ticdc that referenced this pull request Apr 26, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #1690

ti-srebot pushed a commit to ti-srebot/ticdc that referenced this pull request Apr 26, 2021
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #1691

@amyangfei amyangfei deleted the fix-kv-client-unstable-unit-test branch April 26, 2021 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/test Unit tests and integration tests component. needs-cherry-pick-release-4.0 Should cherry pick this PR to release-4.0 branch. needs-cherry-pick-release-5.0 Should cherry pick this PR to release-5.0 branch. size/S Denotes a PR that changes 10-29 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. status/ptal Could you please take a look?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants