-
Notifications
You must be signed in to change notification settings - Fork 450
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
refactor ipam unit test #2126
refactor ipam unit test #2126
Conversation
1) check all ipam and subnet module's export api 2) add pod with multi nic case 3) refactor comment in api By() 4) check more items in struct ipam 5) add case update err subnet cidr
test/unittest/ipam/ipam.go
Outdated
By("invalid mask len > 32") | ||
err := im.AddOrUpdateSubnet(subnetName, "1.1.1.1/64", v4Gw, nil) | ||
Expect(err).Should(MatchError(ipam.ErrInvalidCIDR)) | ||
|
||
By("invalid ip range") | ||
err = im.AddOrUpdateSubnet(subnetName, "1.1.256.1/24", v4Gw, nil) | ||
Expect(err).Should(MatchError(ipam.ErrInvalidCIDR)) | ||
}) |
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.
Edge cases, such as prefix = 30/31/32/33/34, are needed.
@@ -2,11 +2,14 @@ package ipam | |||
|
|||
import ( | |||
"fmt" | |||
"math/rand" |
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.
The random source should be initialized.
test/unittest/ipam/ipam.go
Outdated
@@ -33,52 +36,103 @@ var _ = Describe("[IPAM]", func() { | |||
dualCIDR := fmt.Sprintf("%s,%s", ipv4CIDR, ipv6CIDR) | |||
dualExcludeIPs := append(ipv4ExcludeIPs, ipv6ExcludeIPs...) | |||
|
|||
// TODO test case use random ip and ipcidr, and input test data should seperate from test case |
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.
typo: separate
test/unittest/ipam/ipam.go
Outdated
iprlist := ipam.IPRangeList{&ipr} | ||
Expect(iprlist.Contains(ip1)).To(BeTrue()) |
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.
iprlist
=> iprList
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes:
Fixes #(issue-number)