6
6
7
7
. "github.com/onsi/gomega"
8
8
appsv1 "k8s.io/api/apps/v1"
9
+ autoscalingv2 "k8s.io/api/autoscaling/v2"
9
10
corev1 "k8s.io/api/core/v1"
10
11
rbacv1 "k8s.io/api/rbac/v1"
11
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -195,6 +196,24 @@ func TestRegisterResourceInGatewayConfig(t *testing.T) {
195
196
// clear out resources before next test
196
197
store .deleteResourcesForGateway (nsName )
197
198
199
+ // HPA
200
+ hpa := & autoscalingv2.HorizontalPodAutoscaler {ObjectMeta : defaultMeta }
201
+ resources = registerAndGetResources (hpa )
202
+ g .Expect (resources .HPA ).To (Equal (defaultMeta ))
203
+
204
+ // HPA again, already exists
205
+ resources = registerAndGetResources (hpa )
206
+ g .Expect (resources .HPA ).To (Equal (defaultMeta ))
207
+
208
+ // clear out resources before next test
209
+ store .deleteResourcesForGateway (nsName )
210
+
211
+ resources = registerAndGetResources (svc )
212
+ g .Expect (resources .Service ).To (Equal (defaultMeta ))
213
+
214
+ // clear out resources before next test
215
+ store .deleteResourcesForGateway (nsName )
216
+
198
217
// Role
199
218
role := & rbacv1.Role {ObjectMeta : defaultMeta }
200
219
resources = registerAndGetResources (role )
@@ -478,6 +497,10 @@ func TestGatewayExistsForResource(t *testing.T) {
478
497
Name : "test-serviceaccount" ,
479
498
Namespace : "default" ,
480
499
},
500
+ HPA : metav1.ObjectMeta {
501
+ Name : "test-hpa" ,
502
+ Namespace : "default" ,
503
+ },
481
504
Role : metav1.ObjectMeta {
482
505
Name : "test-role" ,
483
506
Namespace : "default" ,
@@ -567,6 +590,16 @@ func TestGatewayExistsForResource(t *testing.T) {
567
590
},
568
591
expected : gateway ,
569
592
},
593
+ {
594
+ name : "HPA exists" ,
595
+ object : & autoscalingv2.HorizontalPodAutoscaler {
596
+ ObjectMeta : metav1.ObjectMeta {
597
+ Name : "test-hpa" ,
598
+ Namespace : "default" ,
599
+ },
600
+ },
601
+ expected : gateway ,
602
+ },
570
603
{
571
604
name : "Role exists" ,
572
605
object : & rbacv1.Role {
@@ -716,57 +749,62 @@ func TestGetResourceVersionForObject(t *testing.T) {
716
749
Namespace : "default" ,
717
750
ResourceVersion : "4" ,
718
751
},
752
+ HPA : metav1.ObjectMeta {
753
+ Name : "test-hpa" ,
754
+ Namespace : "default" ,
755
+ ResourceVersion : "5" ,
756
+ },
719
757
Role : metav1.ObjectMeta {
720
758
Name : "test-role" ,
721
759
Namespace : "default" ,
722
- ResourceVersion : "5 " ,
760
+ ResourceVersion : "6 " ,
723
761
},
724
762
RoleBinding : metav1.ObjectMeta {
725
763
Name : "test-rolebinding" ,
726
764
Namespace : "default" ,
727
- ResourceVersion : "6 " ,
765
+ ResourceVersion : "7 " ,
728
766
},
729
767
BootstrapConfigMap : metav1.ObjectMeta {
730
768
Name : "test-bootstrap-configmap" ,
731
769
Namespace : "default" ,
732
- ResourceVersion : "7 " ,
770
+ ResourceVersion : "8 " ,
733
771
},
734
772
AgentConfigMap : metav1.ObjectMeta {
735
773
Name : "test-agent-configmap" ,
736
774
Namespace : "default" ,
737
- ResourceVersion : "8 " ,
775
+ ResourceVersion : "9 " ,
738
776
},
739
777
AgentTLSSecret : metav1.ObjectMeta {
740
778
Name : "test-agent-tls-secret" ,
741
779
Namespace : "default" ,
742
- ResourceVersion : "9 " ,
780
+ ResourceVersion : "10 " ,
743
781
},
744
782
PlusJWTSecret : metav1.ObjectMeta {
745
783
Name : "test-jwt-secret" ,
746
784
Namespace : "default" ,
747
- ResourceVersion : "10 " ,
785
+ ResourceVersion : "11 " ,
748
786
},
749
787
PlusCASecret : metav1.ObjectMeta {
750
788
Name : "test-ca-secret" ,
751
789
Namespace : "default" ,
752
- ResourceVersion : "11 " ,
790
+ ResourceVersion : "12 " ,
753
791
},
754
792
PlusClientSSLSecret : metav1.ObjectMeta {
755
793
Name : "test-client-ssl-secret" ,
756
794
Namespace : "default" ,
757
- ResourceVersion : "12 " ,
795
+ ResourceVersion : "13 " ,
758
796
},
759
797
DockerSecrets : []metav1.ObjectMeta {
760
798
{
761
799
Name : "test-docker-secret" ,
762
800
Namespace : "default" ,
763
- ResourceVersion : "13 " ,
801
+ ResourceVersion : "14 " ,
764
802
},
765
803
},
766
804
DataplaneKeySecret : metav1.ObjectMeta {
767
805
Name : "test-dataplane-key-secret" ,
768
806
Namespace : "default" ,
769
- ResourceVersion : "14 " ,
807
+ ResourceVersion : "15 " ,
770
808
},
771
809
}
772
810
@@ -815,6 +853,16 @@ func TestGetResourceVersionForObject(t *testing.T) {
815
853
},
816
854
expectedResult : "4" ,
817
855
},
856
+ {
857
+ name : "HPA resource version" ,
858
+ object : & autoscalingv2.HorizontalPodAutoscaler {
859
+ ObjectMeta : metav1.ObjectMeta {
860
+ Name : "test-hpa" ,
861
+ Namespace : "default" ,
862
+ },
863
+ },
864
+ expectedResult : "5" ,
865
+ },
818
866
{
819
867
name : "Role resource version" ,
820
868
object : & rbacv1.Role {
@@ -823,7 +871,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
823
871
Namespace : "default" ,
824
872
},
825
873
},
826
- expectedResult : "5 " ,
874
+ expectedResult : "6 " ,
827
875
},
828
876
{
829
877
name : "RoleBinding resource version" ,
@@ -833,7 +881,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
833
881
Namespace : "default" ,
834
882
},
835
883
},
836
- expectedResult : "6 " ,
884
+ expectedResult : "7 " ,
837
885
},
838
886
{
839
887
name : "Bootstrap ConfigMap resource version" ,
@@ -843,7 +891,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
843
891
Namespace : "default" ,
844
892
},
845
893
},
846
- expectedResult : "7 " ,
894
+ expectedResult : "8 " ,
847
895
},
848
896
{
849
897
name : "Agent ConfigMap resource version" ,
@@ -853,7 +901,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
853
901
Namespace : "default" ,
854
902
},
855
903
},
856
- expectedResult : "8 " ,
904
+ expectedResult : "9 " ,
857
905
},
858
906
{
859
907
name : "Agent TLS Secret resource version" ,
@@ -863,7 +911,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
863
911
Namespace : "default" ,
864
912
},
865
913
},
866
- expectedResult : "9 " ,
914
+ expectedResult : "10 " ,
867
915
},
868
916
{
869
917
name : "JWT Secret resource version" ,
@@ -873,7 +921,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
873
921
Namespace : "default" ,
874
922
},
875
923
},
876
- expectedResult : "10 " ,
924
+ expectedResult : "11 " ,
877
925
},
878
926
{
879
927
name : "CA Secret resource version" ,
@@ -883,7 +931,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
883
931
Namespace : "default" ,
884
932
},
885
933
},
886
- expectedResult : "11 " ,
934
+ expectedResult : "12 " ,
887
935
},
888
936
{
889
937
name : "Client SSL Secret resource version" ,
@@ -893,7 +941,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
893
941
Namespace : "default" ,
894
942
},
895
943
},
896
- expectedResult : "12 " ,
944
+ expectedResult : "13 " ,
897
945
},
898
946
{
899
947
name : "Docker Secret resource version" ,
@@ -903,7 +951,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
903
951
Namespace : "default" ,
904
952
},
905
953
},
906
- expectedResult : "13 " ,
954
+ expectedResult : "14 " ,
907
955
},
908
956
{
909
957
name : "Dataplane Key Secret resource version" ,
@@ -913,7 +961,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
913
961
Namespace : "default" ,
914
962
},
915
963
},
916
- expectedResult : "14 " ,
964
+ expectedResult : "15 " ,
917
965
},
918
966
{
919
967
name : "Non-existent resource" ,
0 commit comments