Merge pull request #80398 from aojea/ipfamily

Add ip family autodetection to the testing framework
This commit is contained in:
Kubernetes Prow Robot
2019-07-25 18:12:00 -07:00
committed by GitHub
6 changed files with 45 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ import (
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
imageutils "k8s.io/kubernetes/test/utils/image"
k8utilnet "k8s.io/utils/net"
)
const (
@@ -77,6 +78,16 @@ const (
// NetexecImageName is the image name for agnhost.
var NetexecImageName = imageutils.GetE2EImage(imageutils.Agnhost)
// TranslateIPv4ToIPv6 maps an IPv4 address into a valid IPv6 address
// adding the well known prefix "0::ffff:" https://tools.ietf.org/html/rfc2765
// if the ip is IPv4 and the cluster IPFamily is IPv6, otherwise returns the same ip
func TranslateIPv4ToIPv6(ip string) string {
if TestContext.IPFamily == "ipv6" && !k8utilnet.IsIPv6String(ip) {
ip = "0::ffff:" + ip
}
return ip
}
// NewNetworkingTestConfig creates and sets up a new test config helper.
func NewNetworkingTestConfig(f *Framework) *NetworkingTestConfig {
config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: true}