Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Mesh (GAMMA) conformance tests #1878

Merged
merged 3 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@ func TestConformance(t *testing.T) {
EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures,
})
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)

// TODO(https://github.com/kubernetes-sigs/gateway-api/issues/1891) this will likely changed;
// for now, we use this mechanism to split mesh and gateway types
var toRun []suite.ConformanceTest
if supportedFeatures.Has(suite.SupportGateway) {
toRun = append(toRun, tests.ConformanceTests...)
}
howardjohn marked this conversation as resolved.
Show resolved Hide resolved
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-release/app:1.17.1
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-release/app:1.17.1
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these files have old copyright dates, are they just being copied from Istio codebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from other files in this repo


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