@@ -97,35 +97,8 @@ var _ = Describe("Storage controller medium tests", func() {
9797 },
9898 })
9999
100- storageSample .Spec .Service .GRPC .AdditionalPort = 2136
101-
102100 Expect (k8sClient .Create (ctx , storageSample )).Should (Succeed ())
103101
104- By ("Check grpc service has an additional port..." , func () {
105- var svc corev1.Service
106- serviceName := fmt .Sprintf ("%v-grpc" , testobjects .StorageName )
107- Eventually (func () bool {
108- err := k8sClient .Get (ctx ,
109- client.ObjectKey {
110- Name : serviceName ,
111- Namespace : testobjects .YdbNamespace ,
112- },
113- & svc ,
114- )
115- return err == nil
116- }, test .Timeout , test .Interval ).Should (BeTrue (),
117- "Service %s/%s should eventually exist" , testobjects .YdbNamespace , serviceName ,
118- )
119-
120- ports := svc .Spec .Ports
121- Expect (len (ports )).To (Equal (2 ), "expected 2 ports but got %d" , len (ports ))
122- Expect (ports [0 ].Port ).To (Equal (int32 (2135 )))
123- Expect (ports [0 ].Name ).To (Equal (v1alpha1 .GRPCServicePortName ))
124- Expect (ports [1 ].Port ).To (Equal (int32 (2136 )))
125- Expect (ports [1 ].Name ).To (Equal (v1alpha1 .GRPCServiceAdditionalPortName ))
126- Expect (ports [1 ].TargetPort .IntVal ).To (Equal (int32 (2136 )))
127- })
128-
129102 By ("Check volume has been propagated to pods..." )
130103 storageStatefulSets := appsv1.StatefulSetList {}
131104 Eventually (func () bool {
@@ -332,5 +305,80 @@ var _ = Describe("Storage controller medium tests", func() {
332305 By ("check that --auth-token-file arg was added to Statefulset template..." )
333306 Eventually (checkAuthTokenArgs , test .Timeout , test .Interval ).ShouldNot (HaveOccurred ())
334307 })
308+
309+ By ("Checking overriding port value in GRPC Service..." , func () {
310+ storage := v1alpha1.Storage {}
311+ Expect (k8sClient .Get (ctx , types.NamespacedName {
312+ Name : testobjects .StorageName ,
313+ Namespace : testobjects .YdbNamespace ,
314+ }, & storage )).Should (Succeed ())
315+
316+ storage .Spec .Service .GRPC .Port = 2137
317+
318+ Expect (k8sClient .Update (ctx , & storage )).Should (Succeed ())
319+
320+ var svc corev1.Service
321+ serviceName := fmt .Sprintf ("%v-grpc" , testobjects .StorageName )
322+
323+ Eventually (func (g Gomega ) bool {
324+ err := k8sClient .Get (ctx ,
325+ client.ObjectKey {
326+ Name : serviceName ,
327+ Namespace : testobjects .YdbNamespace ,
328+ },
329+ & svc ,
330+ )
331+ if err != nil {
332+ return false
333+ }
334+
335+ ports := svc .Spec .Ports
336+ g .Expect (len (ports )).To (Equal (1 ), "expected 1 port but got %d" , len (ports ))
337+ g .Expect (ports [0 ].Name ).To (Equal (v1alpha1 .GRPCServicePortName ))
338+ g .Expect (ports [0 ].Port ).To (Equal (storage .Spec .Service .GRPC .Port ))
339+ return true
340+ }, test .Timeout , test .Interval ).Should (BeTrue (),
341+ "Service %s/%s should eventually have proper ports" , testobjects .YdbNamespace , serviceName ,
342+ )
343+ })
344+
345+ By ("Checking additionalPort propagation in GRPC Service..." , func () {
346+ storage := v1alpha1.Storage {}
347+ Expect (k8sClient .Get (ctx , types.NamespacedName {
348+ Name : testobjects .StorageName ,
349+ Namespace : testobjects .YdbNamespace ,
350+ }, & storage )).Should (Succeed ())
351+
352+ storage .Spec .Service .GRPC .Port = 2135
353+ storage .Spec .Service .GRPC .AdditionalPort = 2136
354+
355+ Expect (k8sClient .Update (ctx , & storage )).Should (Succeed ())
356+
357+ var svc corev1.Service
358+ serviceName := fmt .Sprintf ("%v-grpc" , testobjects .StorageName )
359+ Eventually (func (g Gomega ) error {
360+ err := k8sClient .Get (ctx ,
361+ client.ObjectKey {
362+ Name : serviceName ,
363+ Namespace : testobjects .YdbNamespace ,
364+ },
365+ & svc ,
366+ )
367+ if err != nil {
368+ return err
369+ }
370+
371+ ports := svc .Spec .Ports
372+ g .Expect (len (ports )).To (Equal (2 ), "expected 2 ports but got %d" , len (ports ))
373+ g .Expect (ports [0 ].Port ).To (Equal (int32 (2135 )))
374+ g .Expect (ports [0 ].Name ).To (Equal (v1alpha1 .GRPCServicePortName ))
375+ g .Expect (ports [1 ].Port ).To (Equal (storage .Spec .Service .GRPC .AdditionalPort ))
376+ g .Expect (ports [1 ].Name ).To (Equal (v1alpha1 .GRPCServiceAdditionalPortName ))
377+ g .Expect (ports [1 ].TargetPort .IntVal ).To (Equal (storage .Spec .Service .GRPC .AdditionalPort ))
378+ return nil
379+ }, test .Timeout , test .Interval ).Should (Succeed (),
380+ "Service %s/%s should eventually have proper ports" , testobjects .YdbNamespace , serviceName ,
381+ )
382+ })
335383 })
336384})
0 commit comments