Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions test/e2e/crds/v2/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have increased this to fix some flaky tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth considering whether it really takes this long to confirm that the configuration has taken effect.

Type: string(gatewayv1.RouteConditionAccepted),
Status: metav1.ConditionTrue,
Reason: string(gatewayv1.GatewayReasonAccepted),
Expand Down
Loading