From da604ad9fac4f016ae754fe238ead7d1fb626891 Mon Sep 17 00:00:00 2001 From: Jon Cope Date: Tue, 20 Dec 2016 13:55:12 -0600 Subject: [PATCH] Made server images paths constant, removed redundant import alias --- test/e2e/persistent_volumes-disruptive.go | 13 +++++-------- test/e2e/persistent_volumes.go | 4 ++-- test/e2e/volumes.go | 21 +++++++++++++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/test/e2e/persistent_volumes-disruptive.go b/test/e2e/persistent_volumes-disruptive.go index 605a19bae89..8bbe5aa2af1 100644 --- a/test/e2e/persistent_volumes-disruptive.go +++ b/test/e2e/persistent_volumes-disruptive.go @@ -21,7 +21,7 @@ limitations under the License. package e2e import ( - "strings" + "fmt" "time" . "github.com/onsi/ginkgo" @@ -47,7 +47,7 @@ const ( kRestart kubeletOpt = "restart" ) -var _ = framework.KubeDescribe("PersistentVolumes:Disruptive", func() { +var _ = framework.KubeDescribe("PersistentVolumes [Disruptive]", func() { f := framework.NewDefaultFramework("disruptive-pv") var ( @@ -62,7 +62,7 @@ var _ = framework.KubeDescribe("PersistentVolumes:Disruptive", func() { nfsServerConfig := VolumeTestConfig{ namespace: v1.NamespaceDefault, prefix: "nfs", - serverImage: "gcr.io/google_containers/volume-nfs:0.7", + serverImage: NfsServerImage, serverPorts: []int{2049}, serverArgs: []string{"-G", "777", "/exports"}, } @@ -151,7 +151,7 @@ var _ = framework.KubeDescribe("PersistentVolumes:Disruptive", func() { // Test loop executes each disruptiveTest iteratively. for _, test := range disruptiveTestTable { func(t disruptiveTest) { - It(t.testItStmt+" [Disruptive]", func() { + It(t.testItStmt, func() { By("Executing Spec") t.runTest(c, f, clientPod, pvc, pv) }) @@ -253,8 +253,5 @@ func kubeletCommand(kOp kubeletOpt, c clientset.Interface, pod *v1.Pod) { // podExec wraps RunKubectl to execute a bash cmd in target pod func podExec(pod *v1.Pod, bashExec string) (string, error) { - args := strings.Split(bashExec, " ") - cmd := []string{"exec", "--namespace=" + pod.Namespace, pod.Name} - cmd = append(cmd, args...) - return framework.RunKubectl(cmd...) + return framework.RunKubectl("exec", fmt.Sprintf("--namespace=%s", pod.Namespace), pod.Name, "--", "/bin/sh", "-c", bashExec) } diff --git a/test/e2e/persistent_volumes.go b/test/e2e/persistent_volumes.go index e2e8a03c33f..fbf5d97e1ef 100644 --- a/test/e2e/persistent_volumes.go +++ b/test/e2e/persistent_volumes.go @@ -27,7 +27,7 @@ import ( "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/apimachinery/registered" metav1 "k8s.io/kubernetes/pkg/apis/meta/v1" - clientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" + "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/pkg/types" "k8s.io/kubernetes/pkg/volume/util/volumehelper" "k8s.io/kubernetes/test/e2e/framework" @@ -509,7 +509,7 @@ var _ = framework.KubeDescribe("PersistentVolumes", func() { NFSconfig = VolumeTestConfig{ namespace: v1.NamespaceDefault, prefix: "nfs", - serverImage: "gcr.io/google_containers/volume-nfs:0.7", + serverImage: NfsServerImage, serverPorts: []int{2049}, serverArgs: []string{"-G", "777", "/exports"}, } diff --git a/test/e2e/volumes.go b/test/e2e/volumes.go index 3119b3d52d0..a59e132fc2d 100644 --- a/test/e2e/volumes.go +++ b/test/e2e/volumes.go @@ -49,7 +49,7 @@ import ( apierrs "k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/v1" metav1 "k8s.io/kubernetes/pkg/apis/meta/v1" - clientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" + "k8s.io/kubernetes/pkg/client/clientset_generated/clientset" "k8s.io/kubernetes/test/e2e/framework" "github.com/golang/glog" @@ -83,6 +83,15 @@ type VolumeTest struct { expectedContent string } +// Current supported images for e2e volume testing to be assigned to VolumeTestConfig.serverImage +const ( + NfsServerImage string = "gcr.io/google_containers/volume-nfs:0.8" + IscsiServerImage string = "gcr.io/google_containers/volume-iscsi:0.1" + GlusterfsServerImage string = "gcr.io/google_containers/volume-gluster:0.2" + CephServerImage string = "gcr.io/google_containers/volume-ceph:0.1" + RbdServerImage string = "gcr.io/google_containers/volume-rbd:0.1" +) + // Starts a container specified by config.serverImage and exports all // config.serverPorts from it. The returned pod should be used to get the server // IP address and create appropriate VolumeSource. @@ -384,7 +393,7 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { config := VolumeTestConfig{ namespace: namespace.Name, prefix: "nfs", - serverImage: "gcr.io/google_containers/volume-nfs:0.8", + serverImage: NfsServerImage, serverPorts: []int{2049}, } @@ -424,7 +433,7 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { config := VolumeTestConfig{ namespace: namespace.Name, prefix: "gluster", - serverImage: "gcr.io/google_containers/volume-gluster:0.2", + serverImage: GlusterfsServerImage, serverPorts: []int{24007, 24008, 49152}, } @@ -509,7 +518,7 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { config := VolumeTestConfig{ namespace: namespace.Name, prefix: "iscsi", - serverImage: "gcr.io/google_containers/volume-iscsi:0.1", + serverImage: IscsiServerImage, serverPorts: []int{3260}, serverVolumes: map[string]string{ // iSCSI container needs to insert modules from the host @@ -556,7 +565,7 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { config := VolumeTestConfig{ namespace: namespace.Name, prefix: "rbd", - serverImage: "gcr.io/google_containers/volume-rbd:0.1", + serverImage: RbdServerImage, serverPorts: []int{6789}, serverVolumes: map[string]string{ // iSCSI container needs to insert modules from the host @@ -634,7 +643,7 @@ var _ = framework.KubeDescribe("Volumes [Feature:Volumes]", func() { config := VolumeTestConfig{ namespace: namespace.Name, prefix: "cephfs", - serverImage: "gcr.io/google_containers/volume-ceph:0.1", + serverImage: CephServerImage, serverPorts: []int{6789}, }