Skip to content

Commit

Permalink
Merge pull request #1156 from spidernet-io/bz/e2e/fix/duplic-gatewayip
Browse files Browse the repository at this point in the history
fix duplicate gateway ip in some test case
  • Loading branch information
bzsuni authored Jan 29, 2024
2 parents 23aeca6 + 25a0030 commit eb55156
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions test/e2e/egressendpointslice/egressendpointslice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var _ = Describe("Egressendpointslice", func() {
4. Verify the status of EndpointSlices and the egress IP of Pods.
5. When deleting all Pods, EndpointSlices should be deleted as well.
*/
Context("After performing several rounds of creating and deleting pods, check the status of the egress endpointSlice and the exported IP of the pod", Label("S00001"), func() {
Context("After performing several rounds of creating and deleting pods, check the status of the egress endpointSlice and the exported IP of the pod", Serial, Label("S00001"), func() {
// deploy
var (
deploy *appsv1.Deployment
Expand Down Expand Up @@ -59,7 +59,7 @@ var _ = Describe("Egressendpointslice", func() {

nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: nodeLabel}}

egw, err = common.CreateGatewayNew(ctx, cli, "egw-"+uuid.NewString(), pool, nodeSelector)
egw, err = common.CreateGatewayNew(ctx, cli, egwName, pool, nodeSelector)
Expect(err).NotTo(HaveOccurred(), "failed to create egressGateway %s\n", egwName)

DeferCleanup(func() {
Expand All @@ -84,7 +84,7 @@ var _ = Describe("Egressendpointslice", func() {
// delete the egressGateway if its exists
if egw != nil {
GinkgoWriter.Printf("delete the gatgeway %s if its exists\n", egw.Name)
Expect(common.DeleteObj(ctx, cli, egw)).NotTo(HaveOccurred())
Expect(common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)).NotTo(HaveOccurred())
}
})
})
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/egressgateway/egressgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ var _ = Describe("Operate EgressGateway", Label("EgressGateway"), Ordered, func(
DeferCleanup(func() {
// delete EgressGateway
if egw != nil {
err := common.DeleteObj(ctx, cli, egw)
err := common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)
Expect(err).NotTo(HaveOccurred())
}
})
Expand Down Expand Up @@ -544,7 +544,7 @@ var _ = Describe("Operate EgressGateway", Label("EgressGateway"), Ordered, func(
// delete egw
time.Sleep(time.Second)
GinkgoWriter.Printf("Delete egw: %s\n", egw.Name)
Expect(common.DeleteObj(ctx, cli, egw)).NotTo(HaveOccurred())
Expect(common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)).NotTo(HaveOccurred())
})
})

Expand Down Expand Up @@ -687,7 +687,7 @@ var _ = Describe("Operate EgressGateway", Label("EgressGateway"), Ordered, func(
// delete the egw if it exists
if egw != nil {
GinkgoWriter.Printf("Delete egw: %s\n", egw.Name)
Expect(common.DeleteObj(ctx, cli, egw)).NotTo(HaveOccurred())
Expect(common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)).NotTo(HaveOccurred())
}
})
})
Expand Down Expand Up @@ -727,7 +727,7 @@ var _ = Describe("Operate EgressGateway", Label("EgressGateway"), Ordered, func(
func createEgressGateway(ctx context.Context) (egw *egressv1.EgressGateway) {
// create gateway
GinkgoWriter.Println("Create EgressGateway")
pool, err := common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, 3, 1)
pool, err := common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, 3, 2)
Expect(err).NotTo(HaveOccurred())
nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: node1.Labels}}
egw, err = common.CreateGatewayNew(ctx, cli, "egw-"+uuid.NewString(), pool, nodeSelector)
Expand Down
19 changes: 12 additions & 7 deletions test/e2e/egresspolicy/egresspolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var _ = Describe("EgressPolicy", Serial, func() {
ipNum = 3

// create EgressGateway
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 1)
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 3)
Expect(err).NotTo(HaveOccurred())
nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: nodeLabel}}

Expand All @@ -50,7 +50,7 @@ var _ = Describe("EgressPolicy", Serial, func() {
DeferCleanup(func() {
// delete EgressGateway
if egw != nil {
err = common.DeleteObj(ctx, cli, egw)
err = common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)
Expect(err).NotTo(HaveOccurred())
}
})
Expand Down Expand Up @@ -359,6 +359,11 @@ var _ = Describe("EgressPolicy", Serial, func() {
err = common.WaitEgressPoliciesDeleted(ctx, cli, []*egressv1.EgressPolicy{egp}, time.Second*5)
Expect(err).NotTo(HaveOccurred())
}
// delete the cluster policy if it is existed
if egcp != nil {
err = common.WaitEgressClusterPoliciesDeleted(ctx, cli, []*egressv1.EgressClusterPolicy{egcp}, time.Second*5)
Expect(err).NotTo(HaveOccurred())
}
})

DescribeTable("namespaced policy", func(expectErr bool, setUp func(egp *egressv1.EgressPolicy)) {
Expand Down Expand Up @@ -940,7 +945,7 @@ var _ = Describe("EgressPolicy", Serial, func() {
The policy and clusterPolicy should be created successfully, and the spec.egressGatewayName should be set to the cluster's default gateway. Verify that the status is correct.
Create a namespace-level default gateway. Create a policy in this namespace without specifying the gatewayName. It is expected to use the default gateway of this namespace, and verify that the status is correct.
*/
Context("Test cluster-level default-egressgateway and namesapce-level default-egressgateway", func() {
Context("Test cluster-level default-egressgateway and namesapce-level default-egressgateway", Serial, func() {
var ctx context.Context
var err error
// gateway
Expand Down Expand Up @@ -969,7 +974,7 @@ var _ = Describe("EgressPolicy", Serial, func() {

// create cluster-level egressgateway
ipNum = 3
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 1)
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 4)
Expect(err).NotTo(HaveOccurred())
nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: nodeLabel}}

Expand Down Expand Up @@ -1000,10 +1005,10 @@ var _ = Describe("EgressPolicy", Serial, func() {

// delete gateway if it exists
if defaultClusterEgw != nil {
Expect(common.DeleteObj(ctx, cli, defaultClusterEgw)).NotTo(HaveOccurred())
Expect(common.DeleteEgressGateway(ctx, cli, defaultClusterEgw, time.Minute/2)).NotTo(HaveOccurred())
}
if defaultNamespaceEgw != nil {
Expect(common.DeleteObj(ctx, cli, defaultNamespaceEgw)).NotTo(HaveOccurred())
Expect(common.DeleteEgressGateway(ctx, cli, defaultNamespaceEgw, time.Minute/2)).NotTo(HaveOccurred())
}
})
})
Expand Down Expand Up @@ -1074,7 +1079,7 @@ var _ = Describe("EgressPolicy", Serial, func() {
createNamespaceLevelPolicyAndCheck(ctx, defaultClusterEgw, pool, ipNum, podLabels, testNS)

// create namespace-default-gateway
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 1)
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 5)
Expect(err).NotTo(HaveOccurred())
nodeSelector := egressv1.NodeSelector{Selector: &metav1.LabelSelector{MatchLabels: nodeLabel}}

Expand Down
6 changes: 3 additions & 3 deletions test/e2e/reliability/reliability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("Reliability", Serial, Label("Reliability"), func() {
}).WithTimeout(time.Second * 6).WithPolling(time.Second * 2).Should(Succeed())

ipNum = 3
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 2)
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 6)
Expect(err).NotTo(HaveOccurred())

egw, err = common.CreateGatewayNew(ctx, cli, "egw-"+uuid.NewString(), pool, selector)
Expand Down Expand Up @@ -92,7 +92,7 @@ var _ = Describe("Reliability", Serial, Label("Reliability"), func() {
Expect(err).NotTo(HaveOccurred())

GinkgoWriter.Println("delete gateway")
err = common.DeleteObj(ctx, cli, egw)
err = common.DeleteEgressGateway(ctx, cli, egw, time.Minute/2)
Expect(err).NotTo(HaveOccurred())

// start up all nodes if some nodes not ready
Expand Down Expand Up @@ -346,7 +346,7 @@ var _ = Describe("Reliability", Serial, Label("Reliability"), func() {
GinkgoWriter.Printf("succeeded to create the deploy %s\n", deploy.Name)

// create EgressGateway
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 1)
pool, err = common.GenIPPools(ctx, cli, egressConfig.EnableIPv4, egressConfig.EnableIPv6, int64(ipNum), 7)
Expect(err).NotTo(HaveOccurred())
nodeSelector := egressv1.NodeSelector{Selector: &v1.LabelSelector{MatchLabels: nodeLabel}}

Expand Down

0 comments on commit eb55156

Please sign in to comment.