Skip to content

Commit 4f246fb

Browse files
test: fix missing mock nodes in conditionPolicy tests
The tests were failing in CI because anyOfNode was defined as a struct but never created in the mock k8sClient. When the controller attempted to remove/add taints on the node, the API server returned a 404 Not Found error. Added Expect(k8sClient.Create(ctx, anyOfNode)).To(Succeed()) to the setup of all tests in the ConditionPolicy Context.
1 parent da613b6 commit 4f246fb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

internal/controller/nodereadinessrule_controller_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2284,6 +2284,8 @@ var _ = Describe("NodeReadinessRule Controller", func() {
22842284
}
22852285
anyOfController.updateRuleCache(ctx, rule)
22862286

2287+
Expect(k8sClient.Create(ctx, anyOfNode)).To(Succeed())
2288+
defer k8sClient.Delete(ctx, anyOfNode)
22872289
Expect(anyOfController.evaluateRuleForNode(ctx, rule, anyOfNode)).To(Succeed())
22882290

22892291
// Taint should have been removed because HardwareDriverReady=True satisfies anyOf
@@ -2318,6 +2320,8 @@ var _ = Describe("NodeReadinessRule Controller", func() {
23182320
}
23192321
anyOfController.updateRuleCache(ctx, rule)
23202322

2323+
Expect(k8sClient.Create(ctx, anyOfNode)).To(Succeed())
2324+
defer k8sClient.Delete(ctx, anyOfNode)
23212325
Expect(anyOfController.evaluateRuleForNode(ctx, rule, anyOfNode)).To(Succeed())
23222326

23232327
// Taint should have been added because neither condition is satisfied
@@ -2348,6 +2352,8 @@ var _ = Describe("NodeReadinessRule Controller", func() {
23482352
}
23492353
anyOfController.updateRuleCache(ctx, rule)
23502354

2355+
Expect(k8sClient.Create(ctx, anyOfNode)).To(Succeed())
2356+
defer k8sClient.Delete(ctx, anyOfNode)
23512357
Expect(anyOfController.evaluateRuleForNode(ctx, rule, anyOfNode)).To(Succeed())
23522358

23532359
// Taint must remain because CondB is still False
@@ -2374,6 +2380,8 @@ var _ = Describe("NodeReadinessRule Controller", func() {
23742380
}
23752381
anyOfController.updateRuleCache(ctx, rule)
23762382

2383+
Expect(k8sClient.Create(ctx, anyOfNode)).To(Succeed())
2384+
defer k8sClient.Delete(ctx, anyOfNode)
23772385
Expect(anyOfController.evaluateRuleForNode(ctx, rule, anyOfNode)).To(Succeed())
23782386

23792387
// Missing condition resolves to Unknown != True, so anyOf is not satisfied

0 commit comments

Comments
 (0)