Skip to content

Commit

Permalink
Merge pull request kubevirt#10875 from EdDev/net-fix-dhcpv6-usage
Browse files Browse the repository at this point in the history
tests, net: Replace semi-dynamic IPv6 configuration with a static one
  • Loading branch information
kubevirt-bot authored Dec 17, 2023
2 parents 7c30888 + 79af09a commit abb922e
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions tests/network/vmi_networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,14 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
}

fedoraMasqueradeVMI := func(ports []v1.Port, ipv6NetworkCIDR string) (*v1.VirtualMachineInstance, error) {
if ipv6NetworkCIDR == "" {
ipv6NetworkCIDR = libnet.DefaultIPv6CIDR
}
networkData, err := libnet.NewNetworkData(
libnet.WithEthernet("eth0",
libnet.WithDHCP4Enabled(),
libnet.WithDHCP6Enabled(),
libnet.WithAddresses(ipv6NetworkCIDR),
libnet.WithGateway6(gatewayIPFromCIDR(ipv6NetworkCIDR)),
),
)
if err != nil {
Expand All @@ -674,27 +678,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
return vmi, nil
}

configureIpv6 := func(vmi *v1.VirtualMachineInstance, networkCIDR string) error {
if networkCIDR == "" {
networkCIDR = api.DefaultVMIpv6CIDR
}

err := console.RunCommand(vmi, "dhclient -6 eth0", 30*time.Second)
if err != nil {
return err
}
err = console.RunCommand(vmi, "ip -6 route add "+networkCIDR+" dev eth0", 5*time.Second)
if err != nil {
return err
}
gateway := gatewayIPFromCIDR(networkCIDR)
err = console.RunCommand(vmi, "ip -6 route add default via "+gateway, 5*time.Second)
if err != nil {
return err
}
return nil
}

portsUsedByLiveMigration := func() []v1.Port {
return []v1.Port{
{Port: LibvirtDirectMigrationPort},
Expand Down Expand Up @@ -802,8 +785,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
Expect(err).ToNot(HaveOccurred())
clientVMI = libwait.WaitUntilVMIReady(clientVMI, console.LoginToFedora)

Expect(configureIpv6(clientVMI, networkCIDR)).To(Succeed(), "failed to configure ipv6 on client vmi")

serverVMI, err = fedoraMasqueradeVMI(ports, networkCIDR)
Expect(err).ToNot(HaveOccurred())

Expand All @@ -812,8 +793,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
Expect(err).ToNot(HaveOccurred())
serverVMI = libwait.WaitUntilVMIReady(serverVMI, console.LoginToFedora)

Expect(configureIpv6(serverVMI, networkCIDR)).To(Succeed(), "failed to configure ipv6 on server vmi")

Expect(serverVMI.Status.Interfaces).To(HaveLen(1))
Expect(serverVMI.Status.Interfaces[0].IPs).NotTo(BeEmpty())

Expand All @@ -825,7 +804,7 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
Entry("with a specific port number [IPv6]", []v1.Port{{Name: "http", Port: 8080}}, 8080, ""),
Entry("with a specific port used by live migration", portsUsedByLiveMigration(), LibvirtDirectMigrationPort, ""),
Entry("without a specific port number [IPv6]", []v1.Port{}, 8080, ""),
Entry("with custom CIDR [IPv6]", []v1.Port{}, 8080, "fd10:10:10::/120"),
Entry("with custom CIDR [IPv6]", []v1.Port{}, 8080, "fd10:10:10::2/120"),
)

It("[outside_connectivity]should be able to reach the outside world [IPv6]", func() {
Expand All @@ -843,7 +822,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
vmi, err = virtClient.VirtualMachineInstance(testsuite.GetTestNamespace(nil)).Create(context.Background(), vmi)
Expect(err).ToNot(HaveOccurred())
vmi = libwait.WaitUntilVMIReady(vmi, console.LoginToFedora)
Expect(configureIpv6(vmi, api.DefaultVMIpv6CIDR)).To(Succeed(), "failed to configure ipv6 on vmi")

By("Checking ping (IPv6) from vmi to cluster nodes gateway")
Expect(libnet.PingFromVMConsole(vmi, ipv6Address)).To(Succeed())
Expand Down Expand Up @@ -939,8 +917,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
virtHandlerPod, err := getVirtHandlerPod()
Expect(err).ToNot(HaveOccurred())

Expect(configureIpv6(vmi, api.DefaultVMIpv6CIDR)).ToNot(HaveOccurred())

By("Check connectivity")
podIP := libnet.GetPodIPByFamily(virtHandlerPod, k8sv1.IPv6Protocol)
Expect(ping(podIP)).To(Succeed())
Expand All @@ -954,12 +930,6 @@ var _ = SIGDescribe("[rfe_id:694][crit:medium][vendor:[email protected]][level:c
Expect(vmi.Status.Phase).To(Equal(v1.Running))

Expect(ping(podIP)).To(Succeed())

By("Initiating DHCP client request after migration")
Expect(console.RunCommand(vmi, "sudo dhclient -6 -r eth0\n", time.Second*time.Duration(15))).To(Succeed(), "failed to release dhcp client")
Expect(console.RunCommand(vmi, "sudo dhclient -6 eth0\n", time.Second*time.Duration(15))).To(Succeed(), "failed to run dhcp client")

Expect(ping(podIP)).To(Succeed())
})
})

Expand Down

0 comments on commit abb922e

Please sign in to comment.