From 0c58f2a6a4feb576d44e5df515cf3213694c3c80 Mon Sep 17 00:00:00 2001 From: Or Mergi Date: Mon, 29 Sep 2025 17:43:47 +0300 Subject: [PATCH] ovn-k, virt, preconfigured-udn-addrs: Test MAC conflict detection Verify KubeVirt VMs with preconfigured MAC address retain a requested MAC address before and after another VM is created requesting the same MAC address. And verify the other VM requesting the same MAC address get the appropriate address conflict error event. Signed-off-by: Or Mergi --- test/extended/networking/livemigration.go | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/extended/networking/livemigration.go b/test/extended/networking/livemigration.go index 8b6ce3285c3e..2650a7659a35 100644 --- a/test/extended/networking/livemigration.go +++ b/test/extended/networking/livemigration.go @@ -332,6 +332,20 @@ var _ = Describe("[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][F preconfiguredIPs: []string{"203.203.0.100", "2014:100:200::100"}, }, ), + Entry( + "[OCPFeatureGate:PreconfiguredUDNAddresses] when the VM with preconfigured MAC address is created when the address is already taken", + networkAttachmentConfigParams{ + name: nadName, + topology: "layer2", + role: "primary", + allowPersistentIPs: true, + }, + kubevirt.FedoraVMWithPreconfiguredPrimaryUDNAttachment, + duplicateVM, + workloadNetworkConfig{ + preconfiguredMAC: "02:00:00:22:22:22", + }, + ), ) }, Entry("NetworkAttachmentDefinitions", func(c networkAttachmentConfigParams) { @@ -588,6 +602,21 @@ func duplicateVM(cli *kubevirt.Client, vmNamespace, vmName string) { ) }) } + + mac, err := cli.GetJSONPath("vmi", vmName, "{.spec.domain.devices.interfaces[0].macAddress}") + Expect(err).NotTo(HaveOccurred()) + if len(mac) > 0 { + vmiExpectations = append(vmiExpectations, func() { + waitForVMPodEventWithMessage( + cli, + vmNamespace, + duplicateVMName, + "MAC address already in use", + 2*time.Minute, + ) + }) + } + Expect(cli.CreateVMIFromSpec(vmNamespace, duplicateVMName, vmiSpec, vmiCreationOptions...)).To(Succeed()) for _, expectation := range vmiExpectations { expectation()