Skip to content

Commit 5ceef38

Browse files
committed
networksegment.,cudn: Wait for NetworkCreated or NetworkReady condition
Following the incoming changes of ClusterUserDefinedNetwork CRD condition type [1], tests that assert on the NetworkReady condition type should take in account the renamed type NetworkCreated to avoid CI breakage in the following scenarios: - Production code changes reached D/S before tests code changes: Having the CUDN CRD produce the new condition type (NetworkCreated), while e2e tests assert on the old condition type (NetworkReady). - Tests code changes reached D/S before production code changes: Having the CUDN CRD produce the old condition type (NetworkReady), while tests assert on the new condition type (NetworkCreated). Change assertions on CUDN condition type NetworkReady, expect condition type NetworkReady or NetworkCreated. [1] ovn-kubernetes/ovn-kubernetes#4884 Signed-off-by: Or Mergi <[email protected]>
1 parent 80ab015 commit 5ceef38

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

test/extended/networking/network_segmentation.go

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -966,12 +966,20 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
966966
var actualConditions []metav1.Condition
967967
g.Expect(json.Unmarshal([]byte(conditionsJSON), &actualConditions)).To(Succeed())
968968
return normalizeConditions(actualConditions)
969-
}, 5*time.Second, 1*time.Second).Should(ConsistOf(metav1.Condition{
970-
Type: "NetworkReady",
971-
Status: metav1.ConditionFalse,
972-
Reason: "NetworkAttachmentDefinitionSyncError",
973-
Message: expectedMessage,
974-
}))
969+
}, 5*time.Second, 1*time.Second).Should(SatisfyAny(
970+
ConsistOf(metav1.Condition{
971+
Type: "NetworkReady",
972+
Status: metav1.ConditionFalse,
973+
Reason: "NetworkAttachmentDefinitionSyncError",
974+
Message: expectedMessage,
975+
}),
976+
ConsistOf(metav1.Condition{
977+
Type: "NetworkCreated",
978+
Status: metav1.ConditionFalse,
979+
Reason: "NetworkAttachmentDefinitionSyncError",
980+
Message: expectedMessage,
981+
}),
982+
))
975983
})
976984

977985
Context("UDN Pod", func() {
@@ -1214,8 +1222,15 @@ func waitForUserDefinedNetworkReady(namespace, name string, timeout time.Duratio
12141222
}
12151223

12161224
func waitForClusterUserDefinedNetworkReady(name string, timeout time.Duration) error {
1217-
_, err := e2ekubectl.RunKubectl("", "wait", "clusteruserdefinednetwork", name, "--for", "condition=NetworkReady=True", "--timeout", timeout.String())
1218-
return err
1225+
_, errNetReady := e2ekubectl.RunKubectl("", "wait", "clusteruserdefinednetwork", name, "--for", "condition=NetworkReady=True", "--timeout", timeout.String())
1226+
netReady := errNetReady == nil
1227+
_, errNetCreated := e2ekubectl.RunKubectl("", "wait", "clusteruserdefinednetwork", name, "--for", "condition=NetworkCreated=True", "--timeout", timeout.String())
1228+
netCreated := errNetCreated == nil
1229+
1230+
if netReady || netCreated {
1231+
return nil
1232+
}
1233+
return errors.Join(errNetReady, errNetCreated)
12191234
}
12201235

12211236
func newPrimaryUserDefinedNetworkManifest(oc *exutil.CLI, name string) string {
@@ -1371,7 +1386,7 @@ func assertClusterUDNStatusReportsActiveNamespaces(cudnName string, expectedActi
13711386

13721387
c := conditions[0]
13731388
// equality matcher cannot be used since condition message namespaces order is inconsistent
1374-
ExpectWithOffset(1, c.Type).Should(Equal("NetworkReady"))
1389+
ExpectWithOffset(1, c.Type).Should(SatisfyAny(Equal("NetworkReady"), Equal("NetworkCreated")))
13751390
ExpectWithOffset(1, c.Status).Should(Equal(metav1.ConditionTrue))
13761391
ExpectWithOffset(1, c.Reason).Should(Equal("NetworkAttachmentDefinitionReady"))
13771392

@@ -1390,14 +1405,20 @@ func assertClusterUDNStatusReportConsumers(conditionsJSON, udnName, udnNamespace
13901405
conditions = normalizeConditions(conditions)
13911406
expectedMsg := fmt.Sprintf("failed to delete NetworkAttachmentDefinition [%[1]s/%[2]s]: network in use by the following pods: [%[1]s/%[3]s]",
13921407
udnNamespace, udnName, expectedPodName)
1393-
ExpectWithOffset(1, conditions).To(Equal([]metav1.Condition{
1394-
{
1408+
ExpectWithOffset(1, conditions).To(SatisfyAny(
1409+
ConsistOf(metav1.Condition{
13951410
Type: "NetworkReady",
1396-
Status: "False",
1411+
Status: metav1.ConditionFalse,
13971412
Reason: "NetworkAttachmentDefinitionSyncError",
13981413
Message: expectedMsg,
1399-
},
1400-
}))
1414+
}),
1415+
ConsistOf(metav1.Condition{
1416+
Type: "NetworkCreated",
1417+
Status: metav1.ConditionFalse,
1418+
Reason: "NetworkAttachmentDefinitionSyncError",
1419+
Message: expectedMsg,
1420+
}),
1421+
))
14011422
}
14021423

14031424
func newClusterUDNManifest(name string, targetNamespaces ...string) string {

0 commit comments

Comments
 (0)