From 96eaaaca954a5253deb79540f168e77b67ac1982 Mon Sep 17 00:00:00 2001 From: zirain Date: Fri, 30 Oct 2026 12:44:50 +0800 Subject: [PATCH] test(gatewayapi): add mergeBackends canary case with a zero-weight backendRef Signed-off-by: zirain --- ...tp-canary-same-service-zero-weight.in.yaml | 83 ++++++++ ...p-canary-same-service-zero-weight.out.yaml | 194 ++++++++++++++++++ 2 files changed, 277 insertions(+) create mode 100644 internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.in.yaml create mode 100644 internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.out.yaml diff --git a/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.in.yaml b/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.in.yaml new file mode 100644 index 0000000000..342dbd7c35 --- /dev/null +++ b/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.in.yaml @@ -0,0 +1,83 @@ +envoyProxyForGatewayClass: + apiVersion: gateway.envoyproxy.io/v1alpha1 + kind: EnvoyProxy + metadata: + namespace: envoy-gateway-system + name: test + spec: + mergeBackends: {} +gateways: + - apiVersion: gateway.networking.k8s.io/v1 + kind: Gateway + metadata: + namespace: envoy-gateway + name: gateway-1 + spec: + gatewayClassName: envoy-gateway-class + listeners: + - name: http + protocol: HTTP + port: 80 + allowedRoutes: + namespaces: + from: All +httpRoutes: + - apiVersion: gateway.networking.k8s.io/v1 + kind: HTTPRoute + metadata: + namespace: default + name: canary + spec: + parentRefs: + - namespace: envoy-gateway + name: gateway-1 + rules: + - matches: + - path: + type: PathPrefix + value: /canary + backendRefs: + - name: canary + port: 3000 + weight: 50 + - name: canary + port: 4000 + weight: 0 +services: + - apiVersion: v1 + kind: Service + metadata: + name: canary + namespace: default + spec: + clusterIP: 10.11.12.13 + ports: + - port: 3000 + name: http-v1 + protocol: TCP + targetPort: 3000 + - port: 4000 + name: http-v2 + protocol: TCP + targetPort: 3000 +endpointSlices: + - apiVersion: discovery.k8s.io/v1 + kind: EndpointSlice + metadata: + name: endpointslice-canary + namespace: default + labels: + kubernetes.io/service-name: canary + addressType: IPv4 + ports: + - name: http-v1 + protocol: TCP + port: 3000 + - name: http-v2 + protocol: TCP + port: 3000 + endpoints: + - addresses: + - "10.244.0.11" + conditions: + ready: true diff --git a/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.out.yaml b/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.out.yaml new file mode 100644 index 0000000000..09c9d4dfde --- /dev/null +++ b/internal/gatewayapi/testdata/mergebackends-http-canary-same-service-zero-weight.out.yaml @@ -0,0 +1,194 @@ +gateways: +- apiVersion: gateway.networking.k8s.io/v1 + kind: Gateway + metadata: + name: gateway-1 + namespace: envoy-gateway + spec: + gatewayClassName: envoy-gateway-class + listeners: + - allowedRoutes: + namespaces: + from: All + name: http + port: 80 + protocol: HTTP + status: + listeners: + - attachedRoutes: 1 + conditions: + - lastTransitionTime: null + message: Sending translated listener configuration to the data plane + reason: Programmed + status: "True" + type: Programmed + - lastTransitionTime: null + message: Listener has been successfully translated + reason: Accepted + status: "True" + type: Accepted + - lastTransitionTime: null + message: Listener references have been resolved + reason: ResolvedRefs + status: "True" + type: ResolvedRefs + name: http + supportedKinds: + - group: gateway.networking.k8s.io + kind: HTTPRoute + - group: gateway.networking.k8s.io + kind: GRPCRoute +httpRoutes: +- apiVersion: gateway.networking.k8s.io/v1 + kind: HTTPRoute + metadata: + name: canary + namespace: default + spec: + parentRefs: + - name: gateway-1 + namespace: envoy-gateway + rules: + - backendRefs: + - name: canary + port: 3000 + weight: 50 + - name: canary + port: 4000 + weight: 0 + matches: + - path: + type: PathPrefix + value: /canary + status: + parents: + - conditions: + - lastTransitionTime: null + message: Route is accepted + reason: Accepted + status: "True" + type: Accepted + - lastTransitionTime: null + message: Resolved all the Object references for the Route + reason: ResolvedRefs + status: "True" + type: ResolvedRefs + controllerName: gateway.envoyproxy.io/gatewayclass-controller + parentRef: + name: gateway-1 + namespace: envoy-gateway +infraIR: + envoy-gateway/gateway-1: + proxy: + config: + apiVersion: gateway.envoyproxy.io/v1alpha1 + kind: EnvoyProxy + metadata: + name: test + namespace: envoy-gateway-system + spec: + logging: {} + mergeBackends: {} + status: {} + listeners: + - name: envoy-gateway/gateway-1/http + ports: + - containerPort: 10080 + name: http-80 + protocol: HTTP + servicePort: 80 + metadata: + labels: + gateway.envoyproxy.io/owning-gateway-name: gateway-1 + gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway + ownerReference: + kind: GatewayClass + name: envoy-gateway-class + name: envoy-gateway/gateway-1 + namespace: envoy-gateway-system +xdsIR: + envoy-gateway/gateway-1: + accessLog: + json: + - path: /dev/stdout + backendClusters: + - metadata: + kind: Service + name: canary + namespace: default + sectionName: "3000" + name: service/default/canary/3000/http + setting: + addressType: IP + endpoints: + - host: 10.244.0.11 + port: 3000 + metadata: + kind: Service + name: canary + namespace: default + sectionName: "3000" + name: service/default/canary/3000/http + protocol: HTTP + globalResources: + proxyServiceCluster: + metadata: + kind: Service + name: envoy-envoy-gateway-gateway-1-196ae069 + namespace: envoy-gateway-system + sectionName: "8080" + name: envoy-gateway/gateway-1 + settings: + - addressType: IP + endpoints: + - host: 7.6.5.4 + port: 8080 + zone: zone1 + metadata: + kind: Service + name: envoy-envoy-gateway-gateway-1-196ae069 + namespace: envoy-gateway-system + sectionName: "8080" + name: envoy-gateway/gateway-1 + protocol: TCP + http: + - address: 0.0.0.0 + externalPort: 80 + hostnames: + - '*' + metadata: + kind: Gateway + name: gateway-1 + namespace: envoy-gateway + sectionName: http + name: envoy-gateway/gateway-1/http + path: + escapedSlashesAction: UnescapeAndRedirect + mergeSlashes: true + port: 10080 + routes: + - destination: + backendClusterRefs: + - name: service/default/canary/3000/http + weight: 50 + metadata: + kind: HTTPRoute + name: canary + namespace: default + name: httproute/default/canary/rule/0 + hostname: '*' + isHTTP2: false + metadata: + kind: HTTPRoute + name: canary + namespace: default + name: httproute/default/canary/rule/0/match/0/* + pathMatch: + distinct: false + name: "" + prefix: /canary + readyListener: + address: 0.0.0.0 + ipFamily: IPv4 + path: /ready + port: 19003