Skip to content

Commit d8e2adb

Browse files
committed
test(dataplane): wait for initial deployment reconcile
Deployment webhook tests create deployments that reference a NodeSet absent from the test namespace. The controller initializes status on the initial reconcile, then schedules a retry. If that retry runs after a synthetic running condition is written, it can reset the condition and allow deletion. Wait until Status.ObservedGeneration matches metadata.generation before setting synthetic conditions. Mark each test deployment as deployed in the same status update, causing queued retries to return early and preserving the condition for webhook validation.
1 parent bd0e67e commit d8e2adb

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎test/functional/dataplane/openstackdataplanedeployment_webhook_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,23 @@ var _ = Describe("DataplaneDeployment Webhook", func() {
3232
Expect(th.K8sClient.Update(th.Ctx, instance)).To(Succeed())
3333
Expect(th.K8sClient.Delete(th.Ctx, instance)).To(Succeed())
3434
})
35+
36+
// Let the deployment controller finish its initial reconcile before the
37+
// tests set a synthetic status. The initial reconcile initializes the
38+
// deployment conditions and would otherwise race with delete validation.
39+
Eventually(func(g Gomega) {
40+
instance := &dataplanev1.OpenStackDataPlaneDeployment{}
41+
g.Expect(th.K8sClient.Get(th.Ctx, name, instance)).To(Succeed())
42+
g.Expect(instance.Status.ObservedGeneration).To(Equal(instance.Generation))
43+
}, timeout, interval).Should(Succeed())
3544
}
3645

3746
setDeploymentRunning := func(name types.NamespacedName) {
3847
Eventually(func(g Gomega) error {
3948
instance := &dataplanev1.OpenStackDataPlaneDeployment{}
4049
g.Expect(th.K8sClient.Get(th.Ctx, name, instance)).To(Succeed())
50+
// Prevent the controller's delayed retry from overwriting this synthetic condition.
51+
instance.Status.Deployed = true
4152
instance.Status.Conditions = condition.Conditions{}
4253
instance.Status.Conditions.MarkFalse(
4354
condition.DeploymentReadyCondition,
@@ -53,6 +64,7 @@ var _ = Describe("DataplaneDeployment Webhook", func() {
5364
Eventually(func(g Gomega) error {
5465
instance := &dataplanev1.OpenStackDataPlaneDeployment{}
5566
g.Expect(th.K8sClient.Get(th.Ctx, name, instance)).To(Succeed())
67+
instance.Status.Deployed = true
5668
instance.Status.Conditions = condition.Conditions{}
5769
instance.Status.Conditions.MarkTrue(
5870
condition.DeploymentReadyCondition,

0 commit comments

Comments
 (0)