Skip to content

Commit ddc9a5c

Browse files
authored
e2e: fix DynamicResolverBackend test (#6374)
1 parent 5945430 commit ddc9a5c

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

test/e2e/testdata/httproute-with-dynamic-resolver-backend.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ spec:
2525
- group: gateway.envoyproxy.io
2626
kind: Backend
2727
name: backend-dynamic-resolver-with-app-protocol
28-
match:
28+
matches:
29+
- path:
2930
type: PathPrefix
3031
value: /status
3132
---

test/e2e/tests/httproute_with_dynamic_resolver_backend.go

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,62 +27,70 @@ var DynamicResolverBackendTest = suite.ConformanceTest{
2727
"testdata/httproute-with-dynamic-resolver-backend.yaml",
2828
},
2929
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
30-
ns := "gateway-conformance-infra"
31-
routeNN := types.NamespacedName{Name: "httproute-with-dynamic-resolver-backend", Namespace: ns}
32-
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
30+
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ConformanceInfraNamespace}
31+
routeNN := types.NamespacedName{Name: "httproute-with-dynamic-resolver-backend", Namespace: ConformanceInfraNamespace}
3332
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
34-
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "backend-dynamic-resolver", Namespace: ns})
33+
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "backend-dynamic-resolver", Namespace: ConformanceInfraNamespace})
3534

3635
t.Run("route to service foo", func(t *testing.T) {
3736
expectedResponse := http.ExpectedResponse{
3837
Request: http.Request{
39-
Host: "test-service-foo.gateway-conformance-infra",
38+
Host: "test-service-foo.gateway-conformance-infra.svc.cluster.local",
4039
Path: "/",
4140
},
4241
Response: http.Response{
4342
StatusCode: 200,
4443
},
45-
Namespace: ns,
44+
Namespace: ConformanceInfraNamespace,
4645
}
4746

4847
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)
4948
})
5049
t.Run("route to service bar", func(t *testing.T) {
5150
expectedResponse := http.ExpectedResponse{
5251
Request: http.Request{
53-
Host: "test-service-bar.gateway-conformance-infra",
52+
Host: "test-service-bar.gateway-conformance-infra.svc.cluster.local",
5453
Path: "/",
5554
},
5655
Response: http.Response{
5756
StatusCode: 200,
5857
},
59-
Namespace: ns,
58+
Namespace: ConformanceInfraNamespace,
6059
}
6160

6261
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)
6362
})
64-
6563
t.Run("route to external service with app protocol", func(t *testing.T) {
66-
routeNN := types.NamespacedName{Name: "httproute-with-dynamic-resolver-backend-with-app-protocol", Namespace: ns}
64+
routeNN := types.NamespacedName{Name: "httproute-with-dynamic-resolver-backend-with-app-protocol", Namespace: ConformanceInfraNamespace}
6765
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
68-
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "backend-dynamic-resolver-with-app-protocol", Namespace: ns})
66+
BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "backend-dynamic-resolver-with-app-protocol", Namespace: ConformanceInfraNamespace})
6967

70-
expectedResponse := http.ExpectedResponse{
68+
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{
7169
Request: http.Request{
7270
Host: "httpbin.org",
7371
Path: "/status/200",
7472
},
75-
ExpectedRequest: &http.ExpectedRequest{
76-
Request: http.Request{
77-
Host: "",
78-
},
73+
Response: http.Response{
74+
StatusCode: 502, // request will fail because httpbin.org doesn't support http2.0
75+
},
76+
})
77+
78+
// test with nghttp2.org, it support http2.0
79+
// https://github.com/postmanlabs/httpbin/issues/373#issuecomment-354534597
80+
req := http.MakeRequest(t, &http.ExpectedResponse{
81+
Request: http.Request{
82+
Host: "nghttp2.org",
83+
Path: "httpbin/status/200",
7984
},
8085
Response: http.Response{
8186
StatusCode: 200,
8287
},
83-
}
84-
85-
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, expectedResponse)
88+
}, gwAddr, "HTTP", "http")
89+
http.WaitForConsistentResponse(t, suite.RoundTripper, req, http.ExpectedResponse{
90+
Response: http.Response{
91+
StatusCode: 200,
92+
},
93+
}, suite.TimeoutConfig.RequiredConsecutiveSuccesses, suite.TimeoutConfig.MaxTimeToConsistency)
8694
})
8795
},
8896
}

0 commit comments

Comments
 (0)