Skip to content

Commit

Permalink
test: fix drift/expiration test flakes (#5601)
Browse files Browse the repository at this point in the history
  • Loading branch information
njtran authored Feb 5, 2024
1 parent ce9f728 commit 354f692
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
9 changes: 2 additions & 7 deletions test/suites/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ var _ = Describe("Drift", func() {
dep.Spec.Replicas = lo.ToPtr[int32](3)
env.ExpectUpdated(dep)

// First expect there to be 3 pods, then try to spread the pods.
env.EventuallyExpectHealthyPodCount(selector, 3)
env.ForcePodsToSpread(nodes...)
env.EventuallyExpectHealthyPodCount(selector, 3)

Expand All @@ -226,8 +228,6 @@ var _ = Describe("Drift", func() {
for _, node := range nodes {
Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
node.Finalizers = append(node.Finalizers, common.TestingFinalizer)
// Set nodes as unschedulable so that pod nomination doesn't delay disruption for the second disruption action
node.Spec.Unschedulable = true
env.ExpectUpdated(node)
}

Expand All @@ -246,11 +246,6 @@ var _ = Describe("Drift", func() {
env.ExpectUpdated(pod)
}

// Mark one node as schedulable so the other two nodes can schedule to this node and delete.
Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(nodes[0]), nodes[0])).To(Succeed())
nodes[0].Spec.Unschedulable = false
env.ExpectUpdated(nodes[0])

// Ensure that we get two nodes tainted, and they have overlap during the drift
env.EventuallyExpectTaintedNodeCount("==", 2)
nodes = env.ConsistentlyExpectDisruptionsWithNodeCount(2, 3, 30*time.Second)
Expand Down
13 changes: 4 additions & 9 deletions test/suites/expiration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ var _ = Describe("Expiration", func() {
dep.Spec.Replicas = lo.ToPtr[int32](3)
env.ExpectUpdated(dep)

// First expect there to be 3 pods, then try to spread the pods.
env.EventuallyExpectHealthyPodCount(selector, 3)
env.ForcePodsToSpread(nodes...)
env.EventuallyExpectHealthyPodCount(selector, 3)

Expand All @@ -305,8 +307,6 @@ var _ = Describe("Expiration", func() {
for _, node := range nodes {
Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).To(Succeed())
node.Finalizers = append(node.Finalizers, common.TestingFinalizer)
// Set nodes as unschedulable so that pod nomination doesn't delay disruption for the second disruption action
node.Spec.Unschedulable = true
env.ExpectUpdated(node)
}

Expand All @@ -325,11 +325,6 @@ var _ = Describe("Expiration", func() {
env.ExpectUpdated(pod)
}

// Mark one node as schedulable so the other two nodes can schedule to this node and delete.
Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(nodes[0]), nodes[0])).To(Succeed())
nodes[0].Spec.Unschedulable = false
env.ExpectUpdated(nodes[0])

// Ensure that we get two nodes tainted, and they have overlap during the expiration
env.EventuallyExpectTaintedNodeCount("==", 2)
nodes = env.ConsistentlyExpectDisruptionsWithNodeCount(2, 3, 5*time.Second)
Expand Down Expand Up @@ -475,7 +470,7 @@ var _ = Describe("Expiration", func() {
env.ExpectUpdated(pod)
}

// Eventually the node will be set as unschedulable, which means its actively being deprovisioned
// Eventually the node will be tainted, which means its actively being disrupted
Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).Should(Succeed())
_, ok := lo.Find(node.Spec.Taints, func(t v1.Taint) bool {
Expand Down Expand Up @@ -539,7 +534,7 @@ var _ = Describe("Expiration", func() {
env.ExpectUpdated(pod)
}

// Eventually the node will be set as unschedulable, which means its actively being deprovisioned
// Eventually the node will be tainted, which means its actively being disrupted
Eventually(func(g Gomega) {
g.Expect(env.Client.Get(env.Context, client.ObjectKeyFromObject(node), node)).Should(Succeed())
_, ok := lo.Find(node.Spec.Taints, func(t v1.Taint) bool {
Expand Down

0 comments on commit 354f692

Please sign in to comment.