Skip to content

Commit

Permalink
udpn, e2e: Adapt to multiple default gws
Browse files Browse the repository at this point in the history
After activating dhcpv6_stateful at LRP the agnhost alpine container has
two IPv6 default gateways pointing to the same interface and resolving
to the same mac (so they work the same).

This change ensure the test account for that by deleting all of them in
the test require it.

Signed-off-by: Enrique Llorente <[email protected]>
  • Loading branch information
qinqon committed Oct 14, 2024
1 parent 1c63fad commit b04d1e4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/e2e/network_segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,19 +356,24 @@ var _ = Describe("Network Segmentation", func() {
if podIP.IP.To4() == nil {
ipCommand = append(ipCommand, "-6")
}
// 1. Find current default route and delete it
defRoute, err := e2ekubectl.RunKubectl(udnPod.Namespace,
// 1. Find current default routes and delete them
defRoutes, err := e2ekubectl.RunKubectl(udnPod.Namespace,
append(ipCommand, "route", "show", "default")...)
Expect(err).NotTo(HaveOccurred())
defRoute = strings.TrimSpace(defRoute)
if defRoute == "" {
if defRoutes == "" {
continue
}
framework.Logf("Found default route %v, deleting", defRoute)

// Remove last new line to propertly split them using new line
defRoutes = strings.TrimSuffix(defRoutes, "\n")

framework.Logf("Found default routes %v, deleting", defRoutes)
cmd := append(ipCommand, "route", "del")
_, err = e2ekubectl.RunKubectl(udnPod.Namespace,
append(cmd, strings.Split(defRoute, " ")...)...)
Expect(err).NotTo(HaveOccurred())
for _ = range strings.Split(defRoutes, "\n") {
_, err = e2ekubectl.RunKubectl(udnPod.Namespace,
append(cmd, "default")...)
Expect(err).NotTo(HaveOccurred())
}

// 2. Add a new default route to use default network interface
gatewayIP := iputils.NextIP(iputils.Network(podIP).IP)
Expand Down

0 comments on commit b04d1e4

Please sign in to comment.