Skip to content

Commit

Permalink
Merge pull request #981 from spidernet-io/bz/open/case-R00008
Browse files Browse the repository at this point in the history
open the test case R00008
  • Loading branch information
weizhoublue authored Nov 21, 2023
2 parents 3f63a39 + de64af7 commit 8149aad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
13 changes: 0 additions & 13 deletions pkg/controller/webhook/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,6 @@ func checkEGWIppools(client client.Client, cfg *config.Config, ctx context.Conte
return fmt.Errorf("referenced egw(%v) spec.Ippools.IPv6 cannot be empty", egw.Name)
}

if allocatorPolicy == egressv1.EipAllocatorRR {
ipv4, ipv6, err := countGatewayAvailableIP(egw)
if err != nil {
return fmt.Errorf("parse egress gateway ippool with error: %s", err)
}
if cfg.FileConfig.EnableIPv4 && ipv4 < 1 {
return fmt.Errorf("the current allocation method is round-robin (rr), and there are no unused egress IPv4")
}
if cfg.FileConfig.EnableIPv6 && ipv6 < 1 {
return fmt.Errorf("the current allocation method is round-robin (rr), and there are no unused egress IPv6")
}
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/egressgateway/egress_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ func (r egnReconciler) allocatorEIP(selEipLolicy string, nodeName string, pi pol
freeIpv6s := ip.IPsDiffSet(ipv6s, useIpv6s, false)

if len(freeIpv6s) == 0 {
return "", "", fmt.Errorf("No Egress IPV4 is available; policy=%v egw=%v", pi.policy, egw.Name)
return "", "", fmt.Errorf("No Egress IPV6 is available; policy=%v egw=%v", pi.policy, egw.Name)

// save it for later policy
// var useIpv6sByNode []net.IP
Expand Down
14 changes: 6 additions & 8 deletions test/e2e/reliability/reliability_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ var _ = Describe("IP Allocation", Label("Reliability_IP"), func() {
Expect(common.DeleteObj(ctx, cli, pod)).NotTo(HaveOccurred())
}
// delete policy if exists
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, egps, time.Second*10)).NotTo(HaveOccurred())
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, newEgps, time.Second*10)).NotTo(HaveOccurred())
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, egps, time.Minute)).NotTo(HaveOccurred())
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, newEgps, time.Minute)).NotTo(HaveOccurred())
// delete egressGateway
Expect(common.DeleteObj(ctx, cli, egw)).NotTo(HaveOccurred())
})
})

// todo @bzsuni wait the bug fixed
// case R00008 steps:
// (1) In the beforeEach block, we create a gateway and set up a pool with 100 IPs.
// (2) Create 120 policies.
Expand All @@ -69,10 +68,10 @@ var _ = Describe("IP Allocation", Label("Reliability_IP"), func() {
// (9) Delete all policies (start timing).
// (10) Verify that the gateway status has synchronized successfully, and all IPs have been released (after deletion is complete, calculate the time spent).
// (11) Check pod egress IPs again; they should no longer match the previous EIPs.
PIt("test IP allocation", Label("R00008", "P00009"), Serial, func() {
It("test IP allocation", Label("R00008", "P00009"), Serial, func() {
// create egresspolicies
By("create egressPolicies by gaven pods")
egps, _, err = common.CreateEgressPoliciesForPods(ctx, cli, egw, pods, egressConfig.EnableIPv4, egressConfig.EnableIPv6, time.Second*5)
egps, _, err = common.CreateEgressPoliciesForPods(ctx, cli, egw, pods, egressConfig.EnableIPv4, egressConfig.EnableIPv6, time.Second*10)
Expect(err).NotTo(HaveOccurred())

By("create extra egressPolicies")
Expand All @@ -87,7 +86,6 @@ var _ = Describe("IP Allocation", Label("Reliability_IP"), func() {

// delete egresspolicies
By("delete all egressPolicies")
// todo @bzsuni we do not wait all policies delete here
Expect(common.DeleteEgressPolicies(ctx, cli, egps)).NotTo(HaveOccurred())

creationStart := time.Now()
Expand All @@ -107,7 +105,7 @@ var _ = Describe("IP Allocation", Label("Reliability_IP"), func() {

// check egressgateway status synced with egresspolicy
By("check egressgateway status synced with egresspolicies")
err := common.WaitEGWSyncedWithEGP(cli, egw, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int(IPNum), time.Second*10)
err := common.WaitEGWSyncedWithEGP(cli, egw, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int(IPNum), time.Minute)
Expect(err).NotTo(HaveOccurred())
creationTime := time.Since(creationStart)

Expand All @@ -124,7 +122,7 @@ var _ = Describe("IP Allocation", Label("Reliability_IP"), func() {
deletionStart := time.Now()
// delete all policies
By("delete all egressPolicies")
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, newEgps, time.Second*10)).NotTo(HaveOccurred())
Expect(common.WaitEgressPoliciesDeleted(ctx, cli, newEgps, time.Minute)).NotTo(HaveOccurred())

// check eip after policies deleted
By("check egressgateway status should be empty")
Expand Down

0 comments on commit 8149aad

Please sign in to comment.