mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
e2e: add a function to map IPv4 in IPv6
This commit is contained in:
parent
daff471766
commit
0655ad338f
@ -116,6 +116,7 @@ go_library(
|
||||
"//vendor/golang.org/x/net/websocket:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
"//vendor/k8s.io/utils/exec:go_default_library",
|
||||
"//vendor/k8s.io/utils/net:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
@ -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 (
|
||||
@ -76,6 +77,16 @@ const (
|
||||
|
||||
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}
|
||||
|
Loading…
Reference in New Issue
Block a user