Skip to content

Commit

Permalink
Allows for backwards compatibility with upcoming network name change
Browse files Browse the repository at this point in the history
With ovn-kubernetes/ovn-kubernetes#4889 the
network name is going to change for UDNs. Update tests in advance.

Signed-off-by: Tim Rozet <[email protected]>
  • Loading branch information
trozet committed Feb 3, 2025
1 parent cd1a9a2 commit da09f81
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions test/extended/networking/network_segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -1538,17 +1538,29 @@ func assertNetAttachDefManifest(nadClient nadclient.K8sCniCncfIoV1Interface, nam
BlockOwnerDeletion: pointer.Bool(true),
Controller: pointer.Bool(true),
}}))
expectedNetworkName := namespace + "." + udnName
expectedNadName := namespace + "/" + udnName
ExpectWithOffset(1, nad.Spec.Config).To(MatchJSON(`{

jsonTemplate := `{
"cniVersion":"1.0.0",
"type": "ovn-k8s-cni-overlay",
"name": "` + expectedNetworkName + `",
"netAttachDefName": "` + expectedNadName + `",
"name": "%s",
"netAttachDefName": "%s",
"topology": "layer2",
"role": "secondary",
"subnets": "10.100.0.0/16"
}`))
}`

// REMOVEME(trozet): after network name has been updated to use underscores in OVNK
expectedLegacyNetworkName := namespace + "." + udnName
expectedNetworkName := namespace + "_" + udnName
expectedNadName := namespace + "/" + udnName

nadJSONLegacy := fmt.Sprintf(jsonTemplate, expectedLegacyNetworkName, expectedNadName)
nadJSON := fmt.Sprintf(jsonTemplate, expectedNetworkName, expectedNadName)

ExpectWithOffset(1, nad.Spec.Config).To(SatisfyAny(
MatchJSON(nadJSONLegacy),
MatchJSON(nadJSON),
))
}

func validateUDNStatusReportsConsumers(client dynamic.Interface, udnNamesapce, udnName, expectedPodName string) error {
Expand Down Expand Up @@ -1608,17 +1620,29 @@ func assertClusterNADManifest(nadClient nadclient.K8sCniCncfIoV1Interface, names
ExpectWithOffset(1, nad.Labels).To(Equal(map[string]string{"k8s.ovn.org/user-defined-network": ""}))
ExpectWithOffset(1, nad.Finalizers).To(Equal([]string{"k8s.ovn.org/user-defined-network-protection"}))

expectedNetworkName := "cluster.udn." + udnName
// REMOVEME(trozet): after network name has been updated to use underscores in OVNK
expectedLegacyNetworkName := "cluster.udn." + udnName

expectedNetworkName := "cluster_udn_" + udnName
expectedNadName := namespace + "/" + udnName
ExpectWithOffset(1, nad.Spec.Config).To(MatchJSON(`{

jsonTemplate := `{
"cniVersion":"1.0.0",
"type": "ovn-k8s-cni-overlay",
"name": "` + expectedNetworkName + `",
"netAttachDefName": "` + expectedNadName + `",
"name": "%s",
"netAttachDefName": "%s",
"topology": "layer2",
"role": "secondary",
"subnets": "10.100.0.0/16"
}`))
}`

nadJSONLegacy := fmt.Sprintf(jsonTemplate, expectedLegacyNetworkName, expectedNadName)
nadJSON := fmt.Sprintf(jsonTemplate, expectedNetworkName, expectedNadName)

ExpectWithOffset(1, nad.Spec.Config).To(SatisfyAny(
MatchJSON(nadJSONLegacy),
MatchJSON(nadJSON),
))
}

func validateClusterUDNStatusReportsActiveNamespacesFunc(client dynamic.Interface, cUDNName string, expectedActiveNsNames ...string) func() error {
Expand Down

0 comments on commit da09f81

Please sign in to comment.