Skip to content

Commit ef75c8a

Browse files
committed
gamma: initial mesh conformance tests
1 parent d6acbb6 commit ef75c8a

File tree

15 files changed

+801
-26
lines changed

15 files changed

+801
-26
lines changed

Diff for: conformance/conformance_test.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ func TestConformance(t *testing.T) {
6363
EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures,
6464
})
6565
cSuite.Setup(t)
66-
cSuite.Run(t, tests.ConformanceTests)
66+
67+
var toRun []suite.ConformanceTest
68+
if supportedFeatures.Has(suite.SupportGateway) {
69+
toRun = append(toRun, tests.ConformanceTests...)
70+
}
71+
if supportedFeatures.Has(suite.SupportGAMMA) {
72+
toRun = append(toRun, tests.MeshConformanceTests...)
73+
}
74+
75+
cSuite.Run(t, toRun)
6776
}
6877

6978
// parseSupportedFeatures parses flag arguments and converts the string to

Diff for: conformance/embed.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ package conformance
1818

1919
import "embed"
2020

21-
//go:embed tests/* base/*
21+
//go:embed tests/* base/* mesh/*
2222
var Manifests embed.FS

Diff for: conformance/mesh/manifests.yaml

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: gateway-conformance-mesh
6+
labels:
7+
gateway-conformance: infra
8+
---
9+
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: echo-v1
14+
namespace: gateway-conformance-mesh
15+
labels:
16+
app: echo
17+
spec:
18+
selector:
19+
matchLabels:
20+
app: echo
21+
version: v1
22+
template:
23+
metadata:
24+
labels:
25+
app: echo
26+
version: v1
27+
spec:
28+
containers:
29+
- name: echo
30+
image: gcr.io/istio-testing/app:latest
31+
imagePullPolicy: IfNotPresent
32+
args:
33+
- --tcp=9090
34+
- --port=80
35+
- --grpc=7070
36+
- --port=443
37+
- --tls=443
38+
- --crt=/cert.crt
39+
- --key=/cert.key
40+
---
41+
apiVersion: v1
42+
kind: Service
43+
metadata:
44+
name: echo-v1
45+
namespace: gateway-conformance-mesh
46+
spec:
47+
selector:
48+
app: echo
49+
version: v1
50+
ports:
51+
- name: http
52+
port: 80
53+
- name: https
54+
port: 443
55+
- name: tcp
56+
port: 9090
57+
- name: tcp-sf
58+
port: 9091
59+
- name: grpc
60+
port: 7070
61+
---
62+
apiVersion: apps/v1
63+
kind: Deployment
64+
metadata:
65+
name: echo-v2
66+
namespace: gateway-conformance-mesh
67+
labels:
68+
app: echo
69+
spec:
70+
selector:
71+
matchLabels:
72+
app: echo
73+
version: v2
74+
template:
75+
metadata:
76+
labels:
77+
app: echo
78+
version: v2
79+
spec:
80+
containers:
81+
- name: echo
82+
image: gcr.io/istio-testing/app:latest
83+
imagePullPolicy: IfNotPresent
84+
args:
85+
- --tcp=9090
86+
- --port=80
87+
- --grpc=7070
88+
- --port=443
89+
- --tls=443
90+
- --crt=/cert.crt
91+
- --key=/cert.key
92+
---
93+
apiVersion: v1
94+
kind: Service
95+
metadata:
96+
name: echo-v2
97+
namespace: gateway-conformance-mesh
98+
spec:
99+
selector:
100+
app: echo
101+
version: v2
102+
ports:
103+
- name: http
104+
port: 80
105+
- name: https
106+
port: 443
107+
- name: tcp
108+
port: 9090
109+
- name: grpc
110+
port: 7070
111+
---
112+
apiVersion: v1
113+
kind: Service
114+
metadata:
115+
name: echo
116+
namespace: gateway-conformance-mesh
117+
spec:
118+
selector:
119+
app: echo
120+
ports:
121+
- name: http
122+
port: 80
123+
- name: https
124+
port: 443
125+
- name: tcp
126+
port: 9090
127+
- name: tcp-sf
128+
port: 9091
129+
- name: grpc
130+
port: 7070

Diff for: conformance/tests/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ package tests
1919
import "sigs.k8s.io/gateway-api/conformance/utils/suite"
2020

2121
var ConformanceTests []suite.ConformanceTest
22+
var MeshConformanceTests []suite.ConformanceTest

Diff for: conformance/tests/mesh-basic.go

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
"sigs.k8s.io/gateway-api/conformance/utils/echo"
23+
"sigs.k8s.io/gateway-api/conformance/utils/http"
24+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25+
)
26+
27+
func init() {
28+
MeshConformanceTests = append(MeshConformanceTests, MeshBasic)
29+
}
30+
31+
var MeshBasic = suite.ConformanceTest{
32+
ShortName: "MeshBasic",
33+
Description: "A mesh client can communicate with a mesh server. This tests basic reachability with no configuration applied.",
34+
Manifests: []string{},
35+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
36+
client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
37+
cases := []http.ExpectedResponse{{
38+
Request: http.Request{
39+
Host: "echo",
40+
Method: "GET",
41+
},
42+
Response: http.Response{
43+
StatusCode: 200,
44+
},
45+
}}
46+
for i := range cases {
47+
// Declare tc here to avoid loop variable
48+
// reuse issues across parallel tests.
49+
tc := cases[i]
50+
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
51+
client.SendRequest(t, tc)
52+
})
53+
}
54+
},
55+
}

Diff for: conformance/tests/mesh-split.go

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
"sigs.k8s.io/gateway-api/conformance/utils/echo"
23+
"sigs.k8s.io/gateway-api/conformance/utils/http"
24+
"sigs.k8s.io/gateway-api/conformance/utils/suite"
25+
)
26+
27+
func init() {
28+
MeshConformanceTests = append(MeshConformanceTests, MeshTrafficSplit)
29+
}
30+
31+
var MeshTrafficSplit = suite.ConformanceTest{
32+
ShortName: "MeshTrafficSplit",
33+
Description: "A mesh client can send traffic to a Service which is split between two versions",
34+
Manifests: []string{"tests/mesh-split.yaml"},
35+
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
36+
client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
37+
cases := []http.ExpectedResponse{
38+
{
39+
Request: http.Request{
40+
Host: "echo",
41+
Method: "GET",
42+
Path: "/v1",
43+
},
44+
Response: http.Response{
45+
StatusCode: 200,
46+
},
47+
Backend: "echo-v1",
48+
},
49+
{
50+
Request: http.Request{
51+
Host: "echo",
52+
Method: "GET",
53+
Path: "/v2",
54+
},
55+
Response: http.Response{
56+
StatusCode: 200,
57+
},
58+
Backend: "echo-v2",
59+
},
60+
}
61+
for i := range cases {
62+
// Declare tc here to avoid loop variable
63+
// reuse issues across parallel tests.
64+
tc := cases[i]
65+
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
66+
client.SendRequest(t, tc)
67+
})
68+
}
69+
},
70+
}

Diff for: conformance/tests/mesh-split.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: gateway.networking.k8s.io/v1beta1
2+
kind: HTTPRoute
3+
metadata:
4+
name: mesh-split
5+
namespace: gateway-conformance-mesh
6+
spec:
7+
parentRefs:
8+
- kind: Service
9+
name: echo
10+
rules:
11+
- matches:
12+
- path:
13+
type: Exact
14+
value: /v1
15+
backendRefs:
16+
- name: echo-v1
17+
port: 80
18+
- matches:
19+
- path:
20+
type: Exact
21+
value: /v2
22+
backendRefs:
23+
- name: echo-v2
24+
port: 80

0 commit comments

Comments
 (0)