This is an automated email from the ASF dual-hosted git repository. ashishtiwari pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push: new eb7c06a6 chore: migrate retries/timeout tests for apisixupstream (#2517) eb7c06a6 is described below commit eb7c06a6f527df1b756ea50ece2bc0fa7dbc6c4e Author: Ashish Tiwari <ashishjaitiwari15112...@gmail.com> AuthorDate: Mon Aug 25 09:49:38 2025 +0530 chore: migrate retries/timeout tests for apisixupstream (#2517) --- test/e2e/crds/v2/route.go | 111 ++++++++++++++++++++++++++++++++++++++++ test/e2e/framework/assertion.go | 2 +- 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/test/e2e/crds/v2/route.go b/test/e2e/crds/v2/route.go index 3e1dce56..1a0a01ce 100644 --- a/test/e2e/crds/v2/route.go +++ b/test/e2e/crds/v2/route.go @@ -1369,6 +1369,117 @@ spec: }) }) }) + + Context("Test ApisixRoute with ApisixUpstream: retries", func() { + const apisixRouteSpec = ` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: default + namespace: %s +spec: + ingressClassName: %s + http: + - name: rule0 + match: + hosts: + - httpbin + paths: + - /* + backends: + - serviceName: httpbin-service-e2e-test + servicePort: 80 + +` + const apisixUpstreamSpec = ` +apiVersion: apisix.apache.org/v2 +kind: ApisixUpstream +metadata: + name: httpbin-service-e2e-test + namespace: %s +spec: + ingressClassName: %s + retries: 3 +` + It("create ApisixRoute and upstream with retries", func() { + By("apply apisixupstream") + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin-service-e2e-test"}, + new(apiv2.ApisixUpstream), fmt.Sprintf(apisixUpstreamSpec, s.Namespace(), s.Namespace())) + By("apply apisixroute") + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"}, + new(apiv2.ApisixRoute), fmt.Sprintf(apisixRouteSpec, s.Namespace(), s.Namespace())) + Eventually(func() bool { + services, err := s.DefaultDataplaneResource().Service().List(context.Background()) + if err != nil { + return false + } + if len(services) != 1 { + return false + } + if services[0].Upstream == nil { + return false + } + return *services[0].Upstream.Retries == 3 + }).WithTimeout(30 * time.Second).ProbeEvery(5 * time.Second).Should(BeTrue()) + }) + }) + + Context("Test ApisixRoute with ApisixUpstream: timeout", func() { + const apisixRouteSpec = ` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: default + namespace: %s +spec: + ingressClassName: %s + http: + - name: rule0 + match: + hosts: + - httpbin + paths: + - /* + backends: + - serviceName: httpbin-service-e2e-test + servicePort: 80 + +` + const apisixUpstreamSpec = ` +apiVersion: apisix.apache.org/v2 +kind: ApisixUpstream +metadata: + name: httpbin-service-e2e-test + namespace: %s +spec: + ingressClassName: %s + timeout: + read: 10s + send: 10s +` + It("create ApisixRoute and upstream with retries", func() { + By("apply apisixupstream") + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin-service-e2e-test"}, + new(apiv2.ApisixUpstream), fmt.Sprintf(apisixUpstreamSpec, s.Namespace(), s.Namespace())) + By("apply apisixroute") + applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"}, + new(apiv2.ApisixRoute), fmt.Sprintf(apisixRouteSpec, s.Namespace(), s.Namespace())) + Eventually(func() bool { + services, err := s.DefaultDataplaneResource().Service().List(context.Background()) + if err != nil { + return false + } + if len(services) != 1 { + return false + } + if services[0].Upstream == nil { + return false + } + return services[0].Upstream.Timeout.Read == 10 && services[0].Upstream.Timeout.Send == 10 + }).WithTimeout(30 * time.Second).ProbeEvery(5 * time.Second).Should(BeTrue()) + }) + }) + Context("Test tls secret processed from ApisixUpstream", func() { var Cert = strings.TrimSpace(framework.TestServerCert) var Key = strings.TrimSpace(framework.TestServerKey) diff --git a/test/e2e/framework/assertion.go b/test/e2e/framework/assertion.go index 32e9c2a9..fe069b4e 100644 --- a/test/e2e/framework/assertion.go +++ b/test/e2e/framework/assertion.go @@ -179,7 +179,7 @@ type applier struct { func (a *applier) MustApplyAPIv2(nn types.NamespacedName, obj client.Object, spec string) { require.NoError(a.t, a.apply(spec), "creating %s", nn) - APIv2MustHaveCondition(a.t, a.cli, 90*time.Second, nn, obj, metav1.Condition{ + APIv2MustHaveCondition(a.t, a.cli, 180*time.Second, nn, obj, metav1.Condition{ Type: string(gatewayv1.RouteConditionAccepted), Status: metav1.ConditionTrue, Reason: string(gatewayv1.GatewayReasonAccepted),