44 "bytes"
55 "context"
66 "errors"
7+ "math"
78 "testing"
89
910 "github.com/spf13/cobra"
@@ -139,9 +140,11 @@ func TestRayWorkerGroupsGetRun(t *testing.T) {
139140 Spec : rayv1.RayClusterSpec {
140141 WorkerGroupSpecs : []rayv1.WorkerGroupSpec {
141142 {
142- GroupName : "group-1" ,
143- Replicas : ptr .To (int32 (1 )),
144- Template : podTemplate ,
143+ GroupName : "group-1" ,
144+ Replicas : ptr .To (int32 (1 )),
145+ MinReplicas : ptr .To (int32 (1 )),
146+ MaxReplicas : ptr .To (int32 (5 )),
147+ Template : podTemplate ,
145148 },
146149 },
147150 },
@@ -154,9 +157,11 @@ func TestRayWorkerGroupsGetRun(t *testing.T) {
154157 Spec : rayv1.RayClusterSpec {
155158 WorkerGroupSpecs : []rayv1.WorkerGroupSpec {
156159 {
157- GroupName : "group-2" ,
158- Replicas : ptr .To (int32 (1 )),
159- Template : podTemplate ,
160+ GroupName : "group-2" ,
161+ Replicas : ptr .To (int32 (1 )),
162+ MinReplicas : ptr .To (int32 (0 )),
163+ MaxReplicas : ptr .To (int32 (math .MaxInt32 )),
164+ Template : podTemplate ,
160165 },
161166 },
162167 },
@@ -169,14 +174,18 @@ func TestRayWorkerGroupsGetRun(t *testing.T) {
169174 Spec : rayv1.RayClusterSpec {
170175 WorkerGroupSpecs : []rayv1.WorkerGroupSpec {
171176 {
172- GroupName : "group-1" ,
173- Replicas : ptr .To (int32 (2 )),
174- Template : podTemplate ,
177+ GroupName : "group-1" ,
178+ Replicas : ptr .To (int32 (2 )),
179+ MinReplicas : ptr .To (int32 (1 )),
180+ MaxReplicas : ptr .To (int32 (4 )),
181+ Template : podTemplate ,
175182 },
176183 {
177- GroupName : "group-4" ,
178- Replicas : ptr .To (int32 (0 )),
179- Template : podTemplate ,
184+ GroupName : "group-4" ,
185+ Replicas : ptr .To (int32 (0 )),
186+ MinReplicas : ptr .To (int32 (0 )),
187+ MaxReplicas : ptr .To (int32 (3 )),
188+ Template : podTemplate ,
180189 },
181190 },
182191 },
@@ -263,11 +272,11 @@ func TestRayWorkerGroupsGetRun(t *testing.T) {
263272 allNamespaces : true ,
264273 rayClusters : rayClusters ,
265274 pods : pods ,
266- expected : `NAMESPACE NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
267- namespace-1 group-1 1/1 2 1 1 1Gi cluster-1
268- namespace-1 group-2 1/1 2 1 1 1Gi cluster-2
269- namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
270- namespace-2 group-4 0/0 0 0 0 0 cluster-1
275+ expected : `NAMESPACE NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
276+ namespace-1 group-1 1 5 1 /1 2 1 1 1Gi cluster-1
277+ namespace-1 group-2 0 - 1/1 2 1 1 1Gi cluster-2
278+ namespace-2 group-1 1 4 1 /2 4 2 2 2Gi cluster-1
279+ namespace-2 group-4 0 3 0 /0 0 0 0 0 cluster-1
271280` ,
272281 },
273282 {
@@ -279,10 +288,10 @@ namespace-2 group-4 0/0 0 0 0 0 cluster-1
279288 // See https://github.com/kubernetes/client-go/issues/326
280289 rayClusters : []runtime.Object {rayClusters [0 ], rayClusters [2 ]},
281290 pods : pods ,
282- expected : `NAMESPACE NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
283- namespace-1 group-1 1/1 2 1 1 1Gi cluster-1
284- namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
285- namespace-2 group-4 0/0 0 0 0 0 cluster-1
291+ expected : `NAMESPACE NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
292+ namespace-1 group-1 1 5 1 /1 2 1 1 1Gi cluster-1
293+ namespace-2 group-1 1 4 1 /2 4 2 2 2Gi cluster-1
294+ namespace-2 group-4 0 3 0 /0 0 0 0 0 cluster-1
286295` ,
287296 },
288297 {
@@ -291,9 +300,9 @@ namespace-2 group-4 0/0 0 0 0 0 cluster-1
291300 allNamespaces : false ,
292301 rayClusters : rayClusters ,
293302 pods : pods ,
294- expected : `NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
295- group-1 1/1 2 1 1 1Gi cluster-1
296- group-2 1/1 2 1 1 1Gi cluster-2
303+ expected : `NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
304+ group-1 1 5 1 /1 2 1 1 1Gi cluster-1
305+ group-2 0 - 1/1 2 1 1 1Gi cluster-2
297306` ,
298307 },
299308 {
@@ -306,8 +315,8 @@ group-2 1/1 2 1 1 1Gi cluster-2
306315 // See https://github.com/kubernetes/client-go/issues/326
307316 rayClusters : rayClusters [:1 ],
308317 pods : pods ,
309- expected : `NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
310- group-1 1/1 2 1 1 1Gi cluster-1
318+ expected : `NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
319+ group-1 1 5 1 /1 2 1 1 1Gi cluster-1
311320` ,
312321 },
313322 {
@@ -316,9 +325,9 @@ group-1 1/1 2 1 1 1Gi cluster-1
316325 workerGroup : "group-1" ,
317326 rayClusters : rayClusters ,
318327 pods : pods ,
319- expected : `NAMESPACE NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
320- namespace-1 group-1 1/1 2 1 1 1Gi cluster-1
321- namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
328+ expected : `NAMESPACE NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
329+ namespace-1 group-1 1 5 1 /1 2 1 1 1Gi cluster-1
330+ namespace-2 group-1 1 4 1 /2 4 2 2 2Gi cluster-1
322331` ,
323332 },
324333 {
@@ -331,9 +340,9 @@ namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
331340 // See https://github.com/kubernetes/client-go/issues/326
332341 rayClusters : []runtime.Object {rayClusters [0 ], rayClusters [2 ]},
333342 pods : pods ,
334- expected : `NAMESPACE NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
335- namespace-1 group-1 1/1 2 1 1 1Gi cluster-1
336- namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
343+ expected : `NAMESPACE NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
344+ namespace-1 group-1 1 5 1 /1 2 1 1 1Gi cluster-1
345+ namespace-2 group-1 1 4 1 /2 4 2 2 2Gi cluster-1
337346` ,
338347 },
339348 {
@@ -343,8 +352,8 @@ namespace-2 group-1 1/2 4 2 2 2Gi cluster-1
343352 workerGroup : "group-1" ,
344353 rayClusters : rayClusters ,
345354 pods : pods ,
346- expected : `NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
347- group-1 1/1 2 1 1 1Gi cluster-1
355+ expected : `NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
356+ group-1 1 5 1 /1 2 1 1 1Gi cluster-1
348357` ,
349358 },
350359 {
@@ -358,8 +367,8 @@ group-1 1/1 2 1 1 1Gi cluster-1
358367 // See https://github.com/kubernetes/client-go/issues/326
359368 rayClusters : rayClusters [:1 ],
360369 pods : pods ,
361- expected : `NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
362- group-1 1/1 2 1 1 1Gi cluster-1
370+ expected : `NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
371+ group-1 1 5 1 /1 2 1 1 1Gi cluster-1
363372` ,
364373 },
365374 {
@@ -624,6 +633,7 @@ func TestGetWorkerGroupDetails(t *testing.T) {
624633 namespace : "namespace-1" ,
625634 cluster : "cluster-1" ,
626635 name : "group-1" ,
636+ maxReplicas : math .MaxInt32 ,
627637 readyReplicas : 1 ,
628638 desiredReplicas : 1 ,
629639 totalCPU : * resources .Cpu (),
@@ -635,6 +645,7 @@ func TestGetWorkerGroupDetails(t *testing.T) {
635645 namespace : "namespace-1" ,
636646 cluster : "cluster-2" ,
637647 name : "group-2" ,
648+ maxReplicas : math .MaxInt32 ,
638649 readyReplicas : 1 ,
639650 desiredReplicas : 1 ,
640651 totalCPU : * resources .Cpu (),
@@ -646,6 +657,7 @@ func TestGetWorkerGroupDetails(t *testing.T) {
646657 namespace : "namespace-2" ,
647658 cluster : "cluster-1" ,
648659 name : "group-1" ,
660+ maxReplicas : math .MaxInt32 ,
649661 readyReplicas : 1 ,
650662 desiredReplicas : 1 ,
651663 totalCPU : * resources .Cpu (),
@@ -742,6 +754,8 @@ func TestPrintWorkerGroups(t *testing.T) {
742754 name : "pod-1" ,
743755 readyReplicas : 1 ,
744756 desiredReplicas : 2 ,
757+ minReplicas : 0 ,
758+ maxReplicas : math .MaxInt32 ,
745759 totalCPU : * resources .Cpu (),
746760 totalGPU : * resources .Name (util .ResourceNvidiaGPU , resource .DecimalSI ),
747761 totalTPU : * resources .Name (util .ResourceGoogleTPU , resource .DecimalSI ),
@@ -753,6 +767,8 @@ func TestPrintWorkerGroups(t *testing.T) {
753767 name : "pod-2" ,
754768 readyReplicas : 3 ,
755769 desiredReplicas : 3 ,
770+ minReplicas : 1 ,
771+ maxReplicas : 5 ,
756772 totalCPU : * resources .Cpu (),
757773 totalGPU : * resources .Name (util .ResourceNvidiaGPU , resource .DecimalSI ),
758774 totalTPU : * resources .Name (util .ResourceGoogleTPU , resource .DecimalSI ),
@@ -768,17 +784,17 @@ func TestPrintWorkerGroups(t *testing.T) {
768784 {
769785 name : "one namespace" ,
770786 allNamespaces : false ,
771- expected : `NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
772- pod-1 1/2 1 1 1 1Gi cluster-1
773- pod-2 3/3 1 1 1 1Gi cluster-2
787+ expected : `NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
788+ pod-1 0 - 1/2 1 1 1 1Gi cluster-1
789+ pod-2 1 5 3/3 1 1 1 1Gi cluster-2
774790` ,
775791 },
776792 {
777793 name : "all namespaces" ,
778794 allNamespaces : true ,
779- expected : `NAMESPACE NAME REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
780- namespace-1 pod-1 1/2 1 1 1 1Gi cluster-1
781- namespace-2 pod-2 3/3 1 1 1 1Gi cluster-2
795+ expected : `NAMESPACE NAME MIN MAX REPLICAS CPUS GPUS TPUS MEMORY CLUSTER
796+ namespace-1 pod-1 0 - 1/2 1 1 1 1Gi cluster-1
797+ namespace-2 pod-2 1 5 3/3 1 1 1 1Gi cluster-2
782798` ,
783799 },
784800 }
0 commit comments