Skip to content

Commit 36ca107

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 36ca107

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

test/functional/neutronapi_controller_test.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,25 +1633,46 @@ 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) {
1649+
1650+
th.ExpectCondition(
1651+
neutronAPIName,
1652+
ConditionGetterFunc(NeutronAPIConditionGetter),
1653+
condition.TopologyReadyCondition,
1654+
corev1.ConditionTrue,
1655+
)
1656+
16361657
tp := infra.GetTopology(types.NamespacedName{
16371658
Name: topologyRefAlt.Name,
16381659
Namespace: topologyRefAlt.Namespace,
16391660
})
16401661
finalizers := tp.GetFinalizers()
16411662
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))
16451663
g.Expect(finalizers).To(ContainElement(
16461664
fmt.Sprintf("openstack.org/neutronapi-%s", neutronAPIName.Name)))
1665+
}, timeout, interval).Should(Succeed())
1666+
1667+
Eventually(func(g Gomega) {
16471668
// Verify the previous referenced topology has no finalizers
1648-
tp = infra.GetTopology(types.NamespacedName{
1669+
prevTopology := infra.GetTopology(types.NamespacedName{
16491670
Name: topologyRef.Name,
16501671
Namespace: topologyRef.Namespace,
16511672
})
1652-
finalizers = tp.GetFinalizers()
1673+
finalizers := prevTopology.GetFinalizers()
16531674
g.Expect(finalizers).To(BeEmpty())
1654-
}, timeout, interval).Should(Succeed())
1675+
}, 20*timeout, interval).Should(Succeed())
16551676
})
16561677

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

0 commit comments

Comments
 (0)