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

refactor ipam unit test #2126

Merged
merged 3 commits into from
Dec 8, 2022
Merged

refactor ipam unit test #2126

merged 3 commits into from
Dec 8, 2022

Conversation

changluyi
Copy link
Collaborator

  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

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

Which issue(s) this PR fixes:

Fixes #(issue-number)

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
Comment on lines 45 to 52
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))
})
Copy link
Member

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.

@changluyi changluyi added the test automation tests label Dec 6, 2022
@@ -2,11 +2,14 @@ package ipam

import (
"fmt"
"math/rand"
Copy link
Member

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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

typo: separate

Comment on lines 540 to 541
iprlist := ipam.IPRangeList{&ipr}
Expect(iprlist.Contains(ip1)).To(BeTrue())
Copy link
Member

Choose a reason for hiding this comment

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

iprlist => iprList

@changluyi changluyi merged commit 51907e0 into master Dec 8, 2022
@changluyi changluyi deleted the ipam_unittest branch December 8, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test automation tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants