Skip to content

Commit 3210423

Browse files
committed
Adds simple tcproute test case
Signed-off-by: Daneyon Hansen <[email protected]>
1 parent 8364490 commit 3210423

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: gateway.networking.k8s.io/v1alpha2
2+
kind: TCPRoute
3+
metadata:
4+
name: gateway-conformance-infra-test
5+
namespace: gateway-conformance-infra
6+
spec:
7+
parentRefs:
8+
- name: gateway-tcproute
9+
namespace: gateway-conformance-infra
10+
rules:
11+
- backendRefs:
12+
- name: infra-backend-v1
13+
port: 8080
14+
---
15+
apiVersion: gateway.networking.k8s.io/v1beta1
16+
kind: Gateway
17+
metadata:
18+
name: gateway-tcproute
19+
namespace: gateway-conformance-infra
20+
spec:
21+
gatewayClassName: "{GATEWAY_CLASS_NAME}"
22+
listeners:
23+
- name: tcp
24+
port: 8080
25+
protocol: TCP
26+
allowedRoutes:
27+
namespaces:
28+
from: Same
29+
kinds:
30+
- kind: TCPRoute

0 commit comments

Comments
 (0)