Skip to content

Commit d306d4f

Browse files
committed
add test for backendErr
1 parent f9d0001 commit d306d4f

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

test/e2e/crds/v2/route.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,45 @@ spec:
741741
By("send requests to verify zero-weight behavior")
742742
for range 30 {
743743
code := verifyRequest()
744-
fmt.Println(code)
744+
Expect(code).Should(Equal(200))
745+
}
746+
})
747+
748+
It("valid backend is set even if other backend is invalid", func() {
749+
const apisixRouteSpec = `
750+
apiVersion: apisix.apache.org/v2
751+
kind: ApisixRoute
752+
metadata:
753+
name: default
754+
spec:
755+
ingressClassName: apisix
756+
http:
757+
- name: rule1
758+
match:
759+
hosts:
760+
- httpbin.org
761+
paths:
762+
- /get
763+
backends:
764+
- serviceName: httpbin-service-e2e-test
765+
servicePort: 80
766+
weight: 10
767+
- serviceName: invalid-service
768+
servicePort: 9180
769+
weight: 5
770+
`
771+
By("apply ApisixRoute with traffic split")
772+
applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "default"}, new(apiv2.ApisixRoute), apisixRouteSpec)
773+
verifyRequest := func() int {
774+
return s.NewAPISIXClient().GET("/get").WithHost("httpbin.org").Expect().Raw().StatusCode
775+
}
776+
777+
By("wait for route to be ready")
778+
time.Sleep(8 * time.Second)
779+
By("send requests to verify all requests routed to valid upstream")
780+
for range 30 {
781+
code := verifyRequest()
782+
Expect(code).Should(Equal(200))
745783
}
746784
})
747785
})

0 commit comments

Comments
 (0)