mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-23 21:40:20 +00:00
e2e: update E2E testing for snapshot
with new implemntation when user creates a snapshot in backend we are creating rbd image, we need to validate the total images count in backend when creating snapshots and clones. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
567b2ab280
commit
47fb5f2299
89
e2e/rbd.go
89
e2e/rbd.go
@ -252,7 +252,7 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
|
||||
pvc.Namespace = f.UniqueName
|
||||
e2elog.Logf("The PVC template %+v", pvc)
|
||||
e2elog.Logf("The PVC template %+v", pvc)
|
||||
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
@ -263,33 +263,92 @@ var _ = Describe("RBD", func() {
|
||||
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
||||
Fail("validate backend image failed")
|
||||
}
|
||||
totalCount := 5
|
||||
snap := getSnapshot(snapshotPath)
|
||||
snap.Namespace = f.UniqueName
|
||||
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||
err = createSnapshot(&snap, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
pool := defaultRBDPool
|
||||
snapList, err := listSnapshots(f, pool, images[0])
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
if len(snapList) != 1 {
|
||||
e2elog.Logf("backend snapshot not matching kubernetes snap count,snap count = % kubernetes snap count %d", len(snapList), 1)
|
||||
Fail("validate backend snapshot failed")
|
||||
// create snapshot
|
||||
for i := 0; i < totalCount; i++ {
|
||||
snap.Name = fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = createSnapshot(&snap, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
||||
imageList := listRBDImages(f)
|
||||
// total images in cluster is 1 parent rbd image+ total snaps
|
||||
if len(imageList) != totalCount+1 {
|
||||
e2elog.Logf("backend images not matching kubernetes pvc,snap count,image count %d kubernetes resource count %d", len(imageList), totalCount+1)
|
||||
Fail("validate backend images failed")
|
||||
}
|
||||
|
||||
err = deleteSnapshot(&snap, deployTimeout)
|
||||
pvcClone, err := loadPVC(pvcClonePath)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
appClone, err := loadApp(appClonePath)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
// create clone and bind it to an app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
pvcClone.Spec.DataSource.Name = name
|
||||
pvcClone.Namespace = f.UniqueName
|
||||
appClone.Namespace = f.UniqueName
|
||||
err = createPVCAndApp(name, f, pvcClone, appClone, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
imageList = listRBDImages(f)
|
||||
// total images in cluster is 1 parent rbd image+ total
|
||||
// snaps+ total clones
|
||||
totalCloneCount := totalCount + totalCount + 1
|
||||
if len(imageList) != totalCloneCount {
|
||||
e2elog.Logf("backend images not matching kubernetes resource count,image count %d kubernetes resource count %d", len(imageList), totalCount+totalCount+1)
|
||||
Fail("validate backend images failed")
|
||||
}
|
||||
|
||||
// delete parent pvc
|
||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
|
||||
imageList = listRBDImages(f)
|
||||
totalSnapCount := totalCount + totalCount
|
||||
// total images in cluster is total snaps+ total clones
|
||||
if len(imageList) != totalSnapCount {
|
||||
e2elog.Logf("backend images not matching kubernetes resource count,image count %d kubernetes resource count %d", len(imageList), totalCount+totalCount)
|
||||
Fail("validate backend images failed")
|
||||
}
|
||||
for i := 0; i < totalCount; i++ {
|
||||
snap.Name = fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
err = deleteSnapshot(&snap, deployTimeout)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
imageList = listRBDImages(f)
|
||||
if len(imageList) != totalCount {
|
||||
e2elog.Logf("backend images not matching kubernetes snap count,image count %d kubernetes resource count %d", len(imageList), totalCount)
|
||||
Fail("validate backend images failed")
|
||||
}
|
||||
// create clone and bind it to an app
|
||||
for i := 0; i < totalCount; i++ {
|
||||
name := fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||
pvcClone.Spec.DataSource.Name = name
|
||||
pvcClone.Namespace = f.UniqueName
|
||||
appClone.Namespace = f.UniqueName
|
||||
err = deletePVCAndApp(name, f, pvcClone, appClone)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -2,7 +2,6 @@ package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -18,13 +17,6 @@ import (
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
)
|
||||
|
||||
type snapInfo struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Size int64 `json:"size"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
func getSnapshotClass(path string) snapapi.VolumeSnapshotClass {
|
||||
sc := snapapi.VolumeSnapshotClass{}
|
||||
err := unmarshal(path, &sc)
|
||||
@ -121,17 +113,6 @@ func deleteSnapshot(snap *snapapi.VolumeSnapshot, t int) error {
|
||||
})
|
||||
}
|
||||
|
||||
func listSnapshots(f *framework.Framework, pool, imageName string) ([]snapInfo, error) {
|
||||
command := fmt.Sprintf("rbd snap ls %s/%s --format=json", pool, imageName)
|
||||
stdout, stdErr := execCommandInToolBoxPod(f, command, rookNamespace)
|
||||
Expect(stdErr).Should(BeEmpty())
|
||||
|
||||
var snapInfos []snapInfo
|
||||
|
||||
err := json.Unmarshal([]byte(stdout), &snapInfos)
|
||||
return snapInfos, err
|
||||
}
|
||||
|
||||
func createRBDSnapshotClass(f *framework.Framework) {
|
||||
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "snapshotclass.yaml")
|
||||
sc := getSnapshotClass(scPath)
|
||||
|
Loading…
Reference in New Issue
Block a user