From 8d8ad6d624731f1cb6f60d4b84458443ff5e266b Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Tue, 19 Sep 2023 17:12:38 +0800 Subject: [PATCH] fix: remove non-existed namespaces and separate bases (#541) Signed-off-by: bitliu --- test/e2e/conformance/base/consul.yaml | 119 +++++++++++ test/e2e/conformance/base/dubbo.yaml | 39 ++++ test/e2e/conformance/base/eureka.yaml | 125 +++++++++++ test/e2e/conformance/base/manifests.yaml | 247 ---------------------- test/e2e/conformance/base/nacos.yaml | 49 +++++ test/e2e/conformance/utils/suite/suite.go | 21 +- 6 files changed, 346 insertions(+), 254 deletions(-) create mode 100644 test/e2e/conformance/base/consul.yaml create mode 100644 test/e2e/conformance/base/dubbo.yaml create mode 100644 test/e2e/conformance/base/eureka.yaml create mode 100644 test/e2e/conformance/base/nacos.yaml diff --git a/test/e2e/conformance/base/consul.yaml b/test/e2e/conformance/base/consul.yaml new file mode 100644 index 000000000..a935debf9 --- /dev/null +++ b/test/e2e/conformance/base/consul.yaml @@ -0,0 +1,119 @@ +# 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. + +# This file contains the base resources that most conformance tests will rely +# on. This includes 3 namespaces along with Gateways, Services and Deployments +# that can be used as backends for routing traffic. The most important +# resources included are the Gateways (all in the higress-conformance-infra +# namespace): +# - same-namespace (only supports route in same ns) +# - all-namespaces (supports routes in all ns) +# - backend-namespaces (supports routes in ns with backend label) + +apiVersion: v1 +kind: Pod +metadata: + name: consul-standlone + namespace: higress-conformance-app-backend + labels: + name: consul-standlone +spec: + containers: + - name: consul + image: docker.io/hashicorp/consul:1.16.0 + resources: + requests: + cpu: 10m + ports: + - containerPort: 8500 + name: http + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: consul-service + namespace: higress-conformance-app-backend + labels: + name: consul-standlone +spec: + clusterIP: None + ports: + - name: http-query + port: 8500 + protocol: TCP + targetPort: 8500 + selector: + name: consul-standlone +--- +apiVersion: v1 +kind: Pod +metadata: + name: httpbin + namespace: higress-conformance-app-backend +spec: + containers: + - name: httpbin + image: registry.cn-hangzhou.aliyuncs.com/2456868764/httpbin:1.0.2 + command: + - /app/httpbin + - --registry-type=consul + - --consul-server-address=consul-service:8500 + - --server-port=8080 + - --service-tags=higress,httpbin + env: + - name: SERVICE_NAME + value: httpbin + - name: VERSION + value: v1 + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: SERVICE_ACCOUNT + valueFrom: + fieldRef: + fieldPath: spec.serviceAccountName + ports: + - containerPort: 8080 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 5 + httpGet: + path: /ping + port: 8080 + scheme: HTTP + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 1 + livenessProbe: + httpGet: + path: /ping + port: 8080 + scheme: HTTP + initialDelaySeconds: 20 + periodSeconds: 20 diff --git a/test/e2e/conformance/base/dubbo.yaml b/test/e2e/conformance/base/dubbo.yaml new file mode 100644 index 000000000..396647b61 --- /dev/null +++ b/test/e2e/conformance/base/dubbo.yaml @@ -0,0 +1,39 @@ +# 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. + +# This file contains the base resources that most conformance tests will rely +# on. This includes 3 namespaces along with Gateways, Services and Deployments +# that can be used as backends for routing traffic. The most important +# resources included are the Gateways (all in the higress-conformance-infra +# namespace): +# - same-namespace (only supports route in same ns) +# - all-namespaces (supports routes in all ns) +# - backend-namespaces (supports routes in ns with backend label) + +apiVersion: v1 +kind: Pod +metadata: + name: dubbo-demo-provider + namespace: higress-conformance-app-backend +spec: + containers: + - name: dubbo-demo-provider + image: registry.cn-hangzhou.aliyuncs.com/hinsteny/dubbo-provider-demo:0.0.2 + env: + - name: NACOS_K8S_NAMESPACE + value: higress-conformance-app-backend + - name: DUBBO_GROUP + value: dev + ports: + - containerPort: 20880 diff --git a/test/e2e/conformance/base/eureka.yaml b/test/e2e/conformance/base/eureka.yaml new file mode 100644 index 000000000..359c07b54 --- /dev/null +++ b/test/e2e/conformance/base/eureka.yaml @@ -0,0 +1,125 @@ +# 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. + +# This file contains the base resources that most conformance tests will rely +# on. This includes 3 namespaces along with Gateways, Services and Deployments +# that can be used as backends for routing traffic. The most important +# resources included are the Gateways (all in the higress-conformance-infra +# namespace): +# - same-namespace (only supports route in same ns) +# - all-namespaces (supports routes in all ns) +# - backend-namespaces (supports routes in ns with backend label) + +apiVersion: v1 +kind: ConfigMap +metadata: + name: eureka-cm + namespace: higress-conformance-app-backend +data: + # if you want to deploy n instances of eureka cluster, + # you should set eureka_service_address: http://eureka-0.eureka:8761/eureka,...,http://eureka-(n-1).eureka:8761/eureka + eureka_service_address: "http://eureka-0.eureka.higress-conformance-app-backend.svc:8761/eureka" +--- +apiVersion: v1 +kind: Service +metadata: + name: eureka + namespace: higress-conformance-app-backend + labels: + app: eureka +spec: + clusterIP: None + ports: + - port: 8761 + name: eureka + selector: + app: eureka +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: eureka + namespace: higress-conformance-app-backend +spec: + serviceName: eureka + # n instances + replicas: 1 + selector: + matchLabels: + app: eureka + template: + metadata: + labels: + app: eureka + spec: + containers: + - name: eureka + image: bitinit/eureka + ports: + - containerPort: 8761 + name: http + protocol: TCP + resources: + requests: + memory: "500Mi" + cpu: "500m" + env: + - name: EUREKA_SERVER_ADDRESS + valueFrom: + configMapKeyRef: + name: eureka-cm + key: eureka_service_address + - name: ENVIRONMENT + value: "prod" + - name: JVM_OPTS + value: "-Xms1g -Xmx1g" + livenessProbe: + httpGet: + path: / + port: 8761 + initialDelaySeconds: 30 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: 8761 + initialDelaySeconds: 30 + periodSeconds: 10 +--- +apiVersion: v1 +kind: Pod +metadata: + name: eureka-registry-provider + namespace: higress-conformance-app-backend +spec: + containers: + - name: eureka-registry-provider + image: charlie1380/eureka-registry-provider:v0.3.0 + env: + - name: EUREKA_SERVER_ADDRESS + valueFrom: + configMapKeyRef: + name: eureka-cm + key: eureka_service_address + ports: + - containerPort: 8888 + name: http + protocol: TCP + readinessProbe: + failureThreshold: 5 + httpGet: + path: /healthz + port: 8888 + scheme: HTTP + periodSeconds: 1 diff --git a/test/e2e/conformance/base/manifests.yaml b/test/e2e/conformance/base/manifests.yaml index fc9247f9b..9b0a7ae9d 100644 --- a/test/e2e/conformance/base/manifests.yaml +++ b/test/e2e/conformance/base/manifests.yaml @@ -318,250 +318,3 @@ spec: resources: requests: cpu: 10m ---- -apiVersion: v1 -kind: Pod -metadata: - name: nacos-standlone-rc3 - namespace: higress-conformance-app-backend - labels: - name: nacos-standlone-rc3 -spec: - containers: - - name: nacos-standlone-rc3 - image: registry.cn-hangzhou.aliyuncs.com/hinsteny/nacos-standlone-rc3:1.0.0-RC3 - ports: - - containerPort: 8848 ---- -apiVersion: v1 -kind: Service -metadata: - name: nacos-standlone-rc3-service - namespace: higress-conformance-app-backend -spec: - selector: - name: nacos-standlone-rc3 - clusterIP: None - ports: - - name: foo # name is not required for single-port Services - port: 8848 ---- -apiVersion: v1 -kind: Pod -metadata: - name: dubbo-demo-provider - namespace: higress-conformance-app-backend -spec: - containers: - - name: dubbo-demo-provider - image: registry.cn-hangzhou.aliyuncs.com/hinsteny/dubbo-provider-demo:0.0.2 - env: - - name: NACOS_K8S_NAMESPACE - value: higress-conformance-app-backend - - name: DUBBO_GROUP - value: dev - ports: - - containerPort: 20880 ---- -apiVersion: v1 -kind: Pod -metadata: - name: consul-standlone - namespace: higress-conformance-app-backend - labels: - name: consul-standlone -spec: - containers: - - name: consul - image: docker.io/hashicorp/consul:1.16.0 - resources: - requests: - cpu: 10m - ports: - - containerPort: 8500 - name: http - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: consul-service - namespace: higress-conformance-app-backend - labels: - name: consul-standlone -spec: - clusterIP: None - ports: - - name: http-query - port: 8500 - protocol: TCP - targetPort: 8500 - selector: - name: consul-standlone ---- -apiVersion: v1 -kind: Pod -metadata: - name: httpbin - namespace: higress-conformance-app-backend -spec: - containers: - - name: httpbin - image: registry.cn-hangzhou.aliyuncs.com/2456868764/httpbin:1.0.2 - command: - - /app/httpbin - - --registry-type=consul - - --consul-server-address=consul-service:8500 - - --server-port=8080 - - --service-tags=higress,httpbin - env: - - name: SERVICE_NAME - value: httpbin - - name: VERSION - value: v1 - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: POD_IP - valueFrom: - fieldRef: - fieldPath: status.podIP - - name: NODE_NAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName - - name: SERVICE_ACCOUNT - valueFrom: - fieldRef: - fieldPath: spec.serviceAccountName - ports: - - containerPort: 8080 - name: http - protocol: TCP - readinessProbe: - failureThreshold: 5 - httpGet: - path: /ping - port: 8080 - scheme: HTTP - periodSeconds: 20 - successThreshold: 1 - timeoutSeconds: 1 - livenessProbe: - httpGet: - path: /ping - port: 8080 - scheme: HTTP - initialDelaySeconds: 20 - periodSeconds: 20 ---- -# Eureka service registry ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: eureka-cm - namespace: higress-conformance-app-backend -data: - # if you want to deploy n instances of eureka cluster, - # you should set eureka_service_address: http://eureka-0.eureka:8761/eureka,...,http://eureka-(n-1).eureka:8761/eureka - eureka_service_address: "http://eureka-0.eureka.higress-conformance-app-backend.svc:8761/eureka" ---- -apiVersion: v1 -kind: Service -metadata: - name: eureka - namespace: higress-conformance-app-backend - labels: - app: eureka -spec: - clusterIP: None - ports: - - port: 8761 - name: eureka - selector: - app: eureka ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: eureka - namespace: higress-conformance-app-backend -spec: - serviceName: eureka - # n instances - replicas: 1 - selector: - matchLabels: - app: eureka - template: - metadata: - labels: - app: eureka - spec: - containers: - - name: eureka - image: bitinit/eureka - ports: - - containerPort: 8761 - name: http - protocol: TCP - resources: - requests: - memory: "500Mi" - cpu: "500m" - env: - - name: EUREKA_SERVER_ADDRESS - valueFrom: - configMapKeyRef: - name: eureka-cm - key: eureka_service_address - - name: ENVIRONMENT - value: "prod" - - name: JVM_OPTS - value: "-Xms1g -Xmx1g" - livenessProbe: - httpGet: - path: / - port: 8761 - initialDelaySeconds: 30 - periodSeconds: 10 - readinessProbe: - httpGet: - path: / - port: 8761 - initialDelaySeconds: 30 - periodSeconds: 10 ---- -apiVersion: v1 -kind: Pod -metadata: - name: eureka-registry-provider - namespace: higress-conformance-app-backend -spec: - containers: - - name: eureka-registry-provider - image: charlie1380/eureka-registry-provider:v0.3.0 - env: - - name: EUREKA_SERVER_ADDRESS - valueFrom: - configMapKeyRef: - name: eureka-cm - key: eureka_service_address - ports: - - containerPort: 8888 - name: http - protocol: TCP - readinessProbe: - failureThreshold: 5 - httpGet: - path: /healthz - port: 8888 - scheme: HTTP - periodSeconds: 1 - diff --git a/test/e2e/conformance/base/nacos.yaml b/test/e2e/conformance/base/nacos.yaml new file mode 100644 index 000000000..459da47d4 --- /dev/null +++ b/test/e2e/conformance/base/nacos.yaml @@ -0,0 +1,49 @@ +# 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. + +# This file contains the base resources that most conformance tests will rely +# on. This includes 3 namespaces along with Gateways, Services and Deployments +# that can be used as backends for routing traffic. The most important +# resources included are the Gateways (all in the higress-conformance-infra +# namespace): +# - same-namespace (only supports route in same ns) +# - all-namespaces (supports routes in all ns) +# - backend-namespaces (supports routes in ns with backend label) + +apiVersion: v1 +kind: Pod +metadata: + name: nacos-standlone-rc3 + namespace: higress-conformance-app-backend + labels: + name: nacos-standlone-rc3 +spec: + containers: + - name: nacos-standlone-rc3 + image: registry.cn-hangzhou.aliyuncs.com/hinsteny/nacos-standlone-rc3:1.0.0-RC3 + ports: + - containerPort: 8848 +--- +apiVersion: v1 +kind: Service +metadata: + name: nacos-standlone-rc3-service + namespace: higress-conformance-app-backend +spec: + selector: + name: nacos-standlone-rc3 + clusterIP: None + ports: + - name: foo # name is not required for single-port Services + port: 8848 diff --git a/test/e2e/conformance/utils/suite/suite.go b/test/e2e/conformance/utils/suite/suite.go index bf6a8eb9d..ba5fe21f3 100644 --- a/test/e2e/conformance/utils/suite/suite.go +++ b/test/e2e/conformance/utils/suite/suite.go @@ -33,7 +33,7 @@ type ConformanceTestSuite struct { IngressClassName string Debug bool Cleanup bool - BaseManifests string + BaseManifests []string Applier kubernetes.Applier SkipTests sets.Set TimeoutConfig config.TimeoutConfig @@ -51,7 +51,7 @@ type Options struct { IngressClassName string Debug bool RoundTripper roundtripper.RoundTripper - BaseManifests string + BaseManifests []string NamespaceLabels map[string]string // Options for wasm extended features WASMOptions @@ -111,8 +111,14 @@ func New(s Options) *ConformanceTestSuite { } // apply defaults - if suite.BaseManifests == "" { - suite.BaseManifests = "base/manifests.yaml" + if suite.BaseManifests == nil { + suite.BaseManifests = []string{ + "base/manifests.yaml", + "base/consul.yaml", + "base/dubbo.yaml", + "base/eureka.yaml", + "base/nacos.yaml", + } } return suite @@ -126,7 +132,10 @@ func (suite *ConformanceTestSuite) Setup(t *testing.T) { suite.Applier.IngressClass = suite.IngressClassName t.Logf("📦 Test Setup: Applying base manifests") - suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, suite.BaseManifests, suite.Cleanup) + + for _, baseManifest := range suite.BaseManifests { + suite.Applier.MustApplyWithCleanup(t, suite.Client, suite.TimeoutConfig, baseManifest, suite.Cleanup) + } t.Logf("📦 Test Setup: Applying programmatic resources") secret := kubernetes.MustCreateSelfSignedCertSecret(t, "higress-conformance-web-backend", "certificate", []string{"*"}) @@ -139,8 +148,6 @@ func (suite *ConformanceTestSuite) Setup(t *testing.T) { "higress-conformance-infra", "higress-conformance-app-backend", "higress-conformance-web-backend", - "nacos-standlone-rc3", - "dubbo-demo-provider", } kubernetes.NamespacesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, namespaces)