From 44da7ffb4e4d8861265f3ecd421cd06dfce9f34a Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Mon, 18 May 2020 18:37:58 +0530 Subject: [PATCH] e2e: Add testcase of invalid mount option Added a test case to cover unmap of rbd image if the mounting fails. if we pass the invalid mount option the expectation is that mounting of rbd image to stagingpath fails. as the unmap happens it should not block the rbd pvc deletion saying rbd image is in-use. Signed-off-by: Madhu Rajanna --- e2e/rbd.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/e2e/rbd.go b/e2e/rbd.go index 3dfce782f..74a38d9a2 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -568,6 +568,40 @@ var _ = Describe("RBD", func() { createRBDStorageClass(f.ClientSet, f, nil, nil) }) + // Mount pvc to pod with invalid mount option,expected that + // mounting will fail + By("Mount pvc to pod with invalid mount option", func() { + deleteResource(rbdExamplePath + "storageclass.yaml") + createRBDStorageClass(f.ClientSet, f, map[string]string{rbdmountOptions: "debug,invalidOption"}, nil) + pvc, err := loadPVC(pvcPath) + if err != nil { + Fail(err.Error()) + } + pvc.Namespace = f.UniqueName + + app, err := loadApp(appPath) + if err != nil { + Fail(err.Error()) + } + app.Namespace = f.UniqueName + err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) + if err != nil { + Fail(err.Error()) + } + // create an app and wait for 2 min for it to go to running state + err = createApp(f.ClientSet, app, 2) + if err == nil { + Fail("application should not go to running state due to invalid mount option") + } + err = deletePVCAndApp("", f, pvc, app) + if err != nil { + Fail(err.Error()) + } + + deleteResource(rbdExamplePath + "storageclass.yaml") + createRBDStorageClass(f.ClientSet, f, nil, nil) + }) + // Make sure this should be last testcase in this file, because // it deletes pool By("Create a PVC and Delete PVC when backend pool deleted", func() {