...
1
16
17 package tests
18
19 import (
20 "testing"
21
22 "k8s.io/apimachinery/pkg/types"
23
24 "sigs.k8s.io/gateway-api/conformance/utils/http"
25 "sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
26 "sigs.k8s.io/gateway-api/conformance/utils/suite"
27 )
28
29 func init() {
30 ConformanceTests = append(ConformanceTests, HTTPRouteCrossNamespace)
31 }
32
33 var HTTPRouteCrossNamespace = suite.ConformanceTest{
34 ShortName: "HTTPRouteCrossNamespace",
35 Description: "A single HTTPRoute in the gateway-conformance-web-backend namespace should attach to Gateway in another namespace",
36 Features: []suite.SupportedFeature{
37 suite.SupportGateway,
38 suite.SupportHTTPRoute,
39 },
40 Manifests: []string{"tests/httproute-cross-namespace.yaml"},
41 Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
42 routeNN := types.NamespacedName{Name: "cross-namespace", Namespace: "gateway-conformance-web-backend"}
43 gwNN := types.NamespacedName{Name: "backend-namespaces", Namespace: "gateway-conformance-infra"}
44 gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
45 kubernetes.HTTPRouteMustHaveResolvedRefsConditionsTrue(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN)
46
47 t.Run("Simple HTTP request should reach web-backend", func(t *testing.T) {
48 http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{
49 Request: http.Request{Path: "/"},
50 Response: http.Response{StatusCode: 200},
51 Backend: "web-backend",
52 Namespace: "gateway-conformance-web-backend",
53 })
54 })
55 },
56 }
57
View as plain text