From 26a00f9032e2cb2412b76ebf4224753178c131a3 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sat, 2 May 2020 19:55:52 +0200 Subject: [PATCH] add ipv6 support to the e2e nfs tests nfs mount command need to use the IP enclosed with square brackets if is an IPv6 address --- test/e2e/common/volumes.go | 8 +++---- test/e2e/framework/volume/fixtures.go | 10 ++++++--- test/e2e/storage/drivers/in_tree.go | 18 +++++++-------- .../nfs_persistent_volume-disruptive.go | 22 +++++++++---------- test/e2e/storage/persistent_volumes.go | 6 ++--- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/test/e2e/common/volumes.go b/test/e2e/common/volumes.go index 514538894cc..a415b8a6aab 100644 --- a/test/e2e/common/volumes.go +++ b/test/e2e/common/volumes.go @@ -77,14 +77,14 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { //////////////////////////////////////////////////////////////////////// ginkgo.Describe("NFSv4", func() { ginkgo.It("should be mountable for NFSv4", func() { - config, _, serverIP := e2evolume.NewNFSServer(c, namespace.Name, []string{}) + config, _, serverHost := e2evolume.NewNFSServer(c, namespace.Name, []string{}) defer e2evolume.TestServerCleanup(f, config) tests := []e2evolume.Test{ { Volume: v1.VolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: serverIP, + Server: serverHost, Path: "/", ReadOnly: true, }, @@ -101,14 +101,14 @@ var _ = ginkgo.Describe("[sig-storage] GCP Volumes", func() { ginkgo.Describe("NFSv3", func() { ginkgo.It("should be mountable for NFSv3", func() { - config, _, serverIP := e2evolume.NewNFSServer(c, namespace.Name, []string{}) + config, _, serverHost := e2evolume.NewNFSServer(c, namespace.Name, []string{}) defer e2evolume.TestServerCleanup(f, config) tests := []e2evolume.Test{ { Volume: v1.VolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: serverIP, + Server: serverHost, Path: "/exports", ReadOnly: true, }, diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 996110dffaf..c4a2c75557d 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -44,6 +44,7 @@ import ( "fmt" "path/filepath" "strconv" + "strings" "time" v1 "k8s.io/api/core/v1" @@ -143,7 +144,7 @@ type Test struct { } // NewNFSServer is a NFS-specific wrapper for CreateStorageServer. -func NewNFSServer(cs clientset.Interface, namespace string, args []string) (config TestConfig, pod *v1.Pod, ip string) { +func NewNFSServer(cs clientset.Interface, namespace string, args []string) (config TestConfig, pod *v1.Pod, host string) { config = TestConfig{ Namespace: namespace, Prefix: "nfs", @@ -155,8 +156,11 @@ func NewNFSServer(cs clientset.Interface, namespace string, args []string) (conf if len(args) > 0 { config.ServerArgs = args } - pod, ip = CreateStorageServer(cs, config) - return config, pod, ip + pod, host = CreateStorageServer(cs, config) + if strings.Contains(host, ":") { + host = "[" + host + "]" + } + return config, pod, host } // NewGlusterfsServer is a GlusterFS-specific wrapper for CreateStorageServer. Also creates the gluster endpoints object. diff --git a/test/e2e/storage/drivers/in_tree.go b/test/e2e/storage/drivers/in_tree.go index 09c56098296..c6609f89365 100644 --- a/test/e2e/storage/drivers/in_tree.go +++ b/test/e2e/storage/drivers/in_tree.go @@ -81,9 +81,9 @@ type nfsDriver struct { } type nfsVolume struct { - serverIP string - serverPod *v1.Pod - f *framework.Framework + serverHost string + serverPod *v1.Pod + f *framework.Framework } var _ testsuites.TestDriver = &nfsDriver{} @@ -129,7 +129,7 @@ func (n *nfsDriver) GetVolumeSource(readOnly bool, fsType string, e2evolume test framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume") return &v1.VolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: nv.serverIP, + Server: nv.serverHost, Path: "/", ReadOnly: readOnly, }, @@ -141,7 +141,7 @@ func (n *nfsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, e2ev framework.ExpectEqual(ok, true, "Failed to cast test volume to NFS test volume") return &v1.PersistentVolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: nv.serverIP, + Server: nv.serverHost, Path: "/", ReadOnly: readOnly, }, @@ -199,12 +199,12 @@ func (n *nfsDriver) CreateVolume(config *testsuites.PerTestConfig, volType testp case testpatterns.InlineVolume: fallthrough case testpatterns.PreprovisionedPV: - c, serverPod, serverIP := e2evolume.NewNFSServer(cs, ns.Name, []string{}) + c, serverPod, serverHost := e2evolume.NewNFSServer(cs, ns.Name, []string{}) config.ServerConfig = &c return &nfsVolume{ - serverIP: serverIP, - serverPod: serverPod, - f: f, + serverHost: serverHost, + serverPod: serverPod, + f: f, } case testpatterns.DynamicPV: // Do nothing diff --git a/test/e2e/storage/nfs_persistent_volume-disruptive.go b/test/e2e/storage/nfs_persistent_volume-disruptive.go index 1e587e0b0e8..5afebb5e903 100644 --- a/test/e2e/storage/nfs_persistent_volume-disruptive.go +++ b/test/e2e/storage/nfs_persistent_volume-disruptive.go @@ -78,15 +78,15 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() { f := framework.NewDefaultFramework("disruptive-pv") var ( - c clientset.Interface - ns string - nfsServerPod *v1.Pod - nfsPVconfig e2epv.PersistentVolumeConfig - pvcConfig e2epv.PersistentVolumeClaimConfig - nfsServerIP, clientNodeIP string - clientNode *v1.Node - volLabel labels.Set - selector *metav1.LabelSelector + c clientset.Interface + ns string + nfsServerPod *v1.Pod + nfsPVconfig e2epv.PersistentVolumeConfig + pvcConfig e2epv.PersistentVolumeClaimConfig + nfsServerHost, clientNodeIP string + clientNode *v1.Node + volLabel labels.Set + selector *metav1.LabelSelector ) ginkgo.BeforeEach(func() { @@ -99,13 +99,13 @@ var _ = utils.SIGDescribe("NFSPersistentVolumes[Disruptive][Flaky]", func() { volLabel = labels.Set{e2epv.VolumeSelectorKey: ns} selector = metav1.SetAsLabelSelector(volLabel) // Start the NFS server pod. - _, nfsServerPod, nfsServerIP = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"}) + _, nfsServerPod, nfsServerHost = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"}) nfsPVconfig = e2epv.PersistentVolumeConfig{ NamePrefix: "nfs-", Labels: volLabel, PVSource: v1.PersistentVolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: nfsServerIP, + Server: nfsServerHost, Path: "/exports", ReadOnly: false, }, diff --git a/test/e2e/storage/persistent_volumes.go b/test/e2e/storage/persistent_volumes.go index 5635b0c9acb..6e80e620ce8 100644 --- a/test/e2e/storage/persistent_volumes.go +++ b/test/e2e/storage/persistent_volumes.go @@ -123,17 +123,17 @@ var _ = utils.SIGDescribe("PersistentVolumes", func() { var ( nfsServerPod *v1.Pod - serverIP string + serverHost string ) ginkgo.BeforeEach(func() { - _, nfsServerPod, serverIP = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"}) + _, nfsServerPod, serverHost = e2evolume.NewNFSServer(c, ns, []string{"-G", "777", "/exports"}) pvConfig = e2epv.PersistentVolumeConfig{ NamePrefix: "nfs-", Labels: volLabel, PVSource: v1.PersistentVolumeSource{ NFS: &v1.NFSVolumeSource{ - Server: serverIP, + Server: serverHost, Path: "/exports", ReadOnly: false, },