From b04d1e440a4fa03bbef2f429d0af2e97b70ef920 Mon Sep 17 00:00:00 2001 From: Enrique Llorente Date: Thu, 3 Oct 2024 10:27:49 +0200 Subject: [PATCH] udpn, e2e: Adapt to multiple default gws 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 --- test/e2e/network_segmentation.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/e2e/network_segmentation.go b/test/e2e/network_segmentation.go index e6c62feb9c..bd0af901ed 100644 --- a/test/e2e/network_segmentation.go +++ b/test/e2e/network_segmentation.go @@ -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)