@@ -476,14 +476,12 @@ var _ = Describe("Whereabouts functionality", func() {
476476 })
477477
478478 Context ("deleting a pod from the statefulset" , func () {
479- var (
480- containerID string
481- podRef string
482- )
479+ It ("can recover from an exhausted IP pool" , func () {
480+ var containerID string
481+ var podRef string
483482
484- ctx := context .Background ()
483+ ctx := context .Background ()
485484
486- BeforeEach (func () {
487485 ipPool , err := clientInfo .WbClient .WhereaboutsV1alpha1 ().IPPools (ipPoolNamespace ).Get (
488486 ctx ,
489487 wbstorage .IPPoolName (wbstorage.PoolIdentifier {IpRange : rangeWithTwoIPs , NetworkName : wbstorage .UnnamedNetwork }),
@@ -498,39 +496,31 @@ var _ = Describe("Whereabouts functionality", func() {
498496 Expect (decomposedPodRef ).To (HaveLen (2 ))
499497 podName := decomposedPodRef [1 ]
500498
499+ By ("deleting pod" )
501500 rightNow := int64 (0 )
502501 Expect (clientInfo .Client .CoreV1 ().Pods (namespace ).Delete (
503502 ctx , podName , metav1.DeleteOptions {GracePeriodSeconds : & rightNow })).To (Succeed ())
504503
505- Expect (wbtestclient .WaitForStatefulSetCondition (
506- ctx ,
507- clientInfo .Client ,
508- namespace ,
509- serviceName ,
510- replicaNumber ,
511- 5 * time .Second ,
512- wbtestclient .IsStatefulSetDegradedPredicate )).Should (Succeed ())
513-
514- scaleUpTimeout := 2 * util .CreatePodTimeout
515- Expect (wbtestclient .WaitForStatefulSetCondition (
516- ctx ,
517- clientInfo .Client ,
518- namespace ,
519- serviceName ,
520- replicaNumber ,
521- scaleUpTimeout ,
522- wbtestclient .IsStatefulSetReadyPredicate )).Should (Succeed ())
523- })
524-
525- It ("can recover from an exhausted IP pool" , func () {
526- ipPool , err := clientInfo .WbClient .WhereaboutsV1alpha1 ().IPPools (ipPoolNamespace ).Get (
527- ctx ,
528- wbstorage .IPPoolName (wbstorage.PoolIdentifier {IpRange : rangeWithTwoIPs , NetworkName : wbstorage .UnnamedNetwork }),
529- metav1.GetOptions {})
530- Expect (err ).NotTo (HaveOccurred ())
531- Expect (ipPool .Spec .Allocations ).NotTo (BeEmpty ())
532- Expect (allocationForPodRef (podRef , * ipPool )[0 ].ContainerID ).NotTo (Equal (containerID ))
533- Expect (allocationForPodRef (podRef , * ipPool )[0 ].PodRef ).To (Equal (podRef ))
504+ By ("checking that the IP allocation is recreated" )
505+ Eventually (func () error {
506+ ipPool , err = clientInfo .WbClient .WhereaboutsV1alpha1 ().IPPools (ipPoolNamespace ).Get (
507+ ctx ,
508+ wbstorage .IPPoolName (wbstorage.PoolIdentifier {IpRange : rangeWithTwoIPs , NetworkName : wbstorage .UnnamedNetwork }),
509+ metav1.GetOptions {})
510+ if err != nil {
511+ return err
512+ }
513+
514+ if len (ipPool .Spec .Allocations ) == 0 {
515+ return fmt .Errorf ("IP pool is empty" )
516+ }
517+
518+ if allocationForPodRef (podRef , * ipPool )[0 ].ContainerID == containerID {
519+ return fmt .Errorf ("IP allocation not recreated" )
520+ }
521+
522+ return nil
523+ }, 3 * time .Second , 500 * time .Millisecond ).Should (Succeed (), "the IP allocation should be recreated" )
534524 })
535525 })
536526 })
0 commit comments