mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +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
73
e2e/rbd.go
73
e2e/rbd.go
@ -263,34 +263,93 @@ var _ = Describe("RBD", func() {
|
|||||||
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
e2elog.Logf("backend image count %d expected image count %d", len(images), 1)
|
||||||
Fail("validate backend image failed")
|
Fail("validate backend image failed")
|
||||||
}
|
}
|
||||||
|
totalCount := 5
|
||||||
snap := getSnapshot(snapshotPath)
|
snap := getSnapshot(snapshotPath)
|
||||||
snap.Namespace = f.UniqueName
|
snap.Namespace = f.UniqueName
|
||||||
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||||
|
// create snapshot
|
||||||
|
for i := 0; i < totalCount; i++ {
|
||||||
|
snap.Name = fmt.Sprintf("%s%d", f.UniqueName, i)
|
||||||
err = createSnapshot(&snap, deployTimeout)
|
err = createSnapshot(&snap, deployTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(err.Error())
|
Fail(err.Error())
|
||||||
}
|
}
|
||||||
pool := defaultRBDPool
|
}
|
||||||
snapList, err := listSnapshots(f, pool, images[0])
|
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
Fail(err.Error())
|
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")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
|
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)
|
err = deleteSnapshot(&snap, deployTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fail(err.Error())
|
Fail(err.Error())
|
||||||
}
|
}
|
||||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
}
|
||||||
|
|
||||||
|
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 {
|
if err != nil {
|
||||||
Fail(err.Error())
|
Fail(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
By("create a block type PVC and Bind it to an app", func() {
|
By("create a block type PVC and Bind it to an app", func() {
|
||||||
|
@ -2,7 +2,6 @@ package e2e
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -18,13 +17,6 @@ import (
|
|||||||
testutils "k8s.io/kubernetes/test/utils"
|
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 {
|
func getSnapshotClass(path string) snapapi.VolumeSnapshotClass {
|
||||||
sc := snapapi.VolumeSnapshotClass{}
|
sc := snapapi.VolumeSnapshotClass{}
|
||||||
err := unmarshal(path, &sc)
|
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) {
|
func createRBDSnapshotClass(f *framework.Framework) {
|
||||||
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "snapshotclass.yaml")
|
scPath := fmt.Sprintf("%s/%s", rbdExamplePath, "snapshotclass.yaml")
|
||||||
sc := getSnapshotClass(scPath)
|
sc := getSnapshotClass(scPath)
|
||||||
|
Loading…
Reference in New Issue
Block a user