Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 25 additions & 35 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,12 @@ var _ = Describe("Whereabouts functionality", func() {
})

Context("deleting a pod from the statefulset", func() {
var (
containerID string
podRef string
)
It("can recover from an exhausted IP pool", func() {
var containerID string
var podRef string

ctx := context.Background()
ctx := context.Background()

BeforeEach(func() {
ipPool, err := clientInfo.WbClient.WhereaboutsV1alpha1().IPPools(ipPoolNamespace).Get(
ctx,
wbstorage.IPPoolName(wbstorage.PoolIdentifier{IpRange: rangeWithTwoIPs, NetworkName: wbstorage.UnnamedNetwork}),
Expand All @@ -498,39 +496,31 @@ var _ = Describe("Whereabouts functionality", func() {
Expect(decomposedPodRef).To(HaveLen(2))
podName := decomposedPodRef[1]

By("deleting pod")
rightNow := int64(0)
Expect(clientInfo.Client.CoreV1().Pods(namespace).Delete(
ctx, podName, metav1.DeleteOptions{GracePeriodSeconds: &rightNow})).To(Succeed())

Expect(wbtestclient.WaitForStatefulSetCondition(
ctx,
clientInfo.Client,
namespace,
serviceName,
replicaNumber,
5*time.Second,
wbtestclient.IsStatefulSetDegradedPredicate)).Should(Succeed())

scaleUpTimeout := 2 * util.CreatePodTimeout
Expect(wbtestclient.WaitForStatefulSetCondition(
ctx,
clientInfo.Client,
namespace,
serviceName,
replicaNumber,
scaleUpTimeout,
wbtestclient.IsStatefulSetReadyPredicate)).Should(Succeed())
})

It("can recover from an exhausted IP pool", func() {
ipPool, err := clientInfo.WbClient.WhereaboutsV1alpha1().IPPools(ipPoolNamespace).Get(
ctx,
wbstorage.IPPoolName(wbstorage.PoolIdentifier{IpRange: rangeWithTwoIPs, NetworkName: wbstorage.UnnamedNetwork}),
metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
Expect(ipPool.Spec.Allocations).NotTo(BeEmpty())
Expect(allocationForPodRef(podRef, *ipPool)[0].ContainerID).NotTo(Equal(containerID))
Expect(allocationForPodRef(podRef, *ipPool)[0].PodRef).To(Equal(podRef))
By("checking that the IP allocation is recreated")
Eventually(func() error {
ipPool, err = clientInfo.WbClient.WhereaboutsV1alpha1().IPPools(ipPoolNamespace).Get(
ctx,
wbstorage.IPPoolName(wbstorage.PoolIdentifier{IpRange: rangeWithTwoIPs, NetworkName: wbstorage.UnnamedNetwork}),
metav1.GetOptions{})
if err != nil {
return err
}

if len(ipPool.Spec.Allocations) == 0 {
return fmt.Errorf("IP pool is empty")
}

if allocationForPodRef(podRef, *ipPool)[0].ContainerID == containerID {
return fmt.Errorf("IP allocation not recreated")
}

return nil
}, 3*time.Second, 500*time.Millisecond).Should(Succeed(), "the IP allocation should be recreated")
})
})
})
Expand Down
Loading