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(dm): migrate pingcap/check to testify for pkg/binlog #7586

Merged
merged 14 commits into from
Nov 17, 2022
Merged

tests(dm): migrate pingcap/check to testify for pkg/binlog #7586

merged 14 commits into from
Nov 17, 2022

Conversation

liumengya94
Copy link
Contributor

@liumengya94 liumengya94 commented Nov 11, 2022

What problem does this PR solve?

migrate pingcap/check to testify for pkg/binlog

Issue Number: ref #5687

What is changed and how it works?

Use testify in dm/pkg/binlog package

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No

Do you need to update user documentation, design documentation or monitoring documentation?

No

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 11, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • gozssky
  • lance6716

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 added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 11, 2022
@liumengya94
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added status/LGT1 Indicates that a PR has LGTM 1. and removed do-not-merge/needs-linked-issue labels Nov 14, 2022
dm/pkg/binlog/common/replication_test.go Outdated Show resolved Hide resolved
@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 Nov 15, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 15, 2022
var (
flavor = gmysql.MySQLFlavor
serverID uint32 = 101
gSetStr = "3ccc475b-2343-11e7-be21-6c0b84d59f30:1-14,406a3f61-690d-11e7-87c5-6c92bf46f384:1-94321383,53bfca22-690d-11e7-8a62-18ded7a37b78:1-495,686e1ab6-c47e-11e7-a42c-6c92bf46f384:1-34981190,03fc0263-28c7-11e7-a653-6c0b84d59f30:1-7041423,05474d3c-28c7-11e7-8352-203db246dd3d:1-170,10b039fc-c843-11e7-8f6a-1866daf8d810:1-308290454"
gSet gmysql.GTIDSet
)
gSet, err := gtid.ParserGTID(flavor, gSetStr)
c.Assert(err, IsNil)
require.Nil(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use require.NoError rather than require.Nil. No big problems, you can remember it in next PR

c.Assert(events[0].Header.EventType, Equals, replication.FORMAT_DESCRIPTION_EVENT)
c.Assert(events[1].Header.EventType, Equals, replication.PREVIOUS_GTIDS_EVENT)
require.Nil(t, err)
require.Equal(t, 2, len(events))
Copy link
Contributor

Choose a reason for hiding this comment

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

require.Len(t, events, 2)

@@ -107,96 +106,97 @@ func (t *testCommonSuite) TestGenCommonGTIDEvent(c *C) {

// nil gSet, invalid
gtidEv, err := GenCommonGTIDEvent(flavor, serverID, latestPos, gSet, false, 0)
c.Assert(err, NotNil)
c.Assert(gtidEv, IsNil)
require.NotNil(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

require.Error

@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: 24d6b6c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 15, 2022
@lance6716
Copy link
Contributor

/hold

lint error


[2022-11-15T05:56:58.851Z] pkg/binlog/position_test.go:24:6: type `testPositionSuite` is unused (unused)

[2022-11-15T05:56:58.851Z] type testPositionSuite struct{}

[2022-11-15T05:56:58.851Z]      ^

[2022-11-15T05:56:58.851Z] pkg/binlog/pos_finder_test.go:328: unnecessary trailing newline (whitespace)

[2022-11-15T05:56:58.851Z] 

[2022-11-15T05:56:58.851Z] 	}

[2022-11-15T05:56:58.851Z] pkg/binlog/event/event_test.go:56:6: test helper function should start from t.Helper() (thelper)

[2022-11-15T05:56:58.851Z] func verifyHeader(t *testing.T, obtained, excepted *replication.EventHeader, eventType replication.EventType, latestPos, eventSize uint32) {

[2022-11-15T05:56:58.851Z]      ^

[2022-11-15T05:56:58.851Z] pkg/binlog/event/generator_test.go:122:6: test helper function should start from t.Helper() (thelper)

[2022-11-15T05:56:58.851Z] func testGenerate(t *testing.T, flavor string, serverID uint32, latestGTID gmysql.GTIDSet, previousGTIDSet gmysql.GTIDSet, latestXID uint64) {

[2022-11-15T05:56:58.851Z]      ^

[2022-11-15T05:56:58.851Z] pkg/binlog/event/generator_test.go:305:6: test helper function should start from t.Helper() (thelper)

[2022-11-15T05:56:58.851Z] func previousGTIDEventType(t *testing.T, flavor string) replication.EventType {

[2022-11-15T05:56:58.851Z]      ^

[2022-11-15T05:56:58.851Z] make: *** [check-static] Error 1

unit test failed

[2022-11-15T06:00:04.824Z] === Failed

[2022-11-15T06:00:04.824Z] === FAIL: dm/pkg/binlog/reader TestSyncPos (0.00s)

[2022-11-15T06:00:04.824Z] [2022/11/15 13:54:40] [info] binlogsyncer.go:164 create BinlogSyncer with config {3251 mysql  0     false false <nil> false UTC false 0 0s 0s 0 false false 0 <nil> 0xc0000534a0 0x91cf40}

[2022-11-15T06:00:04.824Z] [2022/11/15 13:54:40] [info] binlogsyncer.go:164 create BinlogSyncer with config {3252 mysql  0     false false <nil> false UTC false 0 0s 0s 0 false false 0 <nil> 0xc0005a6000 0x91cf40}

[2022-11-15T06:00:04.824Z]     tcp_test.go:69: 

[2022-11-15T06:00:04.824Z]         	Error Trace:	/home/jenkins/agent/workspace/ut-check/tiflow/dm/pkg/binlog/reader/tcp_test.go:69

[2022-11-15T06:00:04.824Z]         	Error:      	Expected nil, but got: [code=30012:class=relay-unit:scope=upstream:level=high], Message: start sync from position (, 0), RawCause: dial tcp: missing address

[2022-11-15T06:00:04.824Z]         	Test:       	TestSyncPos

[2022-11-15T06:00:04.824Z] 

[2022-11-15T06:00:04.824Z] === FAIL: dm/pkg/binlog/reader TestSyncGTID (0.00s)

[2022-11-15T06:00:04.824Z]     tcp_test.go:124: 

[2022-11-15T06:00:04.824Z]         	Error Trace:	/home/jenkins/agent/workspace/ut-check/tiflow/dm/pkg/binlog/reader/tcp_test.go:124

[2022-11-15T06:00:04.824Z]         	Error:      	Expected nil, but got: [code=30014:class=relay-unit:scope=upstream:level=high], Message: start sync from GTID set , RawCause: dial tcp: missing address

[2022-11-15T06:00:04.824Z]         	Test:       	TestSyncGTID

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 15, 2022
@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Nov 15, 2022
c.Assert(failpoint.Enable("github.com/pingcap/tiflow/dm/pkg/binlog/reader/MockTCPReaderClose", "return(true)"), IsNil)
c.Assert(failpoint.Enable("github.com/pingcap/tiflow/dm/pkg/binlog/reader/MockTCPReaderGetEvent", "return(true)"), IsNil)
c.Assert(failpoint.Enable("github.com/pingcap/tiflow/dm/pkg/binlog/reader/MockTCPReaderStatus", "return(true)"), IsNil)
func (t *testTCPReaderSuite) SetUpSuite() {
Copy link
Contributor

Choose a reason for hiding this comment

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

@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: d3fa753

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 17, 2022
@lance6716
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 17, 2022
@lance6716
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

@liumengya94: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

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.

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.

@liumengya94
Copy link
Contributor Author

/run-engine-integration-test

@ti-chi-bot ti-chi-bot merged commit 770dab8 into pingcap:master Nov 17, 2022
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.

4 participants