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

storage: migrate test framework to testify #5139

Merged
merged 2 commits into from Jun 10, 2022

Conversation

LLThomas
Copy link
Contributor

@LLThomas LLThomas commented Jun 9, 2022

Signed-off-by: LLThomas zs033@qq.com

What problem does this PR solve?

Issue Number: Ref #4813

What is changed and how does it work?

As the title says.

Check List

Tests

  • Unit test

Release note

None

Signed-off-by: LLThomas <zs033@qq.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 9, 2022

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

@LLThomas
Copy link
Contributor Author

LLThomas commented Jun 9, 2022

When I run test, TestLoadMinServiceSafePoint can't pass.
The error occurs in "re.Nil(ssp)".

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  re.NoError(err)
  re.Nil(ssp)

Then, I test the original code.

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  c.Assert(err, IsNil)
  c.Assert(ssp, IsNil)

"c.Assert(ssp, IsNil)" also has the same error.
Maybe it is a bug.

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #5139 (633e6a7) into master (f82e15e) will increase coverage by 0.10%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5139      +/-   ##
==========================================
+ Coverage   75.46%   75.56%   +0.10%     
==========================================
  Files         309      309              
  Lines       30515    30515              
==========================================
+ Hits        23028    23060      +32     
+ Misses       5474     5450      -24     
+ Partials     2013     2005       -8     
Flag Coverage Δ
unittests 75.56% <ø> (+0.10%) ⬆️

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

Impacted Files Coverage Δ
pkg/tempurl/tempurl.go 45.00% <0.00%> (-15.00%) ⬇️
server/storage/storage.go 64.86% <0.00%> (-5.41%) ⬇️
server/tso/tso.go 69.49% <0.00%> (-2.26%) ⬇️
server/storage/endpoint/meta.go 61.79% <0.00%> (-2.25%) ⬇️
server/region_syncer/client.go 84.32% <0.00%> (-1.50%) ⬇️
server/storage/hot_region_storage.go 78.14% <0.00%> (-1.10%) ⬇️
server/cluster/unsafe_recovery_controller.go 80.18% <0.00%> (-0.37%) ⬇️
server/tso/allocator_manager.go 64.55% <0.00%> (-0.34%) ⬇️
server/id/id.go 80.95% <0.00%> (ø)
server/cluster/coordinator.go 70.45% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f82e15e...633e6a7. Read the comment docs.

@@ -207,7 +198,7 @@ func (t *testHotRegionStorage) TestHotRegionDelete(c *C) {
num := 0
for next, err := iter.Next(); next != nil && err == nil; next, err = iter.Next() {
num++
c.Assert(reflect.DeepEqual(next, &historyHotRegions[defaultRemainDay-num]), IsTrue)
re.True(reflect.DeepEqual(next, &historyHotRegions[defaultRemainDay-num]))
Copy link
Member

Choose a reason for hiding this comment

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

Equal is enough.

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 think "re.True" is more suitable for functions that return bool value.
And I see an example that has been merged.

- c.Assert(rep.GetReplicationStatus().GetDrAutoSync().GetPauseRegionSplit(), IsTrue)
+ re.True(rep.GetReplicationStatus().GetDrAutoSync().GetPauseRegionSplit())

https://github.com/tikv/pd/pull/5100/files#diff-f36769a34db4e8e3412376a3a7c5be18b2f7f8ab90287fc48c7f4445bc716218L221

Copy link
Member

Choose a reason for hiding this comment

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

See #5104, require.Equal is used to replace reflect.DeepEqual.

Suggested change
re.True(reflect.DeepEqual(next, &historyHotRegions[defaultRemainDay-num]))
re.Equal(&historyHotRegions[defaultRemainDay-num], next)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I got it, I'll fix it.

@JmPotato
Copy link
Member

JmPotato commented Jun 9, 2022

When I run test, TestLoadMinServiceSafePoint can't pass. The error occurs in "re.Nil(ssp)".

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  re.NoError(err)
  re.Nil(ssp)

Then, I test the original code.

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  c.Assert(err, IsNil)
  c.Assert(ssp, IsNil)

"c.Assert(ssp, IsNil)" also has the same error. Maybe it is a bug.

This test relies on the failpoint injection, you can see it is enabled on line 107.

c.Assert(failpoint.Enable("github.com/tikv/pd/server/storage/endpoint/removeExpiredKeys", "return(true)"), IsNil)

To make the failpoint work, you should call make failpoint-enable before running the test.

Signed-off-by: LLThomas <zs033@qq.com>
@LLThomas
Copy link
Contributor Author

When I run test, TestLoadMinServiceSafePoint can't pass. The error occurs in "re.Nil(ssp)".

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  re.NoError(err)
  re.Nil(ssp)

Then, I test the original code.

  // verify that service safe point with ServiceID 0 has been removed
  ssp, err := storage.LoadServiceSafePoint(testKeySpace, "0")
  c.Assert(err, IsNil)
  c.Assert(ssp, IsNil)

"c.Assert(ssp, IsNil)" also has the same error. Maybe it is a bug.

This test relies on the failpoint injection, you can see it is enabled on line 107.

c.Assert(failpoint.Enable("github.com/tikv/pd/server/storage/endpoint/removeExpiredKeys", "return(true)"), IsNil)

To make the failpoint work, you should call make failpoint-enable before running the test.

Thanks! I got it.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 10, 2022
@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 Jun 10, 2022
@JmPotato
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

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

/run-all-tests

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
Member

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

Commit hash: 633e6a7

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 10, 2022
@ti-chi-bot ti-chi-bot merged commit ae157b5 into tikv:master Jun 10, 2022
@rleungx rleungx mentioned this pull request Jun 13, 2022
85 tasks
CabinfeverB pushed a commit to CabinfeverB/pd that referenced this pull request Jul 14, 2022
ref tikv#4813

As the title says.

Signed-off-by: LLThomas <zs033@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none 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.

None yet

4 participants