Skip to content

Commit

Permalink
Merge pull request #100676 from squeed/netpol-v6-test
Browse files Browse the repository at this point in the history
test/e2e: handle ipv6 addresses in netpol tests
  • Loading branch information
k8s-ci-robot committed Apr 9, 2021
2 parents 4959cd6 + 1efd456 commit fded3d7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/e2e/network/netpol/kubemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package netpol
import (
"context"
"fmt"
"net"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -109,14 +111,15 @@ func (k *kubeManager) getPod(ns string, name string) (*v1.Pod, error) {

// probeConnectivity execs into a pod and checks its connectivity to another pod..
func (k *kubeManager) probeConnectivity(nsFrom string, podFrom string, containerFrom string, addrTo string, protocol v1.Protocol, toPort int) (bool, string, error) {
port := strconv.Itoa(toPort)
var cmd []string
switch protocol {
case v1.ProtocolSCTP:
cmd = []string{"/agnhost", "connect", fmt.Sprintf("%s:%d", addrTo, toPort), "--timeout=1s", "--protocol=sctp"}
cmd = []string{"/agnhost", "connect", net.JoinHostPort(addrTo, port), "--timeout=1s", "--protocol=sctp"}
case v1.ProtocolTCP:
cmd = []string{"/agnhost", "connect", fmt.Sprintf("%s:%d", addrTo, toPort), "--timeout=1s", "--protocol=tcp"}
cmd = []string{"/agnhost", "connect", net.JoinHostPort(addrTo, port), "--timeout=1s", "--protocol=tcp"}
case v1.ProtocolUDP:
cmd = []string{"/agnhost", "connect", fmt.Sprintf("%s:%d", addrTo, toPort), "--timeout=1s", "--protocol=udp"}
cmd = []string{"/agnhost", "connect", net.JoinHostPort(addrTo, port), "--timeout=1s", "--protocol=udp"}
default:
framework.Failf("protocol %s not supported", protocol)
}
Expand Down

0 comments on commit fded3d7

Please sign in to comment.