Skip to content

Commit

Permalink
test: fix race in flakey drift test
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed May 9, 2024
1 parent c16fd76 commit 8808ace
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/suites/drift/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,9 @@ var _ = Describe("Drift", func() {

env.EventuallyExpectDrifted(startingNodeClaimState...)

// Only drift a single node at a time due to default budgets
driftedNodeClaimState := env.EventuallyExpectCreatedNodeClaimCount("==", int(numPods) + 1)

// Expect nodes To get tainted
taintedNodes := env.EventuallyExpectTaintedNodeCount("==", 1)

Expand All @@ -849,7 +852,17 @@ var _ = Describe("Drift", func() {
Eventually(func(g Gomega) {
nodeClaims := &corev1beta1.NodeClaimList{}
g.Expect(env.Client.List(env, nodeClaims, client.HasLabels{coretest.DiscoveryLabel})).To(Succeed())
g.Expect(nodeClaims.Items).To(HaveLen(int(numPods)))
replacementNodeClaims := lo.FilterMap(driftedNodeClaimState, func(nc *corev1beta1.NodeClaim, _ int) (types.UID, bool) {
if lo.ContainsBy(startingNodeClaimState, func(snc *corev1beta1.NodeClaim) bool {
return snc.UID == nc.UID
}) {
return "", false
}
return nc.UID, true
})
g.Expect(lo.ContainsBy(nodeClaims.Items, func(nc corev1beta1.NodeClaim) bool {
return lo.Contains(replacementNodeClaims, nc.UID)
})).To(BeFalse())
}).WithTimeout(6 * time.Minute).Should(Succeed())

// Expect all the NodeClaims that existed on the initial provisioning loop are not removed
Expand Down

0 comments on commit 8808ace

Please sign in to comment.