From e298078065db6550f8a6035c93676de139c75777 Mon Sep 17 00:00:00 2001 From: Jun <108045855+2456868764@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:21:03 +0800 Subject: [PATCH] add dns&static registry e2e test (#1393) --- test/e2e/conformance/base/manifests.yaml | 52 +++++++++++++++++ .../tests/httproute-dns-registry.go | 57 +++++++++++++++++++ .../tests/httproute-dns-registry.yaml | 48 ++++++++++++++++ .../tests/httproute-static-registry.go | 57 +++++++++++++++++++ .../tests/httproute-static-registry.yaml | 48 ++++++++++++++++ 5 files changed, 262 insertions(+) create mode 100644 test/e2e/conformance/tests/httproute-dns-registry.go create mode 100644 test/e2e/conformance/tests/httproute-dns-registry.yaml create mode 100644 test/e2e/conformance/tests/httproute-static-registry.go create mode 100644 test/e2e/conformance/tests/httproute-static-registry.yaml diff --git a/test/e2e/conformance/base/manifests.yaml b/test/e2e/conformance/base/manifests.yaml index 235dce14d..a8afe3b11 100644 --- a/test/e2e/conformance/base/manifests.yaml +++ b/test/e2e/conformance/base/manifests.yaml @@ -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 diff --git a/test/e2e/conformance/tests/httproute-dns-registry.go b/test/e2e/conformance/tests/httproute-dns-registry.go new file mode 100644 index 000000000..1864b8d39 --- /dev/null +++ b/test/e2e/conformance/tests/httproute-dns-registry.go @@ -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) + } + }) + }, +} diff --git a/test/e2e/conformance/tests/httproute-dns-registry.yaml b/test/e2e/conformance/tests/httproute-dns-registry.yaml new file mode 100644 index 000000000..8f992ac9e --- /dev/null +++ b/test/e2e/conformance/tests/httproute-dns-registry.yaml @@ -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 diff --git a/test/e2e/conformance/tests/httproute-static-registry.go b/test/e2e/conformance/tests/httproute-static-registry.go new file mode 100644 index 000000000..b95acf4a6 --- /dev/null +++ b/test/e2e/conformance/tests/httproute-static-registry.go @@ -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) + } + }) + }, +} diff --git a/test/e2e/conformance/tests/httproute-static-registry.yaml b/test/e2e/conformance/tests/httproute-static-registry.yaml new file mode 100644 index 000000000..310302fbb --- /dev/null +++ b/test/e2e/conformance/tests/httproute-static-registry.yaml @@ -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