Skip to content

Commit

Permalink
gamma: initial mesh conformance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed Mar 30, 2023
1 parent d6acbb6 commit ef75c8a
Show file tree
Hide file tree
Showing 15 changed files with 801 additions and 26 deletions.
11 changes: 10 additions & 1 deletion conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ func TestConformance(t *testing.T) {
EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures,
})
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)

var toRun []suite.ConformanceTest
if supportedFeatures.Has(suite.SupportGateway) {
toRun = append(toRun, tests.ConformanceTests...)
}
if supportedFeatures.Has(suite.SupportGAMMA) {
toRun = append(toRun, tests.MeshConformanceTests...)
}

cSuite.Run(t, toRun)
}

// parseSupportedFeatures parses flag arguments and converts the string to
Expand Down
2 changes: 1 addition & 1 deletion conformance/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ package conformance

import "embed"

//go:embed tests/* base/*
//go:embed tests/* base/* mesh/*
var Manifests embed.FS
130 changes: 130 additions & 0 deletions conformance/mesh/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: gateway-conformance-mesh
labels:
gateway-conformance: infra
---

apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-v1
namespace: gateway-conformance-mesh
labels:
app: echo
spec:
selector:
matchLabels:
app: echo
version: v1
template:
metadata:
labels:
app: echo
version: v1
spec:
containers:
- name: echo
image: gcr.io/istio-testing/app:latest
imagePullPolicy: IfNotPresent
args:
- --tcp=9090
- --port=80
- --grpc=7070
- --port=443
- --tls=443
- --crt=/cert.crt
- --key=/cert.key
---
apiVersion: v1
kind: Service
metadata:
name: echo-v1
namespace: gateway-conformance-mesh
spec:
selector:
app: echo
version: v1
ports:
- name: http
port: 80
- name: https
port: 443
- name: tcp
port: 9090
- name: tcp-sf
port: 9091
- name: grpc
port: 7070
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-v2
namespace: gateway-conformance-mesh
labels:
app: echo
spec:
selector:
matchLabels:
app: echo
version: v2
template:
metadata:
labels:
app: echo
version: v2
spec:
containers:
- name: echo
image: gcr.io/istio-testing/app:latest
imagePullPolicy: IfNotPresent
args:
- --tcp=9090
- --port=80
- --grpc=7070
- --port=443
- --tls=443
- --crt=/cert.crt
- --key=/cert.key
---
apiVersion: v1
kind: Service
metadata:
name: echo-v2
namespace: gateway-conformance-mesh
spec:
selector:
app: echo
version: v2
ports:
- name: http
port: 80
- name: https
port: 443
- name: tcp
port: 9090
- name: grpc
port: 7070
---
apiVersion: v1
kind: Service
metadata:
name: echo
namespace: gateway-conformance-mesh
spec:
selector:
app: echo
ports:
- name: http
port: 80
- name: https
port: 443
- name: tcp
port: 9090
- name: tcp-sf
port: 9091
- name: grpc
port: 7070
1 change: 1 addition & 0 deletions conformance/tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ package tests
import "sigs.k8s.io/gateway-api/conformance/utils/suite"

var ConformanceTests []suite.ConformanceTest
var MeshConformanceTests []suite.ConformanceTest
55 changes: 55 additions & 0 deletions conformance/tests/mesh-basic.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package tests

import (
"testing"

"sigs.k8s.io/gateway-api/conformance/utils/echo"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

func init() {
MeshConformanceTests = append(MeshConformanceTests, MeshBasic)
}

var MeshBasic = suite.ConformanceTest{
ShortName: "MeshBasic",
Description: "A mesh client can communicate with a mesh server. This tests basic reachability with no configuration applied.",
Manifests: []string{},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
cases := []http.ExpectedResponse{{
Request: http.Request{
Host: "echo",
Method: "GET",
},
Response: http.Response{
StatusCode: 200,
},
}}
for i := range cases {
// Declare tc here to avoid loop variable
// reuse issues across parallel tests.
tc := cases[i]
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
client.SendRequest(t, tc)
})
}
},
}
70 changes: 70 additions & 0 deletions conformance/tests/mesh-split.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package tests

import (
"testing"

"sigs.k8s.io/gateway-api/conformance/utils/echo"
"sigs.k8s.io/gateway-api/conformance/utils/http"
"sigs.k8s.io/gateway-api/conformance/utils/suite"
)

func init() {
MeshConformanceTests = append(MeshConformanceTests, MeshTrafficSplit)
}

var MeshTrafficSplit = suite.ConformanceTest{
ShortName: "MeshTrafficSplit",
Description: "A mesh client can send traffic to a Service which is split between two versions",
Manifests: []string{"tests/mesh-split.yaml"},
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
cases := []http.ExpectedResponse{
{
Request: http.Request{
Host: "echo",
Method: "GET",
Path: "/v1",
},
Response: http.Response{
StatusCode: 200,
},
Backend: "echo-v1",
},
{
Request: http.Request{
Host: "echo",
Method: "GET",
Path: "/v2",
},
Response: http.Response{
StatusCode: 200,
},
Backend: "echo-v2",
},
}
for i := range cases {
// Declare tc here to avoid loop variable
// reuse issues across parallel tests.
tc := cases[i]
t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
client.SendRequest(t, tc)
})
}
},
}
24 changes: 24 additions & 0 deletions conformance/tests/mesh-split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: mesh-split
namespace: gateway-conformance-mesh
spec:
parentRefs:
- kind: Service
name: echo
rules:
- matches:
- path:
type: Exact
value: /v1
backendRefs:
- name: echo-v1
port: 80
- matches:
- path:
type: Exact
value: /v2
backendRefs:
- name: echo-v2
port: 80
Loading

0 comments on commit ef75c8a

Please sign in to comment.