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

scripts: add the inefficient assert function usage check #5110

Merged
merged 5 commits into from
Jun 7, 2022

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Jun 6, 2022

Signed-off-by: JmPotato ghzpotato@gmail.com

What problem does this PR solve?

Issue Number: Close #5104. Should be merged after #5109.

What is changed and how does it work?

Add the inefficient assert function usage check.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
./scripts/check-test.sh
following packages use inefficient assert function: please replace reflect.DeepEqual with require.Equal
./client/client_test.go:61:	re.True(reflect.DeepEqual(getURLs([]*pdpb.Member{members[1], members[3], members[2]}), cli.GetURLs()))
./client/client_test.go:63:	re.True(reflect.DeepEqual(getURLs([]*pdpb.Member{members[1], members[3], members[2]}), cli.GetURLs()))
./client/client_test.go:65:	re.True(reflect.DeepEqual(getURLs([]*pdpb.Member{members[1], members[3], members[2], members[0]}), cli.GetURLs()))
./pkg/autoscaling/calculation_test.go:200:			re.True(reflect.DeepEqual(testCase.expectedPlan, plans))
./pkg/cache/cache_test.go:109:	re.True(reflect.DeepEqual(sortIDs(cache.GetAllID()), []uint64{3}))
./pkg/cache/cache_test.go:128:	re.True(reflect.DeepEqual(val, "3"))
./pkg/cache/cache_test.go:132:	re.True(reflect.DeepEqual(val, "2"))
./pkg/cache/cache_test.go:136:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:150:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:154:	re.True(reflect.DeepEqual(val, "2"))
./pkg/cache/cache_test.go:158:	re.True(reflect.DeepEqual(val, "4"))
./pkg/cache/cache_test.go:164:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:168:	re.True(reflect.DeepEqual(elems[0].Value, "4"))
./pkg/cache/cache_test.go:169:	re.True(reflect.DeepEqual(elems[1].Value, "2"))
./pkg/cache/cache_test.go:170:	re.True(reflect.DeepEqual(elems[2].Value, "1"))
./pkg/cache/cache_test.go:208:	re.True(reflect.DeepEqual(elems[0].Value, "2"))
./pkg/cache/cache_test.go:209:	re.True(reflect.DeepEqual(elems[1].Value, "3"))
./pkg/cache/cache_test.go:210:	re.True(reflect.DeepEqual(elems[2].Value, "4"))
./pkg/cache/cache_test.go:214:	re.True(reflect.DeepEqual(elems[0].Value, "4"))
./pkg/cache/cache_test.go:231:	re.True(reflect.DeepEqual(val, "3"))
./pkg/cache/cache_test.go:235:	re.True(reflect.DeepEqual(val, "2"))
./pkg/cache/cache_test.go:239:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:253:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:257:	re.True(reflect.DeepEqual(val, "2"))
./pkg/cache/cache_test.go:261:	re.True(reflect.DeepEqual(val, "4"))
./pkg/cache/cache_test.go:267:	re.True(reflect.DeepEqual(val, "1"))
./pkg/cache/cache_test.go:271:	re.True(reflect.DeepEqual(elems[0].Value, "4"))
./pkg/cache/cache_test.go:272:	re.True(reflect.DeepEqual(elems[1].Value, "2"))
./pkg/cache/cache_test.go:273:	re.True(reflect.DeepEqual(elems[2].Value, "1"))
./pkg/cache/cache_test.go:79:	re.True(reflect.DeepEqual(sortIDs(cache.GetAllID()), []uint64{1, 2, 3}))
./pkg/cache/cache_test.go:96:	re.True(reflect.DeepEqual(sortIDs(cache.GetAllID()), []uint64{2, 3}))
./pkg/logutil/log_test.go:76:			re.True(reflect.DeepEqual(testCase.expect, RedactBytes(r)))
./pkg/logutil/log_test.go:78:			re.True(reflect.DeepEqual(testCase.expect, RedactString(r)))
./pkg/logutil/log_test.go:80:			re.True(reflect.DeepEqual(testCase.expect, RedactStringer(r)))
./pkg/typeutil/conversion_test.go:38:	re.True(reflect.DeepEqual([]byte(str), b))
./pkg/typeutil/string_slice_test.go:35:	re.True(reflect.DeepEqual(b, nb))
./pkg/typeutil/string_slice_test.go:47:	re.True(reflect.DeepEqual(ss, ss2))
./tests/client/client_test.go:1039:	suite.True(reflect.DeepEqual(store, n))
./tests/client/client_test.go:1056:	suite.True(reflect.DeepEqual(offlineStore, n))
./tests/client/client_test.go:1065:			suite.True(reflect.DeepEqual(offlineStore, store))
./tests/client/client_test.go:116:	re.True(reflect.DeepEqual(endpoints, urls))
./tests/client/client_test.go:267:			re.True(reflect.DeepEqual(endpoints, urls))
./tests/client/client_test.go:977:			suite.True(reflect.DeepEqual(expect[i], scanRegions[i].Meta))
./tests/client/client_test.go:980:				suite.True(reflect.DeepEqual(&metapb.Peer{}, scanRegions[i].Leader))
./tests/client/client_test.go:982:				suite.True(reflect.DeepEqual(expect[i].Peers[0], scanRegions[i].Leader))
./tests/client/client_test.go:986:				suite.True(reflect.DeepEqual([]*metapb.Peer{expect[i].Peers[1]}, scanRegions[i].DownPeers))
./tests/client/client_test.go:990:				suite.True(reflect.DeepEqual([]*metapb.Peer{expect[i].Peers[1], expect[i].Peers[2]}, scanRegions[i].PendingPeers))
make: *** [check-test] Error 1

Release note

None.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
@JmPotato JmPotato added the component/testing CI testing. label Jun 6, 2022
@JmPotato JmPotato requested review from disksing and rleungx June 6, 2022 10:22
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jun 6, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • 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 added the release-note-none Denotes a PR that doesn't merit a release note. label Jun 6, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 6, 2022
@codecov
Copy link

codecov bot commented Jun 6, 2022

Codecov Report

Merging #5110 (1c91a50) into master (e19dc71) will increase coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5110      +/-   ##
==========================================
+ Coverage   75.42%   75.46%   +0.03%     
==========================================
  Files         308      308              
  Lines       30484    30484              
==========================================
+ Hits        22993    23005      +12     
+ Misses       5484     5481       -3     
+ Partials     2007     1998       -9     
Flag Coverage Δ
unittests 75.46% <ø> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
server/schedulers/shuffle_hot_region.go 55.55% <0.00%> (-10.11%) ⬇️
server/storage/kv/etcd_kv.go 79.71% <0.00%> (-5.80%) ⬇️
server/election/lease.go 84.05% <0.00%> (-1.45%) ⬇️
tools/pd-ctl/pdctl/command/operator.go 66.66% <0.00%> (-1.15%) ⬇️
server/cluster/unsafe_recovery_controller.go 79.81% <0.00%> (-1.09%) ⬇️
server/schedulers/evict_leader.go 78.82% <0.00%> (-0.91%) ⬇️
server/cluster/cluster.go 83.50% <0.00%> (-0.56%) ⬇️
server/handler.go 52.58% <0.00%> (-0.39%) ⬇️
pkg/btree/btree.go 87.22% <0.00%> (-0.25%) ⬇️
client/client.go 68.72% <0.00%> (-0.11%) ⬇️
... and 10 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 e19dc71...1c91a50. Read the comment docs.

@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 7, 2022
@JmPotato
Copy link
Member Author

JmPotato commented Jun 7, 2022

/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 ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 7, 2022
@JmPotato
Copy link
Member Author

JmPotato commented Jun 7, 2022

/merge cancel

@ti-chi-bot ti-chi-bot removed the status/can-merge Indicates a PR has been approved by a committer. label Jun 7, 2022
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@JmPotato
Copy link
Member Author

JmPotato commented Jun 7, 2022

/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: ac4389e

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 7, 2022
@ti-chi-bot ti-chi-bot merged commit 1f3c305 into tikv:master Jun 7, 2022
@JmPotato JmPotato deleted the testify_check branch June 7, 2022 02:56
CabinfeverB pushed a commit to CabinfeverB/pd that referenced this pull request Jul 14, 2022
close tikv#5104

Add the inefficient assert function usage check.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/testing CI testing. release-note-none Denotes a PR that doesn't merit a release note. 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.

Use require.Equal to replace reflect.DeepEqual
4 participants