add dns&static registry e2e test (#1393)

This commit is contained in:
Jun
2024-10-16 10:21:03 +08:00
committed by GitHub
parent 85f8eb5166
commit e298078065
5 changed files with 262 additions and 0 deletions

View File

@@ -80,6 +80,58 @@ spec:
---
apiVersion: v1
kind: Service
metadata:
name: infra-backend-v1-ip
namespace: higress-conformance-infra
spec:
selector:
app: infra-backend-v1-ip
ports:
- protocol: TCP
port: 8080
targetPort: 3000
clusterIP: 10.96.254.254
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: infra-backend-v1-ip
namespace: higress-conformance-infra
labels:
app: infra-backend-v1-ip
spec:
replicas: 1
selector:
matchLabels:
app: infra-backend-v1-ip
template:
metadata:
labels:
app: infra-backend-v1-ip
spec:
containers:
- name: infra-backend-v1-ip
# From https://github.com/kubernetes-sigs/ingress-controller-conformance/tree/master/images/echoserver
# image: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/echoserver:v20221109-7ee2f3e
# From https://github.com/Uncle-Justice/echo-server
image: higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/echo-server:1.3.0
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
requests:
cpu: 10m
---
apiVersion: v1
kind: Service
metadata:
name: infra-backend-v2
namespace: higress-conformance-infra

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2022 Alibaba Group Holding Ltd.
//
// 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"
"github.com/alibaba/higress/test/e2e/conformance/utils/http"
"github.com/alibaba/higress/test/e2e/conformance/utils/suite"
)
func init() {
Register(HTTPRouteDNSRegistry)
}
var HTTPRouteDNSRegistry = suite.ConformanceTest{
ShortName: "HTTPRouteDNSRegistry",
Description: "The Ingress in the higress-conformance-infra namespace uses the dns service registry.",
Manifests: []string{"tests/httproute-dns-registry.yaml"},
Features: []suite.SupportedFeature{suite.HTTPConformanceFeature},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
testcases := []http.Assertion{
{
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo.com",
Path: "/",
Method: "GET",
},
},
Response: http.AssertionResponse{
ExpectedResponseNoRequest: true,
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
}
t.Run("HTTPRoute DNS Registry", func(t *testing.T) {
for _, testcase := range testcases {
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, suite.GatewayAddress, testcase)
}
})
},
}

View File

@@ -0,0 +1,48 @@
# Copyright (c) 2022 Alibaba Group Holding Ltd.
#
# 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.
apiVersion: networking.higress.io/v1
kind: McpBridge
metadata:
name: default
namespace: higress-system
spec:
registries:
- type: dns
domain: infra-backend-v1.higress-conformance-infra.svc.cluster.local
name: infra-backend-v1
port: 8080
protocol: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
higress.io/destination: infra-backend-v1.dns
name: httproute-infra-backend-v1-dns-ingress
namespace: higress-system
spec:
ingressClassName: higress
rules:
- host: "foo.com"
http:
paths:
- pathType: Prefix
path: /
backend:
resource:
apiGroup: networking.higress.io
kind: McpBridge
name: default

View File

@@ -0,0 +1,57 @@
// Copyright (c) 2022 Alibaba Group Holding Ltd.
//
// 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"
"github.com/alibaba/higress/test/e2e/conformance/utils/http"
"github.com/alibaba/higress/test/e2e/conformance/utils/suite"
)
func init() {
Register(HTTPRouteStaticRegistry)
}
var HTTPRouteStaticRegistry = suite.ConformanceTest{
ShortName: "HTTPRouteStaticRegistry",
Description: "The Ingress in the higress-conformance-infra namespace uses the static service registry.",
Manifests: []string{"tests/httproute-static-registry.yaml"},
Features: []suite.SupportedFeature{suite.HTTPConformanceFeature},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
testcases := []http.Assertion{
{
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo.com",
Path: "/",
Method: "GET",
},
},
Response: http.AssertionResponse{
ExpectedResponseNoRequest: true,
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
}
t.Run("HTTPRoute Static Registry", func(t *testing.T) {
for _, testcase := range testcases {
http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, suite.GatewayAddress, testcase)
}
})
},
}

View File

@@ -0,0 +1,48 @@
# Copyright (c) 2022 Alibaba Group Holding Ltd.
#
# 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.
apiVersion: networking.higress.io/v1
kind: McpBridge
metadata:
name: default
namespace: higress-system
spec:
registries:
- type: static
domain: 10.96.254.254:8080
name: infra-backend-v1-ip
port: 8080
protocol: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
higress.io/destination: infra-backend-v1-ip.static
name: httproute-infra-backend-v1-ip-ingress
namespace: higress-system
spec:
ingressClassName: higress
rules:
- host: "foo.com"
http:
paths:
- pathType: Prefix
path: /
backend:
resource:
apiGroup: networking.higress.io
kind: McpBridge
name: default