mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Merge pull request #84258 from oomichi/move-TranslateIPv4ToIPv6
Move TranslateIPv4ToIPv6() to e2e scheduling test
This commit is contained in:
commit
39a8417510
@ -40,7 +40,6 @@ 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,16 +75,6 @@ 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 != "" {
|
||||
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}
|
||||
|
@ -55,6 +55,7 @@ go_library(
|
||||
"//vendor/github.com/onsi/gomega:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
"//vendor/google.golang.org/api/compute/v1:go_default_library",
|
||||
"//vendor/k8s.io/utils/net:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
k8utilnet "k8s.io/utils/net"
|
||||
|
||||
"github.com/onsi/ginkgo"
|
||||
|
||||
@ -810,7 +811,7 @@ func CreateNodeSelectorPods(f *framework.Framework, id string, replicas int, nod
|
||||
|
||||
// create pod which using hostport on the specified node according to the nodeSelector
|
||||
func createHostPortPodOnNode(f *framework.Framework, podName, ns, hostIP string, port int32, protocol v1.Protocol, nodeSelector map[string]string, expectScheduled bool) {
|
||||
hostIP = framework.TranslateIPv4ToIPv6(hostIP)
|
||||
hostIP = translateIPv4ToIPv6(hostIP)
|
||||
createPausePod(f, pausePodConfig{
|
||||
Name: podName,
|
||||
Ports: []v1.ContainerPort{
|
||||
@ -829,3 +830,13 @@ func createHostPortPodOnNode(f *framework.Framework, podName, ns, hostIP string,
|
||||
framework.ExpectNoError(err)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 framework.TestContext.IPFamily == "ipv6" && !k8utilnet.IsIPv6String(ip) && ip != "" {
|
||||
ip = "0::ffff:" + ip
|
||||
}
|
||||
return ip
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user