66
77 . "github.com/onsi/gomega"
88 appsv1 "k8s.io/api/apps/v1"
9+ autoscalingv2 "k8s.io/api/autoscaling/v2"
910 corev1 "k8s.io/api/core/v1"
1011 rbacv1 "k8s.io/api/rbac/v1"
1112 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -195,6 +196,24 @@ func TestRegisterResourceInGatewayConfig(t *testing.T) {
195196 // clear out resources before next test
196197 store .deleteResourcesForGateway (nsName )
197198
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+
198217 // Role
199218 role := & rbacv1.Role {ObjectMeta : defaultMeta }
200219 resources = registerAndGetResources (role )
@@ -478,6 +497,10 @@ func TestGatewayExistsForResource(t *testing.T) {
478497 Name : "test-serviceaccount" ,
479498 Namespace : "default" ,
480499 },
500+ HPA : metav1.ObjectMeta {
501+ Name : "test-hpa" ,
502+ Namespace : "default" ,
503+ },
481504 Role : metav1.ObjectMeta {
482505 Name : "test-role" ,
483506 Namespace : "default" ,
@@ -567,6 +590,16 @@ func TestGatewayExistsForResource(t *testing.T) {
567590 },
568591 expected : gateway ,
569592 },
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+ },
570603 {
571604 name : "Role exists" ,
572605 object : & rbacv1.Role {
@@ -716,57 +749,62 @@ func TestGetResourceVersionForObject(t *testing.T) {
716749 Namespace : "default" ,
717750 ResourceVersion : "4" ,
718751 },
752+ HPA : metav1.ObjectMeta {
753+ Name : "test-hpa" ,
754+ Namespace : "default" ,
755+ ResourceVersion : "5" ,
756+ },
719757 Role : metav1.ObjectMeta {
720758 Name : "test-role" ,
721759 Namespace : "default" ,
722- ResourceVersion : "5 " ,
760+ ResourceVersion : "6 " ,
723761 },
724762 RoleBinding : metav1.ObjectMeta {
725763 Name : "test-rolebinding" ,
726764 Namespace : "default" ,
727- ResourceVersion : "6 " ,
765+ ResourceVersion : "7 " ,
728766 },
729767 BootstrapConfigMap : metav1.ObjectMeta {
730768 Name : "test-bootstrap-configmap" ,
731769 Namespace : "default" ,
732- ResourceVersion : "7 " ,
770+ ResourceVersion : "8 " ,
733771 },
734772 AgentConfigMap : metav1.ObjectMeta {
735773 Name : "test-agent-configmap" ,
736774 Namespace : "default" ,
737- ResourceVersion : "8 " ,
775+ ResourceVersion : "9 " ,
738776 },
739777 AgentTLSSecret : metav1.ObjectMeta {
740778 Name : "test-agent-tls-secret" ,
741779 Namespace : "default" ,
742- ResourceVersion : "9 " ,
780+ ResourceVersion : "10 " ,
743781 },
744782 PlusJWTSecret : metav1.ObjectMeta {
745783 Name : "test-jwt-secret" ,
746784 Namespace : "default" ,
747- ResourceVersion : "10 " ,
785+ ResourceVersion : "11 " ,
748786 },
749787 PlusCASecret : metav1.ObjectMeta {
750788 Name : "test-ca-secret" ,
751789 Namespace : "default" ,
752- ResourceVersion : "11 " ,
790+ ResourceVersion : "12 " ,
753791 },
754792 PlusClientSSLSecret : metav1.ObjectMeta {
755793 Name : "test-client-ssl-secret" ,
756794 Namespace : "default" ,
757- ResourceVersion : "12 " ,
795+ ResourceVersion : "13 " ,
758796 },
759797 DockerSecrets : []metav1.ObjectMeta {
760798 {
761799 Name : "test-docker-secret" ,
762800 Namespace : "default" ,
763- ResourceVersion : "13 " ,
801+ ResourceVersion : "14 " ,
764802 },
765803 },
766804 DataplaneKeySecret : metav1.ObjectMeta {
767805 Name : "test-dataplane-key-secret" ,
768806 Namespace : "default" ,
769- ResourceVersion : "14 " ,
807+ ResourceVersion : "15 " ,
770808 },
771809 }
772810
@@ -815,6 +853,16 @@ func TestGetResourceVersionForObject(t *testing.T) {
815853 },
816854 expectedResult : "4" ,
817855 },
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+ },
818866 {
819867 name : "Role resource version" ,
820868 object : & rbacv1.Role {
@@ -823,7 +871,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
823871 Namespace : "default" ,
824872 },
825873 },
826- expectedResult : "5 " ,
874+ expectedResult : "6 " ,
827875 },
828876 {
829877 name : "RoleBinding resource version" ,
@@ -833,7 +881,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
833881 Namespace : "default" ,
834882 },
835883 },
836- expectedResult : "6 " ,
884+ expectedResult : "7 " ,
837885 },
838886 {
839887 name : "Bootstrap ConfigMap resource version" ,
@@ -843,7 +891,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
843891 Namespace : "default" ,
844892 },
845893 },
846- expectedResult : "7 " ,
894+ expectedResult : "8 " ,
847895 },
848896 {
849897 name : "Agent ConfigMap resource version" ,
@@ -853,7 +901,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
853901 Namespace : "default" ,
854902 },
855903 },
856- expectedResult : "8 " ,
904+ expectedResult : "9 " ,
857905 },
858906 {
859907 name : "Agent TLS Secret resource version" ,
@@ -863,7 +911,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
863911 Namespace : "default" ,
864912 },
865913 },
866- expectedResult : "9 " ,
914+ expectedResult : "10 " ,
867915 },
868916 {
869917 name : "JWT Secret resource version" ,
@@ -873,7 +921,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
873921 Namespace : "default" ,
874922 },
875923 },
876- expectedResult : "10 " ,
924+ expectedResult : "11 " ,
877925 },
878926 {
879927 name : "CA Secret resource version" ,
@@ -883,7 +931,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
883931 Namespace : "default" ,
884932 },
885933 },
886- expectedResult : "11 " ,
934+ expectedResult : "12 " ,
887935 },
888936 {
889937 name : "Client SSL Secret resource version" ,
@@ -893,7 +941,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
893941 Namespace : "default" ,
894942 },
895943 },
896- expectedResult : "12 " ,
944+ expectedResult : "13 " ,
897945 },
898946 {
899947 name : "Docker Secret resource version" ,
@@ -903,7 +951,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
903951 Namespace : "default" ,
904952 },
905953 },
906- expectedResult : "13 " ,
954+ expectedResult : "14 " ,
907955 },
908956 {
909957 name : "Dataplane Key Secret resource version" ,
@@ -913,7 +961,7 @@ func TestGetResourceVersionForObject(t *testing.T) {
913961 Namespace : "default" ,
914962 },
915963 },
916- expectedResult : "14 " ,
964+ expectedResult : "15 " ,
917965 },
918966 {
919967 name : "Non-existent resource" ,
0 commit comments