Skip to content

Commit

Permalink
Add validation of backend rbd image and snapshots
Browse files Browse the repository at this point in the history
Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Jun 19, 2019
1 parent 096d7fa commit 66ff856
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 34 deletions.
46 changes: 42 additions & 4 deletions e2e/cephfs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo" // nolint
Expand Down Expand Up @@ -43,7 +44,9 @@ var _ = Describe("cephfs", func() {
cephfsFiles := getFilesinDirectory(cephfsDirPath)
for _, file := range cephfsFiles {
res, err := framework.RunKubectl("delete", "-f", cephfsDirPath+file.Name())
framework.Logf("failed to delete resource in %s with err %v", res, err)
if err != nil {
framework.Logf("failed to delete resource in %s with err %v", res, err)
}
}
deleteResource(cephfsExamplePath + "secret.yaml")
deleteResource(cephfsExamplePath + "storageclass.yaml")
Expand All @@ -52,6 +55,8 @@ var _ = Describe("cephfs", func() {

Context("Test cephfs CSI", func() {
It("Test cephfs CSI", func() {
pvcPath := cephfsExamplePath + "pvc.yaml"
appPath := cephfsExamplePath + "pod.yaml"
By("checking provisioner statefulset is running")
timeout := time.Duration(deployTimeout) * time.Minute
err := framework.WaitForStatefulSetReplicasReady(cephfsDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout)
Expand All @@ -67,16 +72,49 @@ var _ = Describe("cephfs", func() {

By("create and delete a PVC", func() {
By("create a PVC and Bind it to an app", func() {
pvcPath := cephfsExamplePath + "pvc.yaml"
appPath := cephfsExamplePath + "pod.yaml"
validatePVCAndAppBinding(pvcPath, appPath, f)

})

By("create a PVC and Bind it to an app with normal user", func() {
pvcPath := cephfsExamplePath + "pvc.yaml"
validateNormalUserPVCAccess(pvcPath, f)
})

By("create/delete multiple PVC and App", func() {
totalCount := 2
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
// create pvc and app
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := createPVCAndApp(name, f, pvc, app)
if err != nil {
Fail(err.Error())
}

}
// TODO add cephfs backend validation

// delete pvc and app
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := deletePVCAndApp(name, f, pvc, app)
if err != nil {
Fail(err.Error())
}

}
})

})

})
Expand Down
20 changes: 15 additions & 5 deletions e2e/deploy-rook.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,26 @@ func createRBDPool() {
}
func deleteFileSystem() {
commonPath := fmt.Sprintf("%s/%s", rookURL, "filesystem-test.yaml")
framework.RunKubectlOrDie("delete", "-f", commonPath)
_, err := framework.RunKubectl("delete", "-f", commonPath)
if err != nil {
framework.Logf("failed to delete file-system %v", err)
}
}

func deleteRBDPool() {
commonPath := fmt.Sprintf("%s/%s", rookURL, "pool-test.yaml")
framework.RunKubectlOrDie("delete", "-f", commonPath)
_, err := framework.RunKubectl("delete", "-f", commonPath)
if err != nil {
framework.Logf("failed to delete pool %v", err)
}
}

func deployOperator(c kubernetes.Interface) {
opPath := fmt.Sprintf("%s/%s", rookURL, "operator.yaml")

framework.RunKubectlOrDie("create", "-f", opPath)
err := waitForDaemonSets("rook-ceph-agent", rookNS, c, deployTimeout)
_, err := framework.RunKubectl("create", "-f", opPath)
Expect(err).Should(BeNil())
err = waitForDaemonSets("rook-ceph-agent", rookNS, c, deployTimeout)
Expect(err).Should(BeNil())
err = waitForDaemonSets("rook-discover", rookNS, c, deployTimeout)
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -109,5 +116,8 @@ func tearDownRook() {
// TODO need to add selector for cleanup validation
framework.Cleanup(opPath, rookNS)
commonPath := fmt.Sprintf("%s/%s", rookURL, "common.yaml")
framework.RunKubectlOrDie("delete", "-f", commonPath)
_, err := framework.RunKubectl("delete", "-f", commonPath)
if err != nil {
framework.Logf("failed to delete rook common %v", err)
}
}
85 changes: 74 additions & 11 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo" // nolint
Expand Down Expand Up @@ -46,7 +47,9 @@ var _ = Describe("RBD", func() {
rbdFiles := getFilesinDirectory(rbdDirPath)
for _, file := range rbdFiles {
res, err := framework.RunKubectl("delete", "-f", rbdDirPath+file.Name())
framework.Logf("failed to delete resource in %s with err %v", res, err)
if err != nil {
framework.Logf("failed to delete resource in %s with err %v", res, err)
}
}
deleteRBDPool()
deleteResource(rbdExamplePath + "secret.yaml")
Expand All @@ -56,6 +59,14 @@ var _ = Describe("RBD", func() {

Context("Test RBD CSI", func() {
It("Test RBD CSI", func() {
pvcPath := rbdExamplePath + "raw-block-pvc.yaml"
appPath := rbdExamplePath + "raw-block-pod.yaml"
rawPvcPath := rbdExamplePath + "raw-block-pvc.yaml"
rawAppPath := rbdExamplePath + "raw-block-pod.yaml"
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
appClonePath := rbdExamplePath + "pod-restore.yaml"
snapshotPath := rbdExamplePath + "snapshot.yaml"

By("checking provisioner statefulset is running")
timeout := time.Duration(deployTimeout) * time.Minute
err := framework.WaitForStatefulSetReplicasReady(rbdDeploymentName, namespace, f.ClientSet, 1*time.Second, timeout)
Expand All @@ -70,22 +81,15 @@ var _ = Describe("RBD", func() {
}

By("create a PVC and Bind it to an app", func() {
pvcPath := rbdExamplePath + "pvc.yaml"
appPath := rbdExamplePath + "pod.yaml"
validatePVCAndAppBinding(pvcPath, appPath, f)
})

By("create a PVC and Bind it to an app with normal user", func() {
pvcPath := rbdExamplePath + "pvc.yaml"
validateNormalUserPVCAccess(pvcPath, f)
})

By("create a PVC clone and Bind it to an app", func() {
createRBDSnapshotClass(f)
pvcPath := rbdExamplePath + "pvc.yaml"
pvcClonePath := rbdExamplePath + "pvc-restore.yaml"
appClonePath := rbdExamplePath + "pod-restore.yaml"
snapshotPath := rbdExamplePath + "snapshot.yaml"
pvc, err := loadPVC(pvcPath)
if err != nil {
Fail(err.Error())
Expand All @@ -97,6 +101,12 @@ var _ = Describe("RBD", func() {
if err != nil {
Fail(err.Error())
}
// validate created backend rbd images
images := listRBDImages(f)
if len(images) != 1 {
framework.Logf("backend image count %d expected image count %d", len(images), 1)
Fail("validate backend image failed")
}
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
snap.Spec.Source.Name = pvc.Name
Expand All @@ -105,6 +115,14 @@ var _ = Describe("RBD", func() {
if err != nil {
Fail(err.Error())
}
snapList, err := listSnapshots(f, "replicapool", images[0])
if err != nil {
Fail(err.Error())
}
if len(snapList) != 1 {
framework.Logf("backend snapshot not matching kube snap count,snap count = % kube snap count %d", len(snapList), 1)
Fail("validate backend snapshot failed")
}

validatePVCAndAppBinding(pvcClonePath, appClonePath, f)

Expand All @@ -119,9 +137,54 @@ var _ = Describe("RBD", func() {
})

By("create a block type PVC and Bind it to an app", func() {
pvcPath := rbdExamplePath + "raw-block-pvc.yaml"
appPath := rbdExamplePath + "raw-block-pod.yaml"
validatePVCAndAppBinding(pvcPath, appPath, f)
validatePVCAndAppBinding(rawPvcPath, rawAppPath, f)
})

By("create/delete multiple PVC and App", func() {
totalCount := 2
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
// create pvc and app
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := createPVCAndApp(name, f, pvc, app)
if err != nil {
Fail(err.Error())
}

}
// validate created backend rbd images
images := listRBDImages(f)
if len(images) != totalCount {
framework.Logf("backend image creation not matching pvc count, image count = % pvc count %d", len(images), totalCount)
Fail("validate multiple pvc failed")
}

// delete pvc and app
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
err := deletePVCAndApp(name, f, pvc, app)
if err != nil {
Fail(err.Error())
}

}

// validate created backend rbd images
images = listRBDImages(f)
if len(images) > 0 {
framework.Logf("left out rbd backend images count %d", len(images))
Fail("validate multiple pvc failed")
}
})
})
})
Expand Down
Loading

0 comments on commit 66ff856

Please sign in to comment.