Skip to content

Commit 400e34a

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 400e34a

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

test/functional/neutronapi_controller_test.go

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,23 +1633,43 @@ 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+
th.ExpectCondition(
1641+
neutronAPIName,
1642+
ConditionGetterFunc(NeutronAPIConditionGetter),
1643+
condition.TopologyReadyCondition,
1644+
corev1.ConditionTrue,
1645+
)
1646+
}, timeout, interval).Should(Succeed())
1647+
1648+
Eventually(func(g Gomega) {
16361649
tp := infra.GetTopology(types.NamespacedName{
16371650
Name: topologyRefAlt.Name,
16381651
Namespace: topologyRefAlt.Namespace,
16391652
})
16401653
finalizers := tp.GetFinalizers()
16411654
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))
16451655
g.Expect(finalizers).To(ContainElement(
16461656
fmt.Sprintf("openstack.org/neutronapi-%s", neutronAPIName.Name)))
1657+
}, timeout, interval).Should(Succeed())
1658+
1659+
Eventually(func(g Gomega) {
1660+
1661+
th.ExpectCondition(
1662+
neutronAPIName,
1663+
ConditionGetterFunc(NeutronAPIConditionGetter),
1664+
condition.TopologyReadyCondition,
1665+
corev1.ConditionTrue,
1666+
)
16471667
// Verify the previous referenced topology has no finalizers
1648-
tp = infra.GetTopology(types.NamespacedName{
1668+
prevTopology := infra.GetTopology(types.NamespacedName{
16491669
Name: topologyRef.Name,
16501670
Namespace: topologyRef.Namespace,
16511671
})
1652-
finalizers = tp.GetFinalizers()
1672+
finalizers := prevTopology.GetFinalizers()
16531673
g.Expect(finalizers).To(BeEmpty())
16541674
}, timeout, interval).Should(Succeed())
16551675
})

0 commit comments

Comments
 (0)