Skip to content

Commit 200f72e

Browse files
committed
Fix envTest topologyRef race condition
Before this patch, the "updates topology" envTest was a single block of instructions, but we actually need to check each of them provided that the reconcile loop moves forward and certain conditions are satisfied. This patch attempts to split the Eventually block so that: - Each assertion gets its own retry logic (based on timeout, interval) - Prevents early assertion failures from masking later issues This approach has been applied already to other operators (e.g. Nova) where there are many controllers trying to apply/remove finalizers to the same resource. Signed-off-by: Francesco Pantano <[email protected]>
1 parent 17d4823 commit 200f72e

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

test/functional/neutronapi_controller_test.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,25 +1633,50 @@ func getNeutronAPIControllerSuite(ml2MechanismDrivers []string) func() {
16331633
Eventually(func(g Gomega) {
16341634
th.SimulateJobSuccess(neutronDBSyncJobName)
16351635

1636+
neutron := GetNeutronAPI(neutronAPIName)
1637+
g.Expect(neutron.Status.LastAppliedTopology).ToNot(BeNil())
1638+
g.Expect(neutron.Status.LastAppliedTopology).To(Equal(topologyRefAlt))
1639+
1640+
// Simulate deployment being ready with empty network attachments (since this test doesn't use them)
1641+
th.SimulateDeploymentReadyWithPods(neutronDeploymentName, map[string][]string{})
1642+
1643+
// Wait for neutron to be fully ready before checking topology finalizers
1644+
th.ExpectCondition(
1645+
neutronAPIName,
1646+
ConditionGetterFunc(NeutronAPIConditionGetter),
1647+
condition.ReadyCondition,
1648+
corev1.ConditionTrue,
1649+
)
1650+
}, timeout, interval).Should(Succeed())
1651+
1652+
Eventually(func(g Gomega) {
1653+
1654+
th.ExpectCondition(
1655+
neutronAPIName,
1656+
ConditionGetterFunc(NeutronAPIConditionGetter),
1657+
condition.TopologyReadyCondition,
1658+
corev1.ConditionTrue,
1659+
)
1660+
16361661
tp := infra.GetTopology(types.NamespacedName{
16371662
Name: topologyRefAlt.Name,
16381663
Namespace: topologyRefAlt.Namespace,
16391664
})
16401665
finalizers := tp.GetFinalizers()
16411666
g.Expect(finalizers).To(HaveLen(1))
1642-
neutron := GetNeutronAPI(neutronAPIName)
1643-
g.Expect(neutron.Status.LastAppliedTopology).ToNot(BeNil())
1644-
g.Expect(neutron.Status.LastAppliedTopology).To(Equal(topologyRefAlt))
16451667
g.Expect(finalizers).To(ContainElement(
16461668
fmt.Sprintf("openstack.org/neutronapi-%s", neutronAPIName.Name)))
1669+
}, timeout, interval).Should(Succeed())
1670+
1671+
Eventually(func(g Gomega) {
16471672
// Verify the previous referenced topology has no finalizers
1648-
tp = infra.GetTopology(types.NamespacedName{
1673+
prevTopology := infra.GetTopology(types.NamespacedName{
16491674
Name: topologyRef.Name,
16501675
Namespace: topologyRef.Namespace,
16511676
})
1652-
finalizers = tp.GetFinalizers()
1677+
finalizers := prevTopology.GetFinalizers()
16531678
g.Expect(finalizers).To(BeEmpty())
1654-
}, timeout, interval).Should(Succeed())
1679+
}, 20*timeout, interval).Should(Succeed())
16551680
})
16561681

16571682
It("removes topologyRef from the spec", func() {

0 commit comments

Comments
 (0)