From f0b3cee94a556f788cfdb66da9e6fffde4da6ac7 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 5 May 2020 09:23:24 +0530 Subject: [PATCH] e2e: define replicapool as constant the static check is failing as the replicapool is used in 3 or more places, we need to define a variable and use it. Signed-off-by: Madhu Rajanna --- e2e/rbd.go | 3 ++- e2e/staticpvc.go | 6 +++--- e2e/utils.go | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/e2e/rbd.go b/e2e/rbd.go index d6724416a..d70ade891 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -22,6 +22,7 @@ var ( rbdExamplePath = "../examples/rbd/" rbdDeploymentName = "csi-rbdplugin-provisioner" rbdDaemonsetName = "csi-rbdplugin" + defaultRBDPool = "replicapool" // Topology related variables nodeRegionLabel = "test.failure-domain/region" regionValue = "testregion" @@ -267,7 +268,7 @@ var _ = Describe("RBD", func() { if err != nil { Fail(err.Error()) } - pool := "replicapool" + pool := defaultRBDPool snapList, err := listSnapshots(f, pool, images[0]) if err != nil { Fail(err.Error()) diff --git a/e2e/staticpvc.go b/e2e/staticpvc.go index 0e4492a8a..4af6341b1 100644 --- a/e2e/staticpvc.go +++ b/e2e/staticpvc.go @@ -103,7 +103,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e fsID = strings.Trim(fsID, "\n") size := "4Gi" // create rbd image - cmd := fmt.Sprintf("rbd create %s --size=%d --pool=replicapool --image-feature=layering", rbdImageName, 4096) + cmd := fmt.Sprintf("rbd create %s --size=%d --pool=%s --image-feature=layering", rbdImageName, 4096, defaultRBDPool) _, e = execCommandInPod(f, cmd, rookNamespace, &listOpt) if e != "" { @@ -111,7 +111,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e } opt["clusterID"] = fsID opt["imageFeatures"] = "layering" - opt["pool"] = "replicapool" + opt["pool"] = defaultRBDPool opt["staticVolume"] = "true" pv := getStaticPV(pvName, rbdImageName, size, "csi-rbd-secret", cephCSINamespace, sc, "rbd.csi.ceph.com", isBlock, opt) @@ -155,7 +155,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e return err } - cmd = fmt.Sprintf("rbd rm %s --pool=replicapool", rbdImageName) + cmd = fmt.Sprintf("rbd rm %s --pool=%s", rbdImageName, defaultRBDPool) execCommandInPod(f, cmd, rookNamespace, &listOpt) return nil } diff --git a/e2e/utils.go b/e2e/utils.go index 9476a9b83..47de5c141 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -274,7 +274,7 @@ func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, en func createRBDStorageClass(c kubernetes.Interface, f *framework.Framework, scOptions, parameters map[string]string) { scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "storageclass.yaml") sc := getStorageClass(scPath) - sc.Parameters["pool"] = "replicapool" + sc.Parameters["pool"] = defaultRBDPool sc.Parameters["csi.storage.k8s.io/provisioner-secret-namespace"] = rookNamespace sc.Parameters["csi.storage.k8s.io/provisioner-secret-name"] = rbdProvisionerSecretName @@ -761,7 +761,7 @@ func validateEncryptedPVCAndAppBinding(pvcPath, appPath, kms string, f *framewor if err != nil { Fail(err.Error()) } - rbdImageSpec := fmt.Sprintf("replicapool/%s", imageData.imageName) + rbdImageSpec := fmt.Sprintf("%s/%s", defaultRBDPool, imageData.imageName) encryptedState, err := getImageMeta(rbdImageSpec, ".rbd.csi.ceph.com/encrypted", f) if err != nil { Fail(err.Error()) @@ -903,7 +903,7 @@ func listRBDImages(f *framework.Framework) []string { opt := metav1.ListOptions{ LabelSelector: "app=rook-ceph-tools", } - stdout, stdErr := execCommandInPod(f, "rbd ls --pool=replicapool --format=json", rookNamespace, &opt) + stdout, stdErr := execCommandInPod(f, fmt.Sprintf("rbd ls --pool=%s --format=json", defaultRBDPool), rookNamespace, &opt) Expect(stdErr).Should(BeEmpty()) var imgInfos []string @@ -973,7 +973,7 @@ func deleteBackingRBDImage(f *framework.Framework, pvc *v1.PersistentVolumeClaim LabelSelector: "app=rook-ceph-tools", } - cmd := fmt.Sprintf("rbd rm %s --pool=replicapool", imageData.imageName) + cmd := fmt.Sprintf("rbd rm %s --pool=%s", imageData.imageName, defaultRBDPool) execCommandInPod(f, cmd, rookNamespace, &opt) return nil } @@ -1030,7 +1030,7 @@ func pvcDeleteWhenPoolNotFound(pvcPath string, cephfs bool, f *framework.Framewo return err } // delete rbd pool - deletePool("replicapool", cephfs, f) + deletePool(defaultRBDPool, cephfs, f) } err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) return err