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