-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Fix incorrect test cases to cover code that needs to be tested in TestValidateIPSet
#108351
Conversation
@mengjiao-liu: This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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 kubernetes/test-infra repository. |
great catch |
ping @thockin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests pass today (these cases fail successfully).
Can you explain why this change is "more correclty incorrect" ?
Would it be too much to ask to expand the comments from // case[3]
to something meaningful?
I see it's not actually validating the error message. Blech. This could/should be refactored to return /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, mengjiao-liu, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Wrong test cases:
kubernetes/pkg/util/ipset/ipset_test.go
Lines 927 to 948 in 5bafc83
According to the testcases desc field, we can see that case[3] is the test
wrong hash size number
case[4] is to test
wrong hash max elem number
However, when building the test case, the value set by the
IPSet.SetType
fields isBitmapPort
,kubernetes/pkg/util/ipset/ipset_test.go
Line 930 in 5bafc83
kubernetes/pkg/util/ipset/ipset_test.go
Line 941 in 5bafc83
which does not conform to the description of the
desc
field.And this will cause the test to jump directly to verifying the
PortRange
ofBitmapPort
. At this time,PortRange == ""
, so it will definitely returnfalse
,kubernetes/pkg/util/ipset/ipset.go
Lines 107 to 109 in 5bafc83
and the verified HashSize and MaxElem part code that needs to be tested is not tested.
kubernetes/pkg/util/ipset/ipset.go
Lines 112 to 121 in 5bafc83
When we modified the code, the test coverage increased from
85.0%
to87.2%
and the code that verified the HashSize and MaxElem part code that was not covered previously was covered.Run command:
Befor:
After:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig testing