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

reparo/syncer: add unit test #540

Merged
merged 37 commits into from
Apr 29, 2019
Merged

reparo/syncer: add unit test #540

merged 37 commits into from
Apr 29, 2019

Conversation

WangXiangUSTC
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC commented Apr 16, 2019

What problem does this PR solve?

add unit test for reparo/syncer
https://internal.pingcap.net/jira/browse/TOOL-1057

What is changed and how it works?

  1. after this pr, reparo/syncer unit test coverage will changed from 4% to 79%
  2. find a bug, the old integration test don't find it, fix the bug and update a integration test case

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to cherry-pick to the release branch

@sre-bot
Copy link

sre-bot commented Apr 16, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests

@WangXiangUSTC
Copy link
Contributor Author

/run-unit-test

reparo/syncer/print.go Outdated Show resolved Hide resolved
reparo/syncer/print.go Outdated Show resolved Hide resolved
reparo/syncer/translate_test.go Outdated Show resolved Hide resolved
reparo/syncer/mysql.go Outdated Show resolved Hide resolved
reparo/syncer/mysql_test.go Show resolved Hide resolved
reparo/syncer/util_test.go Show resolved Hide resolved
@WangXiangUSTC
Copy link
Contributor Author

@suzaku @july2993 PTAL again

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

rest LGTM

reparo/syncer/mysql_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

LGTM

@july2993
Copy link
Contributor

can you separate the bug fix into another pr?

reparo/syncer/mysql_test.go Outdated Show resolved Hide resolved

var _ = check.Suite(&testPrintSuite{})

func (s *testPrintSuite) TestPrintSyncer(c *check.C) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that these test cases are almost identical, can we create a test function that can validate all of these syncers?

Copy link
Collaborator

Choose a reason for hiding this comment

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

only validation functions are different

Copy link
Collaborator

Choose a reason for hiding this comment

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

and this case is lack of output validation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

define a new function to do these things 201a7cb

reparo/syncer/syncer_test.go Outdated Show resolved Hide resolved
@IANTHEREAL
Copy link
Collaborator

where is the bug? 🤔

if err != nil {
return nil, errors.Trace(err)
}
_, oldDatum, err := codec.DecodeOne(col.ChangedValue)
_, newDatum, err := codec.DecodeOne(col.ChangedValue)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the bug? ***

dmlBinlog := &pb.Binlog{
Tp: pb.BinlogType_DML,
DmlData: &pb.DMLData{
Events: generateDMLEvents(c)[0:1],
Copy link
Collaborator

Choose a reason for hiding this comment

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

test two case Events: generateDMLEvents(c)[0:2],?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 0bd0c15

@IANTHEREAL
Copy link
Collaborator

Rest LGTM

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests

@IANTHEREAL
Copy link
Collaborator

LGTM

@WangXiangUSTC
Copy link
Contributor Author

/run-all-tests

@suzaku
Copy link
Contributor

suzaku commented Apr 29, 2019

LGTM

Copy link
Contributor

@suzaku suzaku left a comment

Choose a reason for hiding this comment

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

LGTM

@WangXiangUSTC WangXiangUSTC merged commit 3e68c99 into master Apr 29, 2019
@WangXiangUSTC WangXiangUSTC deleted the xiang/reparo_syncer_test branch April 29, 2019 05:42
WangXiangUSTC added a commit that referenced this pull request Jul 2, 2019
july2993 pushed a commit that referenced this pull request Jul 3, 2019
* reparo/syncer: add unit test (#540)
* update log and add safe mode config (#652)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants