Skip to content

Commit ca2c889

Browse files
jluhrsenclaude
andcommitted
fix CUDN status condition tests for new TransportAccepted condition
upstream ovn-kubernetes commit [0] added a new TransportAccepted status condition to ClusterUserDefinedNetwork resources. two tests and a helper function assumed the condition list only contained network conditions and broke when TransportAccepted appeared. fixes: - validateClusterUDNStatusReportsActiveNamespacesFunc: iterate conditions to find NetworkCreated/NetworkReady instead of assuming conditions[0] - "should report not-ready" test: use ContainElement instead of ConsistOf so extra conditions don't cause failures [0] ovn-kubernetes/ovn-kubernetes@b855462 Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c77ff4a commit ca2c889

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

test/extended/networking/network_segmentation.go

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,13 +1047,13 @@ var _ = Describe("[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:User
10471047
g.Expect(json.Unmarshal([]byte(conditionsJSON), &actualConditions)).To(Succeed())
10481048
return normalizeConditions(actualConditions)
10491049
}, 5*time.Second, 1*time.Second).Should(SatisfyAny(
1050-
ConsistOf(metav1.Condition{
1050+
ContainElement(metav1.Condition{
10511051
Type: "NetworkReady",
10521052
Status: metav1.ConditionFalse,
10531053
Reason: "NetworkAttachmentDefinitionSyncError",
10541054
Message: expectedMessage,
10551055
}),
1056-
ConsistOf(metav1.Condition{
1056+
ContainElement(metav1.Condition{
10571057
Type: "NetworkCreated",
10581058
Status: metav1.ConditionFalse,
10591059
Reason: "NetworkAttachmentDefinitionSyncError",
@@ -1481,23 +1481,31 @@ func validateClusterUDNStatusReportsActiveNamespacesFunc(client dynamic.Interfac
14811481
return fmt.Errorf("expected at least one condition in %v", cUDN)
14821482
}
14831483

1484-
c := conditions[0]
1485-
if c.Type != "NetworkCreated" && c.Type != "NetworkReady" {
1486-
return fmt.Errorf("expected NetworkCreated/NetworkReady type in %v", c)
1484+
// Find NetworkCreated/NetworkReady condition among all conditions
1485+
var networkCond *metav1.Condition
1486+
for i := range conditions {
1487+
if conditions[i].Type == "NetworkCreated" || conditions[i].Type == "NetworkReady" {
1488+
networkCond = &conditions[i]
1489+
break
1490+
}
14871491
}
1488-
if c.Status != metav1.ConditionTrue {
1489-
return fmt.Errorf("expected True status in %v", c)
1492+
if networkCond == nil {
1493+
return fmt.Errorf("NetworkCreated/NetworkReady condition not found in conditions: %v", conditions)
1494+
}
1495+
1496+
if networkCond.Status != metav1.ConditionTrue {
1497+
return fmt.Errorf("expected True status in %v", networkCond)
14901498
}
1491-
if c.Reason != "NetworkAttachmentDefinitionCreated" && c.Reason != "NetworkAttachmentDefinitionReady" {
1492-
return fmt.Errorf("expected NetworkAttachmentDefinitionCreated/NetworkAttachmentDefinitionReady reason in %v", c)
1499+
if networkCond.Reason != "NetworkAttachmentDefinitionCreated" && networkCond.Reason != "NetworkAttachmentDefinitionReady" {
1500+
return fmt.Errorf("expected NetworkAttachmentDefinitionCreated/NetworkAttachmentDefinitionReady reason in %v", networkCond)
14931501
}
1494-
if !strings.Contains(c.Message, "NetworkAttachmentDefinition has been created in following namespaces:") {
1495-
return fmt.Errorf("expected \"NetworkAttachmentDefinition has been created in following namespaces:\" in %s", c.Message)
1502+
if !strings.Contains(networkCond.Message, "NetworkAttachmentDefinition has been created in following namespaces:") {
1503+
return fmt.Errorf("expected \"NetworkAttachmentDefinition has been created in following namespaces:\" in %s", networkCond.Message)
14961504
}
14971505

14981506
for _, ns := range expectedActiveNsNames {
1499-
if !strings.Contains(c.Message, ns) {
1500-
return fmt.Errorf("expected to find %q namespace in %s", ns, c.Message)
1507+
if !strings.Contains(networkCond.Message, ns) {
1508+
return fmt.Errorf("expected to find %q namespace in %s", ns, networkCond.Message)
15011509
}
15021510
}
15031511
return nil

0 commit comments

Comments
 (0)