From b058926cf43465f81adef79114c553356fb1596c Mon Sep 17 00:00:00 2001 From: Ido Aharon Date: Thu, 2 Mar 2023 09:39:30 +0200 Subject: [PATCH] CSI clone and Cloning from snapshot source functional tests Signed-off-by: Ido Aharon --- tests/cloner_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/cloner_test.go b/tests/cloner_test.go index c3303d2fb6..c914d6f3a6 100644 --- a/tests/cloner_test.go +++ b/tests/cloner_test.go @@ -281,11 +281,13 @@ var _ = Describe("all clone tests", func() { DescribeTable("[test_id:1355]Should clone data across different namespaces", func(targetSize string) { pvcDef := utils.NewPVCDefinition(sourcePVCName, "1Gi", nil, nil) pvcDef.Namespace = f.Namespace.Name + sourcePvc = f.CreateAndPopulateSourcePVC(pvcDef, sourcePodFillerName, fillCommand+testFile+"; chmod 660 "+testBaseDir+testFile) targetNs, err := f.CreateNamespace(f.NsPrefix, map[string]string{ framework.NsPrefixLabel: f.NsPrefix, }) Expect(err).NotTo(HaveOccurred()) + f.AddNamespaceToDelete(targetNs) doFileBasedCloneTest(f, pvcDef, targetNs, "target-dv", targetSize) }, @@ -2654,6 +2656,8 @@ var _ = Describe("all clone tests", func() { for i = 0; i < repeat; i++ { dataVolume := utils.NewDataVolumeForSnapshotCloningAndStorageSpec(fmt.Sprintf("clone-from-snap-%d", i), size, snapshot.Namespace, snapshot.Name, nil, &volumeMode) + dataVolume.Labels = map[string]string{"test-label-1": "test-label-value-1"} + dataVolume.Annotations = map[string]string{"test-annotation-1": "test-annotation-value-1"} By(fmt.Sprintf("Create new datavolume %s which will clone from volumesnapshot", dataVolume.Name)) dataVolume, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, targetNs.Name, dataVolume) Expect(err).ToNot(HaveOccurred()) @@ -2671,6 +2675,9 @@ var _ = Describe("all clone tests", func() { Expect(ok).To(BeFalse()) Expect(pvc.Spec.DataSource.Kind).To(Equal("VolumeSnapshot")) Expect(pvc.Spec.DataSourceRef.Kind).To(Equal("VolumeSnapshot")) + // All labels and annotations passed + Expect(pvc.Labels["test-label-1"]).To(Equal("test-label-value-1")) + Expect(pvc.Annotations["test-annotation-1"]).To(Equal("test-annotation-value-1")) } By("Verify MD5 on one of the DVs") @@ -2868,6 +2875,9 @@ func doFileBasedCloneTest(f *framework.Framework, srcPVCDef *v1.PersistentVolume } // Create targetPvc in new NS. targetDV := utils.NewCloningDataVolume(targetDv, targetSize[0], srcPVCDef) + targetDV.Labels = map[string]string{"test-label-1": "test-label-key-1"} + targetDV.Annotations = map[string]string{"test-annotation-1": "test-annotation-key-1"} + dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, targetNs.Name, targetDV) Expect(err).ToNot(HaveOccurred()) @@ -2888,6 +2898,10 @@ func doFileBasedCloneTest(f *framework.Framework, srcPVCDef *v1.PersistentVolume es := resource.MustParse(targetSize[0]) Expect(es.Cmp(*targetPvc.Status.Capacity.Storage()) <= 0).To(BeTrue()) + + // All labels and annotations passed + Expect(targetPvc.Labels["test-label-1"]).To(Equal("test-label-key-1")) + Expect(targetPvc.Annotations["test-annotation-1"]).To(Equal("test-annotation-key-1")) } func doInUseCloneTest(f *framework.Framework, srcPVCDef *v1.PersistentVolumeClaim, targetNs *v1.Namespace, targetDv string) {