Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDN-5570: revert primary udn test workaround from virt tests #29386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 4 additions & 57 deletions test/extended/networking/livemigration.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F
)

DescribeTableSubtree("created using",
func(createNetworkFn func(netConfig networkAttachmentConfigParams) networkAttachmentConfig) {
func(createNetworkFn func(netConfig networkAttachmentConfigParams)) {

DescribeTable("[Suite:openshift/network/virtualization] should keep ip", func(netConfig networkAttachmentConfigParams, vmResource string, opCmd func(cli *kubevirt.Client, vmNamespace, vmName string)) {
var err error
Expand All @@ -77,16 +77,7 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F

isDualStack := getIPFamilyForCluster(f) == DualStack

provisionedNetConfig := createNetworkFn(netConfig)

for _, node := range workerNodes {
Eventually(func() bool {
isNetProvisioned, err := isNetworkProvisioned(oc, node.Name, provisionedNetConfig.networkName)
return err == nil && isNetProvisioned
}).WithPolling(time.Second).WithTimeout(udnCrReadyTimeout).Should(
BeTrueBecause("the network must be ready before creating workloads"),
)
}
createNetworkFn(netConfig)

httpServerPods := prepareHTTPServerPods(f, netConfig, workerNodes)
vmCreationParams := kubevirt.CreationTemplateParams{
Expand Down Expand Up @@ -192,25 +183,18 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F
restartVM,
))
},
Entry("NetworkAttachmentDefinitions", func(c networkAttachmentConfigParams) networkAttachmentConfig {
Entry("NetworkAttachmentDefinitions", func(c networkAttachmentConfigParams) {
netConfig := newNetworkAttachmentConfig(c)
nad := generateNAD(netConfig)
By(fmt.Sprintf("Creating NetworkAttachmentDefinitions %s/%s", nad.Namespace, nad.Name))
_, err := nadClient.NetworkAttachmentDefinitions(c.namespace).Create(context.Background(), nad, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
return netConfig
}),
Entry("UserDefinedNetwork", func(c networkAttachmentConfigParams) networkAttachmentConfig {
Entry("UserDefinedNetwork", func(c networkAttachmentConfigParams) {
udnManifest := generateUserDefinedNetworkManifest(&c)
By(fmt.Sprintf("Creating UserDefinedNetwork %s/%s", c.namespace, c.name))
Expect(applyManifest(c.namespace, udnManifest)).To(Succeed())
Expect(waitForUserDefinedNetworkReady(c.namespace, c.name, udnCrReadyTimeout)).To(Succeed())

nad, err := nadClient.NetworkAttachmentDefinitions(c.namespace).Get(
context.Background(), c.name, metav1.GetOptions{},
)
Expect(err).NotTo(HaveOccurred())
return networkAttachmentConfig{networkAttachmentConfigParams{networkName: networkName(nad.Spec.Config)}}
}))
})
})
Expand Down Expand Up @@ -537,40 +521,3 @@ func checkEastWestTraffic(virtClient *kubevirt.Client, vmiName string, podIPsByN
}
}
}

func isNetworkProvisioned(oc *exutil.CLI, nodeName string, networkName string) (bool, error) {
ovnkubePodInfo, err := ovnkubePod(oc, nodeName)
if err != nil {
return false, err
}

lsName := logicalSwitchName(networkName)
out, err := adminExecInPod(
oc,
"openshift-ovn-kubernetes",
ovnkubePodInfo.podName,
ovnkubePodInfo.containerName,
fmt.Sprintf("ovn-nbctl list logical-switch %s", lsName),
)
if err != nil {
return false, fmt.Errorf("failed to find a logical switch for network %q: %w", networkName, err)
}

return strings.Contains(out, lsName), nil
}

func logicalSwitchName(networkName string) string {
netName := strings.ReplaceAll(networkName, "-", ".")
netName = strings.ReplaceAll(netName, "/", ".")
return fmt.Sprintf("%s_ovn_layer2_switch", netName)
}

func networkName(netSpecConfig string) string {
GinkgoHelper()
type netConfig struct {
Name string `json:"name,omitempty"`
}
var nc netConfig
Expect(json.Unmarshal([]byte(netSpecConfig), &nc)).To(Succeed())
return nc.Name
}