mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
e2e: add e2e test for rbd reattach metadata
Added E2E test case to verify metadata after PV is attached to a new PVC in different namespace. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
07aa9dea5c
commit
0530134c9a
21
e2e/rbd.go
21
e2e/rbd.go
@ -513,6 +513,7 @@ var _ = Describe("RBD", func() {
|
||||
})
|
||||
|
||||
By("reattach the old PV to a new PVC and check if PVC metadata is updated on RBD image", func() {
|
||||
reattachPVCNamespace := fmt.Sprintf("%s-2", f.Namespace.Name)
|
||||
pvc, err := loadPVC(pvcPath)
|
||||
if err != nil {
|
||||
e2elog.Failf("failed to load PVC: %v", err)
|
||||
@ -593,8 +594,15 @@ var _ = Describe("RBD", func() {
|
||||
// validate created backend rbd images
|
||||
validateRBDImageCount(f, 1, defaultRBDPool)
|
||||
validateOmapCount(f, 1, rbdType, defaultRBDPool, volumesType)
|
||||
// create namespace for reattach PVC, deletion will be taken care by framework
|
||||
ns, err := f.CreateNamespace(reattachPVCNamespace, nil)
|
||||
if err != nil {
|
||||
e2elog.Failf("failed to create namespace: %v", err)
|
||||
}
|
||||
|
||||
pvcObj.Name = "rbd-pvc-new"
|
||||
pvcObj.Namespace = ns.Name
|
||||
|
||||
// unset the resource version as should not be set on objects to be created
|
||||
pvcObj.ResourceVersion = ""
|
||||
err = createPVCAndvalidatePV(f.ClientSet, pvcObj, deployTimeout)
|
||||
@ -619,6 +627,19 @@ var _ = Describe("RBD", func() {
|
||||
e2elog.Failf("expected pvcName %q got %q", pvcObj.Name, pvcName)
|
||||
}
|
||||
|
||||
owner, stdErr, err := execCommandInToolBoxPod(f,
|
||||
fmt.Sprintf("rbd image-meta get %s --image=%s %s",
|
||||
rbdOptions(defaultRBDPool), imageList[0], pvcNamespaceKey),
|
||||
rookNamespace)
|
||||
if err != nil || stdErr != "" {
|
||||
e2elog.Failf("failed to get owner name %s/%s %s: err=%v stdErr=%q",
|
||||
rbdOptions(defaultRBDPool), imageList[0], pvcNamespaceKey, err, stdErr)
|
||||
}
|
||||
owner = strings.TrimSuffix(owner, "\n")
|
||||
if owner != pvcObj.Namespace {
|
||||
e2elog.Failf("expected pvcNamespace name %q got %q", pvcObj.Namespace, owner)
|
||||
}
|
||||
|
||||
patchBytes = []byte(`{"spec":{"persistentVolumeReclaimPolicy": "Delete"}}`)
|
||||
_, err = c.CoreV1().PersistentVolumes().Patch(
|
||||
context.TODO(),
|
||||
|
Loading…
Reference in New Issue
Block a user