From 99f940cdefad96b6de96484297c777aca38b0563 Mon Sep 17 00:00:00 2001 From: Todd Neal Date: Fri, 4 Mar 2022 11:07:59 -0600 Subject: [PATCH] remove the expect enqueued for eviction tests Pods can enter/exit the eviction queue rapidly so looking for them in the queue itself is flaky. Instead, just check if they've been evicted. Fixes #706 --- pkg/controllers/termination/suite_test.go | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/pkg/controllers/termination/suite_test.go b/pkg/controllers/termination/suite_test.go index 535dfc7f78b3..1acd4bca1d47 100644 --- a/pkg/controllers/termination/suite_test.go +++ b/pkg/controllers/termination/suite_test.go @@ -108,9 +108,6 @@ var _ = Describe("Termination", func() { node = ExpectNodeExists(ctx, env.Client, node.Name) ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(node)) - // Expect podEvict to be enqueued for eviction - ExpectEnqueuedForEviction(evictionQueue, podEvict) - // Expect node to exist and be draining ExpectNodeDraining(env.Client, node.Name) @@ -150,7 +147,6 @@ var _ = Describe("Termination", func() { ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(node)) // Expect podEvict to be enqueued for eviction then be successful - ExpectEnqueuedForEviction(evictionQueue, podEvict) ExpectEvicted(env.Client, podEvict) // Delete pod to simulate successful eviction @@ -215,9 +211,6 @@ var _ = Describe("Termination", func() { node = ExpectNodeExists(ctx, env.Client, node.Name) ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(node)) - // Expect the pod to be enqueued for eviction - ExpectEnqueuedForEviction(evictionQueue, podNoEvict) - // Expect node to exist and be draining ExpectNodeDraining(env.Client, node.Name) @@ -247,9 +240,6 @@ var _ = Describe("Termination", func() { node = ExpectNodeExists(ctx, env.Client, node.Name) ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(node)) - // Expect podEvict to be enqueued for eviction - ExpectEnqueuedForEviction(evictionQueue, podEvict) - // Expect node to exist and be draining ExpectNodeDraining(env.Client, node.Name) @@ -296,7 +286,6 @@ var _ = Describe("Termination", func() { ExpectNotEnqueuedForEviction(evictionQueue, podNoEvict) // Expect podEvict to be enqueued for eviction then be successful - ExpectEnqueuedForEviction(evictionQueue, podEvict) ExpectEvicted(env.Client, podEvict) // Expect node to exist and be draining @@ -324,8 +313,8 @@ var _ = Describe("Termination", func() { node = ExpectNodeExists(ctx, env.Client, node.Name) ExpectReconcileSucceeded(ctx, controller, client.ObjectKeyFromObject(node)) - // Expect the pod to be enqueued for eviction - ExpectEnqueuedForEviction(evictionQueue, pods[0], pods[1]) + // Expect the pods to be evicted + ExpectEvicted(env.Client, pods[0], pods[1]) // Expect node to exist and be draining, but not deleted node = ExpectNodeExists(ctx, env.Client, node.Name) @@ -364,12 +353,6 @@ var _ = Describe("Termination", func() { }) }) -func ExpectEnqueuedForEviction(e *termination.EvictionQueue, pods ...*v1.Pod) { - for _, pod := range pods { - Expect(e.Contains(client.ObjectKeyFromObject(pod))).To(BeTrue()) - } -} - func ExpectNotEnqueuedForEviction(e *termination.EvictionQueue, pods ...*v1.Pod) { for _, pod := range pods { Expect(e.Contains(client.ObjectKeyFromObject(pod))).To(BeFalse())