From 788544a83602cc529632480245328058c6b2f327 Mon Sep 17 00:00:00 2001 From: Pratyay Banerjee Date: Tue, 7 Mar 2023 21:22:37 +0530 Subject: [PATCH] report IP families that are being tested Signed-off-by: Pratyay Banerjee --- connectivity/tests/host.go | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/connectivity/tests/host.go b/connectivity/tests/host.go index 53ae39db71..4e2ad0defe 100644 --- a/connectivity/tests/host.go +++ b/connectivity/tests/host.go @@ -35,16 +35,23 @@ func (s *podToHost) Run(ctx context.Context, t *check.Test) { for _, node := range ct.Nodes() { node := node + var ipFamStr string + t.ForEachIPFamily(func(ipFam check.IPFamily) { + if ipFam == check.IPv4 { + ipFamStr = "v4" + } else if ipFam == check.IPv6 { + ipFamStr = "v6" + } + for _, addr := range node.Status.Addresses { if check.GetIPFamily(addr.Address) != ipFam { continue } dst := check.ICMPEndpoint("", addr.Address) - ipFam := check.GetIPFamily(addr.Address) - t.NewAction(s, fmt.Sprintf("ping-%d", i), &pod, dst, ipFam).Run(func(a *check.Action) { + t.NewAction(s, fmt.Sprintf("ping-%s-%d", ipFamStr, i), &pod, dst, ipFam).Run(func(a *check.Action) { a.ExecInPod(ctx, ct.PingCommand(dst, ipFam)) a.ValidateFlows(ctx, pod, a.GetEgressRequirements(check.FlowParameters{ @@ -89,15 +96,25 @@ func (s *podToHostPort) Run(ctx context.Context, t *check.Test) { echo := echo // copy to avoid memory aliasing when using reference baseURL := fmt.Sprintf("%s://%s:%d%s", echo.Scheme(), echo.Pod.Status.HostIP, check.EchoServerHostPort, echo.Path()) + + var ipFamStr string + + t.ForEachIPFamily(func(ipFam check.IPFamily) { + if ipFam == check.IPv4 { + ipFamStr = "v4" + } else if ipFam == check.IPv6 { + ipFamStr = "v6" + } + ep := check.HTTPEndpoint(echo.Name(), baseURL) - t.NewAction(s, fmt.Sprintf("curl-%d", i), &client, ep, check.IPFamilyAny).Run(func(a *check.Action) { - a.ExecInPod(ctx, ct.CurlCommand(ep, check.IPFamilyAny)) + t.NewAction(s, fmt.Sprintf("curl-%s-%d", ipFamStr, i), &client, ep, ipFam).Run(func(a *check.Action) { + a.ExecInPod(ctx, ct.CurlCommand(ep, check.ipFam)) a.ValidateFlows(ctx, client, a.GetEgressRequirements(check.FlowParameters{ // Because the HostPort request is NATed, we might only // observe flows after DNAT has been applied (e.g. by // HostReachableServices), - AltDstIP: echo.Address(check.IPFamilyAny), + AltDstIP: echo.Address(check.ipFam), AltDstPort: echo.Port(), })) })