Skip to content

Commit

Permalink
remove the expect enqueued for eviction tests (#1469)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tzneal committed Mar 4, 2022
1 parent ab4aca7 commit 057ee48
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions pkg/controllers/termination/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 057ee48

Please sign in to comment.