diff --git a/test/e2e/common/egressgateway.go b/test/e2e/common/egressgateway.go index cb71087a4..089c8138c 100644 --- a/test/e2e/common/egressgateway.go +++ b/test/e2e/common/egressgateway.go @@ -48,8 +48,33 @@ func DeleteEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGa return f.DeleteResource(gateway, opts...) } -func UpdateEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGateway, opts ...client.UpdateOption) error { - return f.UpdateResource(gateway, opts...) +func UpdateEgressGateway(f *framework.Framework, gateway *egressv1beta1.EgressGateway, timeout time.Duration, opts ...client.UpdateOption) error { + ctx, cancel := context.WithTimeout(context.TODO(), timeout) + defer cancel() + + eg := new(egressv1beta1.EgressGateway) + for { + select { + case <-ctx.Done(): + return ERR_TIMEOUT + default: + e := GetEgressGateway(f, gateway.Name, eg) + if e != nil { + return e + } + gateway.ResourceVersion = eg.ResourceVersion + e = f.UpdateResource(gateway, opts...) + if e == nil { + GinkgoWriter.Printf("the latest resourceVersion is: %s\n", eg.ResourceVersion) + return nil + } + if !errors.IsConflict(e) { + return e + } + GinkgoWriter.Printf("conflict, need retry, now the request resourceVersion is: %s\n", eg.ResourceVersion) + time.Sleep(time.Second) + } + } } // DeleteEgressGatewayIfExists delete egressGateway if its exists diff --git a/test/e2e/common/eip.go b/test/e2e/common/eip.go index 7e05b76b4..99a8421ae 100644 --- a/test/e2e/common/eip.go +++ b/test/e2e/common/eip.go @@ -154,7 +154,9 @@ func CheckEipInClientPod(f *framework.Framework, pod *corev1.Pod, eIP, serverIP default: out, err := GetClientPodLog(f, pod, serverIP, connectionTimeout, logDuration) Expect(err).NotTo(HaveOccurred()) - GinkgoWriter.Printf("the client-pod log: \n%s\n", out) + if err != nil { + GinkgoWriter.Printf("the client-pod log: \n%s\n", out) + } if expect { if strings.Contains(out, WEBSOCKET) && strings.Contains(out, eIP) { webSocketOk = true diff --git a/test/e2e/egressgateway/egressgateway_test.go b/test/e2e/egressgateway/egressgateway_test.go index 3588bae7e..ed4554b06 100644 --- a/test/e2e/egressgateway/egressgateway_test.go +++ b/test/e2e/egressgateway/egressgateway_test.go @@ -178,40 +178,40 @@ var _ = Describe("Operate egressGateway", Label("egressGateway"), func() { } }, Entry("Failed when add invalid `IP` to `Ippools`", Label("G00009"), false, func() error { - Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred()) if enableV4 { eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, invalidIPv4) } if enableV6 { eg.Spec.Ippools.IPv6 = append(eg.Spec.Ippools.IPv6, invalidIPv6) } - return common.UpdateEgressGateway(f, eg) + GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name) + return common.UpdateEgressGateway(f, eg, time.Second*10) }), Entry("Succeeded when add valid `IP` to `Ippools`", Label("G00012", "G00013"), true, func() error { - Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred()) if enableV4 { eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, singleIpv4Pool...) } if enableV6 { eg.Spec.Ippools.IPv6 = append(eg.Spec.Ippools.IPv6, singleIpv6Pool...) } - return common.UpdateEgressGateway(f, eg) + GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name) + return common.UpdateEgressGateway(f, eg, time.Second*10) }), Entry("Failed when delete `IP` that being used", Label("G00010"), false, func() error { - Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred()) if enableV4 { eg.Spec.Ippools.IPv4 = tools.RemoveValueFromSlice(eg.Spec.Ippools.IPv4, v4DefaultEip) } if enableV6 { eg.Spec.Ippools.IPv6 = tools.RemoveValueFromSlice(eg.Spec.Ippools.IPv6, v6DefaultEip) } - return common.UpdateEgressGateway(f, eg) + GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name) + return common.UpdateEgressGateway(f, eg, time.Second*10) }), Entry("Failed when add different number of ip to `Ippools.IPv4` and `Ippools.IPv6`", Label("G00011"), false, func() error { - Expect(common.GetEgressGateway(f, name, eg)).NotTo(HaveOccurred()) if enableV4 && enableV6 { eg.Spec.Ippools.IPv4 = append(eg.Spec.Ippools.IPv4, singleIpv4Pool...) - return common.UpdateEgressGateway(f, eg) + GinkgoWriter.Printf("UpdateEgressGateway: %s\n", eg.Name) + return common.UpdateEgressGateway(f, eg, time.Second*10) } return ErrNotNeed }), diff --git a/test/yaml/calico.yaml b/test/yaml/calico.yaml index 6175d3a7d..099e89e9d 100644 --- a/test/yaml/calico.yaml +++ b/test/yaml/calico.yaml @@ -4495,6 +4495,8 @@ spec: # Use Kubernetes API as the backing datastore. - name: DATASTORE_TYPE value: "kubernetes" + - name: "CALICO_IPV6POOL_NAT_OUTGOING" + value: "true" # Wait for the datastore. - name: WAIT_FOR_DATASTORE value: "true"