|
| 1 | +/* |
| 2 | +Copyright 2022 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 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 | + "sigs.k8s.io/gateway-api/pkg/features" |
| 28 | +) |
| 29 | + |
| 30 | +func init() { |
| 31 | + ConformanceTests = append(ConformanceTests, TLSRouteSimpleSameNamespace) |
| 32 | +} |
| 33 | + |
| 34 | +var TCPRouteSimpleSameNamespace = suite.ConformanceTest{ |
| 35 | + ShortName: "TCPRouteSimpleSameNamespace", |
| 36 | + Description: "A single TCPRoute in the gateway-conformance-infra namespace attaches to a Gateway in the same namespace", |
| 37 | + Features: []features.FeatureName{ |
| 38 | + features.SupportGateway, |
| 39 | + features.SupportTCPRoute, |
| 40 | + }, |
| 41 | + Manifests: []string{"tests/tcproute-simple-same-namespace.yaml"}, |
| 42 | + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { |
| 43 | + ns := "gateway-conformance-infra" |
| 44 | + routeNN := types.NamespacedName{Name: "gateway-conformance-infra-test", Namespace: ns} |
| 45 | + gwNN := types.NamespacedName{Name: "gateway-tcproute", Namespace: ns} |
| 46 | + |
| 47 | + kubernetes.NamespacesMustBeReady(t, suite.Client, suite.TimeoutConfig, []string{ns}) |
| 48 | + |
| 49 | + gwAddr := kubernetes.GatewayAndTCPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) |
| 50 | + |
| 51 | + t.Run("Simple TCP request should reach infra-backend", func(t *testing.T) { |
| 52 | + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{ |
| 53 | + Request: http.Request{Path: "/"}, |
| 54 | + Response: http.Response{StatusCode: 200}, |
| 55 | + Backend: "infra-backend-v1", |
| 56 | + Namespace: "gateway-conformance-infra", |
| 57 | + }) |
| 58 | + }) |
| 59 | + }, |
| 60 | +} |
0 commit comments