@@ -382,6 +382,13 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
382
382
"vultr.com/label1": "value1",
383
383
"vultr.com/label2": "value2"
384
384
},
385
+ "taints": [
386
+ {
387
+ "key": "gpu",
388
+ "value": "test",
389
+ "effect": "NoSchedule"
390
+ }
391
+ ],
385
392
"nodes": [
386
393
{
387
394
"id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
@@ -404,6 +411,13 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
404
411
"vultr.com/label1" : "value1" ,
405
412
"vultr.com/label2" : "value2" ,
406
413
},
414
+ Taints : []Taint {
415
+ {
416
+ Key : "gpu" ,
417
+ Value : "test" ,
418
+ Effect : "NoSchedule" ,
419
+ },
420
+ },
407
421
}
408
422
np , _ , err := client .Kubernetes .CreateNodePool (ctx , "1" , createReq )
409
423
if err != nil {
@@ -425,6 +439,13 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
425
439
"vultr.com/label1" : "value1" ,
426
440
"vultr.com/label2" : "value2" ,
427
441
},
442
+ Taints : []Taint {
443
+ {
444
+ Key : "gpu" ,
445
+ Value : "test" ,
446
+ Effect : "NoSchedule" ,
447
+ },
448
+ },
428
449
Nodes : []Node {
429
450
{
430
451
ID : "3e1ca1e0-25be-4977-907a-3dee42b9bb15" ,
@@ -464,6 +485,13 @@ func TestKubernetesHandler_GetNodePool(t *testing.T) {
464
485
"max_nodes": 2,
465
486
"auto_scaler": true,
466
487
"tag": "mytag",
488
+ "taints": [
489
+ {
490
+ "key": "gpu",
491
+ "value": "test",
492
+ "effect": "NoSchedule"
493
+ }
494
+ ],
467
495
"nodes": [
468
496
{
469
497
"id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
@@ -493,6 +521,13 @@ func TestKubernetesHandler_GetNodePool(t *testing.T) {
493
521
MinNodes : 1 ,
494
522
MaxNodes : 2 ,
495
523
AutoScaler : true ,
524
+ Taints : []Taint {
525
+ {
526
+ Key : "gpu" ,
527
+ Value : "test" ,
528
+ Effect : "NoSchedule" ,
529
+ },
530
+ },
496
531
Nodes : []Node {
497
532
{
498
533
ID : "3e1ca1e0-25be-4977-907a-3dee42b9bb15" ,
@@ -532,6 +567,13 @@ func TestKubernetesHandler_ListNodePools(t *testing.T) {
532
567
"max_nodes": 2,
533
568
"auto_scaler": true,
534
569
"tag": "mytag",
570
+ "taints": [
571
+ {
572
+ "key": "gpu",
573
+ "value": "test",
574
+ "effect": "NoSchedule"
575
+ }
576
+ ],
535
577
"nodes": [
536
578
{
537
579
"id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
@@ -569,6 +611,13 @@ func TestKubernetesHandler_ListNodePools(t *testing.T) {
569
611
MinNodes : 1 ,
570
612
MaxNodes : 2 ,
571
613
AutoScaler : true ,
614
+ Taints : []Taint {
615
+ {
616
+ Key : "gpu" ,
617
+ Value : "test" ,
618
+ Effect : "NoSchedule" ,
619
+ },
620
+ },
572
621
Nodes : []Node {
573
622
{
574
623
ID : "3e1ca1e0-25be-4977-907a-3dee42b9bb15" ,
@@ -621,6 +670,13 @@ func TestKubernetesHandler_UpdateNodePool(t *testing.T) {
621
670
"max_nodes": 2,
622
671
"auto_scaler": true,
623
672
"tag": "mytag",
673
+ "taints": [
674
+ {
675
+ "key": "gpu",
676
+ "value": "updated-test",
677
+ "effect": "NoSchedule"
678
+ }
679
+ ],
624
680
"nodes": [
625
681
{
626
682
"id": "f2e11430-76e5-4dc6-a1c9-ef5682c21ddf",
@@ -633,7 +689,20 @@ func TestKubernetesHandler_UpdateNodePool(t *testing.T) {
633
689
}`
634
690
fmt .Fprint (writer , response )
635
691
})
636
- update := NodePoolReqUpdate {NodeQuantity : 1 }
692
+
693
+ taints := []Taint {
694
+ {
695
+ Key : "gpu" ,
696
+ Value : "updated-test" ,
697
+ Effect : "NoSchedule" ,
698
+ },
699
+ }
700
+
701
+ update := NodePoolReqUpdate {
702
+ NodeQuantity : 1 ,
703
+ Taints : taints ,
704
+ }
705
+
637
706
response , _ , err := client .Kubernetes .UpdateNodePool (ctx , "1" , "2" , & update )
638
707
if err != nil {
639
708
t .Errorf ("Kubernetes.UpdateNodePool returned %+v" , err )
@@ -651,6 +720,7 @@ func TestKubernetesHandler_UpdateNodePool(t *testing.T) {
651
720
MaxNodes : 2 ,
652
721
AutoScaler : true ,
653
722
Tag : "mytag" ,
723
+ Taints : taints ,
654
724
Nodes : []Node {
655
725
{
656
726
ID : "f2e11430-76e5-4dc6-a1c9-ef5682c21ddf" ,
@@ -810,3 +880,50 @@ func TestKubernetesHandler_Upgrade(t *testing.T) {
810
880
t .Errorf ("Kubernetes.StartUpgrade returned %+v" , err )
811
881
}
812
882
}
883
+
884
+ func TestTaintStructForNodePool (t * testing.T ) {
885
+ setup ()
886
+ defer teardown ()
887
+
888
+ // Test creating a node pool with taints
889
+ taints := []Taint {
890
+ {
891
+ Key : "key1" ,
892
+ Value : "value1" ,
893
+ Effect : "NoSchedule" ,
894
+ },
895
+ {
896
+ Key : "key2" ,
897
+ Value : "value2" ,
898
+ Effect : "NoExecute" ,
899
+ },
900
+ }
901
+
902
+ // Construct a NodePoolReq with taints
903
+ nodePoolReq := & NodePoolReq {
904
+ Taints : taints ,
905
+ }
906
+
907
+ // Test that the taints are properly included in the struct
908
+ if len (nodePoolReq .Taints ) != 2 {
909
+ t .Errorf ("Expected 2 taints in the NodePoolReq struct, got %d" , len (nodePoolReq .Taints ))
910
+ }
911
+
912
+ // Test that the taints values are correct
913
+ if nodePoolReq .Taints [0 ].Key != "key1" || nodePoolReq .Taints [0 ].Value != "value1" || nodePoolReq .Taints [0 ].Effect != "NoSchedule" {
914
+ t .Errorf ("First taint values don't match expected values, got %+v" , nodePoolReq .Taints [0 ])
915
+ }
916
+
917
+ if nodePoolReq .Taints [1 ].Key != "key2" || nodePoolReq .Taints [1 ].Value != "value2" || nodePoolReq .Taints [1 ].Effect != "NoExecute" {
918
+ t .Errorf ("Second taint values don't match expected values, got %+v" , nodePoolReq .Taints [1 ])
919
+ }
920
+
921
+ // Test NodePoolReqUpdate with taints
922
+ updateReq := & NodePoolReqUpdate {
923
+ Taints : taints ,
924
+ }
925
+
926
+ if len (updateReq .Taints ) != 2 {
927
+ t .Errorf ("Expected 2 taints in the NodePoolReqUpdate struct, got %d" , len (updateReq .Taints ))
928
+ }
929
+ }
0 commit comments