|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +suite: GRPCRoute replica routing |
| 5 | +templates: |
| 6 | + - templates/grpcroute.yaml |
| 7 | + - templates/replica-services.yaml |
| 8 | + - templates/gateway-config.yaml |
| 9 | + - templates/statefulset.yaml |
| 10 | +release: |
| 11 | + name: openshell |
| 12 | + namespace: my-namespace |
| 13 | +set: |
| 14 | + grpcRoute.enabled: true |
| 15 | + replicaCount: 2 |
| 16 | + workload.allowMultiReplicaStatefulSet: true |
| 17 | + server.externalDbSecret: db |
| 18 | + |
| 19 | +tests: |
| 20 | + - it: routes every request to the shared Service by default |
| 21 | + template: templates/grpcroute.yaml |
| 22 | + asserts: |
| 23 | + - lengthEqual: |
| 24 | + path: spec.rules |
| 25 | + count: 1 |
| 26 | + - equal: |
| 27 | + path: spec.rules[0].backendRefs[0].name |
| 28 | + value: openshell |
| 29 | + |
| 30 | + - it: renders no per-replica Services by default |
| 31 | + template: templates/replica-services.yaml |
| 32 | + asserts: |
| 33 | + - hasDocuments: |
| 34 | + count: 0 |
| 35 | + |
| 36 | + - it: renders when values from an older release have no replicaRouting key |
| 37 | + template: templates/grpcroute.yaml |
| 38 | + set: |
| 39 | + grpcRoute.replicaRouting: null |
| 40 | + asserts: |
| 41 | + - lengthEqual: |
| 42 | + path: spec.rules |
| 43 | + count: 1 |
| 44 | + |
| 45 | + - it: routes a named replica to its own Service ahead of the shared rule |
| 46 | + template: templates/grpcroute.yaml |
| 47 | + set: |
| 48 | + grpcRoute.replicaRouting.enabled: true |
| 49 | + asserts: |
| 50 | + - lengthEqual: |
| 51 | + path: spec.rules |
| 52 | + count: 3 |
| 53 | + - equal: |
| 54 | + path: spec.rules[1].matches[0].headers[0] |
| 55 | + value: |
| 56 | + type: Exact |
| 57 | + name: x-openshell-replica |
| 58 | + value: openshell-1 |
| 59 | + - equal: |
| 60 | + path: spec.rules[1].backendRefs[0].name |
| 61 | + value: openshell-replica-1 |
| 62 | + - equal: |
| 63 | + path: spec.rules[2].backendRefs[0].name |
| 64 | + value: openshell |
| 65 | + |
| 66 | + - it: selects exactly one pod per replica Service |
| 67 | + template: templates/replica-services.yaml |
| 68 | + set: |
| 69 | + grpcRoute.replicaRouting.enabled: true |
| 70 | + asserts: |
| 71 | + - hasDocuments: |
| 72 | + count: 2 |
| 73 | + - equal: |
| 74 | + path: metadata.name |
| 75 | + value: openshell-replica-1 |
| 76 | + documentIndex: 1 |
| 77 | + - equal: |
| 78 | + path: spec.selector["statefulset.kubernetes.io/pod-name"] |
| 79 | + value: openshell-1 |
| 80 | + documentIndex: 1 |
| 81 | + |
| 82 | + - it: routes every replica the autoscaler can create |
| 83 | + template: templates/grpcroute.yaml |
| 84 | + set: |
| 85 | + grpcRoute.replicaRouting.enabled: true |
| 86 | + autoscaling.enabled: true |
| 87 | + resources.requests.cpu: 100m |
| 88 | + asserts: |
| 89 | + - lengthEqual: |
| 90 | + path: spec.rules |
| 91 | + count: 5 |
| 92 | + |
| 93 | + - it: caps autoscaled replica routing at 15 replicas |
| 94 | + template: templates/statefulset.yaml |
| 95 | + set: |
| 96 | + grpcRoute.replicaRouting.enabled: true |
| 97 | + autoscaling.enabled: true |
| 98 | + autoscaling.maxReplicas: 16 |
| 99 | + resources.requests.cpu: 100m |
| 100 | + asserts: |
| 101 | + - failedTemplate: |
| 102 | + errorMessage: "grpcRoute.replicaRouting.enabled supports autoscaling.maxReplicas of at most 15; a GRPCRoute holds at most 16 rules." |
| 103 | + |
| 104 | + - it: requires a StatefulSet for stable replica names |
| 105 | + template: templates/statefulset.yaml |
| 106 | + set: |
| 107 | + grpcRoute.replicaRouting.enabled: true |
| 108 | + workload.kind: deployment |
| 109 | + asserts: |
| 110 | + - failedTemplate: |
| 111 | + errorMessage: "grpcRoute.replicaRouting.enabled requires workload.kind=statefulset so each replica has a stable name." |
0 commit comments