mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #100676 from squeed/netpol-v6-test
test/e2e: handle ipv6 addresses in netpol tests
This commit is contained in:
commit
fded3d71e5
@ -19,6 +19,8 @@ package netpol
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -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..
|
// 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) {
|
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
|
var cmd []string
|
||||||
switch protocol {
|
switch protocol {
|
||||||
case v1.ProtocolSCTP:
|
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:
|
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:
|
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:
|
default:
|
||||||
framework.Failf("protocol %s not supported", protocol)
|
framework.Failf("protocol %s not supported", protocol)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user