@@ -252,64 +252,68 @@ var _ = framework.Describe("[group:ipam]", func() {
252
252
ippoolSep = ","
253
253
}
254
254
255
- replicas := 3
256
- ippool := framework .RandomIPs (cidr , ippoolSep , replicas )
257
- labels := map [string ]string {"app" : stsName }
255
+ for replicas := 1 ; replicas <= 3 ; replicas ++ {
256
+ ippool := framework .RandomIPs (cidr , ippoolSep , replicas )
257
+ labels := map [string ]string {"app" : stsName }
258
258
259
- ginkgo .By ("Creating statefulset " + stsName + " with ippool " + ippool )
260
- sts := framework .MakeStatefulSet (stsName , stsName , int32 (replicas ), labels , framework .PauseImage )
261
- sts .Spec .Template .Annotations = map [string ]string {util .IpPoolAnnotation : ippool }
262
- sts = stsClient .CreateSync (sts )
259
+ ginkgo .By ("Creating statefulset " + stsName + " with ippool " + ippool )
260
+ sts := framework .MakeStatefulSet (stsName , stsName , int32 (replicas ), labels , framework .PauseImage )
261
+ sts .Spec .Template .Annotations = map [string ]string {util .IpPoolAnnotation : ippool }
262
+ sts = stsClient .CreateSync (sts )
263
263
264
- ginkgo .By ("Getting pods for statefulset " + stsName )
265
- pods := stsClient .GetPods (sts )
266
- framework .ExpectHaveLen (pods .Items , replicas )
267
-
268
- ips := make ([]string , 0 , replicas )
269
- for _ , pod := range pods .Items {
270
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .AllocatedAnnotation , "true" )
271
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .CidrAnnotation , subnet .Spec .CIDRBlock )
272
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .GatewayAnnotation , subnet .Spec .Gateway )
273
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpPoolAnnotation , ippool )
274
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .LogicalSwitchAnnotation , subnet .Name )
275
- framework .ExpectMAC (pod .Annotations [util .MacAddressAnnotation ])
276
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .RoutedAnnotation , "true" )
264
+ ginkgo .By ("Getting pods for statefulset " + stsName )
265
+ pods := stsClient .GetPods (sts )
266
+ framework .ExpectHaveLen (pods .Items , replicas )
277
267
278
- podIPs := make ([]string , 0 , len (pod .Status .PodIPs ))
279
- for _ , podIP := range pod .Status .PodIPs {
280
- podIPs = append (podIPs , podIP .IP )
268
+ ips := make ([]string , 0 , replicas )
269
+ for _ , pod := range pods .Items {
270
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .AllocatedAnnotation , "true" )
271
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .CidrAnnotation , subnet .Spec .CIDRBlock )
272
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .GatewayAnnotation , subnet .Spec .Gateway )
273
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpPoolAnnotation , ippool )
274
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .LogicalSwitchAnnotation , subnet .Name )
275
+ framework .ExpectMAC (pod .Annotations [util .MacAddressAnnotation ])
276
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .RoutedAnnotation , "true" )
277
+
278
+ podIPs := make ([]string , 0 , len (pod .Status .PodIPs ))
279
+ for _ , podIP := range pod .Status .PodIPs {
280
+ podIPs = append (podIPs , podIP .IP )
281
+ }
282
+ framework .ExpectConsistOf (podIPs , strings .Split (pod .Annotations [util .IpAddressAnnotation ], "," ))
283
+ ips = append (ips , pod .Annotations [util .IpAddressAnnotation ])
281
284
}
282
- framework .ExpectConsistOf (podIPs , strings .Split (pod .Annotations [util .IpAddressAnnotation ], "," ))
283
- ips = append (ips , pod .Annotations [util .IpAddressAnnotation ])
284
- }
285
- framework .ExpectConsistOf (ips , strings .Split (ippool , ippoolSep ))
286
-
287
- ginkgo .By ("Deleting pods for statefulset " + stsName )
288
- for _ , pod := range pods .Items {
289
- err := podClient .Delete (pod .Name )
290
- framework .ExpectNoError (err , "failed to delete pod " + pod .Name )
291
- }
292
- stsClient .WaitForRunningAndReady (sts )
285
+ framework .ExpectConsistOf (ips , strings .Split (ippool , ippoolSep ))
293
286
294
- ginkgo .By ("Getting pods for statefulset " + stsName )
295
- pods = stsClient .GetPods (sts )
296
- framework .ExpectHaveLen (pods .Items , replicas )
287
+ ginkgo .By ("Deleting pods for statefulset " + stsName )
288
+ for _ , pod := range pods .Items {
289
+ err := podClient .Delete (pod .Name )
290
+ framework .ExpectNoError (err , "failed to delete pod " + pod .Name )
291
+ }
292
+ stsClient .WaitForRunningAndReady (sts )
297
293
298
- for i , pod := range pods .Items {
299
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .AllocatedAnnotation , "true" )
300
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .CidrAnnotation , subnet .Spec .CIDRBlock )
301
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .GatewayAnnotation , subnet .Spec .Gateway )
302
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpPoolAnnotation , ippool )
303
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpAddressAnnotation , ips [i ])
304
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .LogicalSwitchAnnotation , subnet .Name )
305
- framework .ExpectMAC (pod .Annotations [util .MacAddressAnnotation ])
306
- framework .ExpectHaveKeyWithValue (pod .Annotations , util .RoutedAnnotation , "true" )
294
+ ginkgo .By ("Getting pods for statefulset " + stsName )
295
+ pods = stsClient .GetPods (sts )
296
+ framework .ExpectHaveLen (pods .Items , replicas )
307
297
308
- podIPs := make ([]string , 0 , len (pod .Status .PodIPs ))
309
- for _ , podIP := range pod .Status .PodIPs {
310
- podIPs = append (podIPs , podIP .IP )
298
+ for i , pod := range pods .Items {
299
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .AllocatedAnnotation , "true" )
300
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .CidrAnnotation , subnet .Spec .CIDRBlock )
301
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .GatewayAnnotation , subnet .Spec .Gateway )
302
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpPoolAnnotation , ippool )
303
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .IpAddressAnnotation , ips [i ])
304
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .LogicalSwitchAnnotation , subnet .Name )
305
+ framework .ExpectMAC (pod .Annotations [util .MacAddressAnnotation ])
306
+ framework .ExpectHaveKeyWithValue (pod .Annotations , util .RoutedAnnotation , "true" )
307
+
308
+ podIPs := make ([]string , 0 , len (pod .Status .PodIPs ))
309
+ for _ , podIP := range pod .Status .PodIPs {
310
+ podIPs = append (podIPs , podIP .IP )
311
+ }
312
+ framework .ExpectConsistOf (podIPs , strings .Split (pod .Annotations [util .IpAddressAnnotation ], "," ))
311
313
}
312
- framework .ExpectConsistOf (podIPs , strings .Split (pod .Annotations [util .IpAddressAnnotation ], "," ))
314
+
315
+ ginkgo .By ("Deleting statefulset " + stsName )
316
+ stsClient .DeleteSync (stsName )
313
317
}
314
318
})
315
319
0 commit comments