Skip to content

Commit

Permalink
report IP families that are being tested
Browse files Browse the repository at this point in the history
Signed-off-by: Pratyay Banerjee <[email protected]>
  • Loading branch information
Neilblaze committed Mar 11, 2023
1 parent eecce64 commit a248a04
Showing 1 changed file with 34 additions and 16 deletions.
50 changes: 34 additions & 16 deletions connectivity/tests/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ 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.IPFamilyV4 {
ipFamStr = "v4"
} else if ipFam == check.IPFamilyV6 {
ipFamStr = "v6"
}

for _, addr := range node.Status.Addresses {
if check.GetIPFamily(addr.Address) != ipFam {
continue
Expand All @@ -44,7 +52,7 @@ func (s *podToHost) Run(ctx context.Context, t *check.Test) {
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{
Expand Down Expand Up @@ -88,21 +96,31 @@ func (s *podToHostPort) Run(ctx context.Context, t *check.Test) {
for _, echo := range ct.EchoPods() {
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())
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))

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),
AltDstPort: echo.Port(),
}))
})
var ipFamStr string

i++
}
t.ForEachIPFamily(func(ipFam check.IPFamily) {
if ipFam == check.IPFamilyV4 {
ipFamStr = "v4"
} else if ipFam == check.IPFamilyV6 {
ipFamStr = "v6"
}

baseURL := fmt.Sprintf("%s://%s:%d%s", echo.Scheme(), echo.Pod.Status.HostIP, check.EchoServerHostPort, echo.Path())
ep := check.HTTPEndpoint(echo.Name(), baseURL)
t.NewAction(s, fmt.Sprintf("curl-%s-%d", ipFamStr, i), &client, ep, check.IPFamilyAny).Run(func(a *check.Action) {
a.ExecInPod(ctx, ct.CurlCommand(ep, check.IPFamilyAny))

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),
AltDstPort: echo.Port(),
}))
})

i++
})
}
}
}

0 comments on commit a248a04

Please sign in to comment.