Skip to content

Commit

Permalink
Follow up for WFFC test suite adjustments
Browse files Browse the repository at this point in the history
Previous PR does not make our test suite completely WFFC-friendly,
as it turns out more follow ups were needed.

Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
  • Loading branch information
akalenyu committed Mar 13, 2023
1 parent 7788c9c commit 02cdc10
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
18 changes: 11 additions & 7 deletions tests/cloner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ var _ = Describe("all clone tests", func() {
Expect(err).ToNot(HaveOccurred())
targetPvc, err := utils.WaitForPVC(f.K8sClient, targetDataVolume.Namespace, targetDataVolume.Name)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(targetDataVolume)

By("Wait for target PVC Bound phase")
utils.WaitForPersistentVolumeClaimPhase(f.K8sClient, f.Namespace.Name, v1.ClaimBound, targetPvc.Name)
Expand Down Expand Up @@ -583,10 +584,11 @@ var _ = Describe("all clone tests", func() {

targetDV := utils.NewDataVolumeCloneToBlockPVStorageAPI("target-dv", "2Gi", sourcePvc.Namespace, sourcePvc.Name, f.BlockSCName)

tagretDataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, targetDV)
targetDataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, targetDV)
Expect(err).ToNot(HaveOccurred())
targetPvc, err := utils.WaitForPVC(f.K8sClient, tagretDataVolume.Namespace, tagretDataVolume.Name)
targetPvc, err := utils.WaitForPVC(f.K8sClient, targetDataVolume.Namespace, targetDataVolume.Name)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(targetDataVolume)

By("Wait for target PVC Bound phase")
utils.WaitForPersistentVolumeClaimPhase(f.K8sClient, f.Namespace.Name, v1.ClaimBound, targetPvc.Name)
Expand Down Expand Up @@ -683,11 +685,7 @@ var _ = Describe("all clone tests", func() {

targetDv, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, targetDv)
Expect(err).ToNot(HaveOccurred())
// As of now, csi and smart clone check the values before the pvc is created, and the network clone
// checks it in the upload phase, so it needs a PVC, this might be improved
if cloneType == "network" {
f.ForceBindPvcIfDvIsWaitForFirstConsumer(targetDv)
}
f.ForceBindPvcIfDvIsWaitForFirstConsumer(targetDv)

f.ExpectEvent(f.Namespace.Name).Should(ContainSubstring(controller.ErrIncompatiblePVC))
})
Expand Down Expand Up @@ -1932,6 +1930,7 @@ var _ = Describe("all clone tests", func() {
controller.AddAnnotation(targetDV, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, targetNs.Name, targetDV)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

targetPvc, err := utils.WaitForPVC(f.K8sClient, dataVolume.Namespace, dataVolume.Name)
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -2642,6 +2641,11 @@ var _ = Describe("all clone tests", func() {
var i int
var err error

defaultSc := utils.DefaultStorageClass.GetName()
if crossNamespace && f.IsBindingModeWaitForFirstConsumer(&defaultSc) {
Skip("only host assisted is applicable with WFFC cross namespace")
}

targetNs := f.Namespace
if crossNamespace {
targetNamespace, err = f.CreateNamespace("cdi-cross-ns-snapshot-clone-test", nil)
Expand Down
19 changes: 16 additions & 3 deletions tests/csiclone_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package tests

import (
"context"
"fmt"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

cdiv1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
cc "kubevirt.io/containerized-data-importer/pkg/controller/common"
Expand Down Expand Up @@ -50,12 +52,13 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component][crit:high][rfe_id:
utils.ConfigureCloneStrategy(f.CrClient, f.CdiClient, f.CsiCloneSCName, originalProfileSpec, cdiv1.CloneStrategyCsiClone)

dataVolume, md5 := createDataVolume("dv-csi-clone-test-1", utils.DefaultImagePath, v1.PersistentVolumeFilesystem, f.CsiCloneSCName, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(string(cdiv1.CSICloneInProgress)))
// Wait for operation Succeeded
waitForDvPhase(cdiv1.Succeeded, dataVolume, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CloneSucceeded))
// Verify PVC's content
verifyPVC(dataVolume, f, utils.DefaultImagePath, md5)
// Verify csi clone took place
verifyCSIClone(dataVolume, f)
})

It("Verify DataVolume CSI Cloning - volumeMode block - Positive flow", func() {
Expand All @@ -67,12 +70,13 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component][crit:high][rfe_id:
utils.ConfigureCloneStrategy(f.CrClient, f.CdiClient, f.CsiCloneSCName, originalProfileSpec, cdiv1.CloneStrategyCsiClone)

dataVolume, expectedMd5 := createDataVolume("dv-csi-clone-test-1", utils.DefaultPvcMountPath, v1.PersistentVolumeBlock, f.CsiCloneSCName, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CSICloneInProgress))
// Wait for operation Succeeded
waitForDvPhase(cdiv1.Succeeded, dataVolume, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CloneSucceeded))
// Verify PVC's content
verifyPVC(dataVolume, f, utils.DefaultPvcMountPath, expectedMd5)
// Verify csi clone took place
verifyCSIClone(dataVolume, f)
})

It("[posneg:negative][test_id:6655] Support for CSI Clone strategy in storage profile with SC HPP - negative", func() {
Expand Down Expand Up @@ -126,12 +130,14 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component][crit:high][rfe_id:
Expect(err).ToNot(HaveOccurred())

By("Verify clone completed after quota increase")
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(string(cdiv1.CSICloneInProgress)))
// Wait for operation Succeeded
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)
waitForDvPhase(cdiv1.Succeeded, dataVolume, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CloneSucceeded))
// Verify PVC's content
verifyPVC(dataVolume, f, utils.DefaultImagePath, md5)
// Verify csi clone took place
verifyCSIClone(dataVolume, f)

err = f.DeleteStorageQuota()
Expect(err).ToNot(HaveOccurred())
Expand All @@ -158,3 +164,10 @@ func createDataVolumeDontWait(dataVolumeName, testPath string, volumeMode v1.Per

return dataVolume, md5
}

func verifyCSIClone(dataVolume *cdiv1.DataVolume, f *framework.Framework) {
targetPvc, err := f.K8sClient.CoreV1().PersistentVolumeClaims(dataVolume.Namespace).Get(context.TODO(), dataVolume.Name, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(targetPvc.Spec.DataSource.Kind).To(Equal("PersistentVolumeClaim"))
Expect(targetPvc.Spec.DataSourceRef.Kind).To(Equal("PersistentVolumeClaim"))
}
1 change: 1 addition & 0 deletions tests/datavolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",
By(fmt.Sprintf("creating new datavolume %s", dataVolume.Name))
dataVolume, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

By(fmt.Sprintf("waiting for datavolume to match phase %s", string(phase)))
err = utils.WaitForDataVolumePhase(f, f.Namespace.Name, phase, dataVolume.Name)
Expand Down
6 changes: 5 additions & 1 deletion tests/external_population_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ var _ = Describe("Population tests", func() {
controller.AddAnnotation(dataVolume, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

By("Verifying pvc was created")
pvc, err := utils.WaitForPVC(f.K8sClient, dataVolume.Namespace, dataVolume.Name)
Expand Down Expand Up @@ -249,6 +250,7 @@ var _ = Describe("Population tests", func() {
controller.AddAnnotation(dataVolume, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

By("Verifying pvc was created")
targetPvc, err := utils.WaitForPVC(f.K8sClient, dataVolume.Namespace, dataVolume.Name)
Expand Down Expand Up @@ -320,10 +322,12 @@ var _ = Describe("Population tests", func() {
}, timeout, pollingInterval).Should(BeTrue())

By(fmt.Sprintf("Creating target datavolume %s", dataVolumeName))
dataVolume := utils.NewDataVolumeWithExternalPopulationAndStorageSpec(dataVolumeName, "100Mi", f.SnapshotSCName, corev1.PersistentVolumeMode(corev1.PersistentVolumeFilesystem), dataSource, nil)
// PVC API because some provisioners only allow exact match between source size and restore size
dataVolume := utils.NewDataVolumeWithExternalPopulation(dataVolumeName, snapshot.Status.RestoreSize.String(), f.SnapshotSCName, corev1.PersistentVolumeMode(corev1.PersistentVolumeFilesystem), dataSource, nil)
controller.AddAnnotation(dataVolume, controller.AnnDeleteAfterCompletion, "false")
dataVolume, err = utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

By("Verifying pvc was created")
targetPvc, err := utils.WaitForPVC(f.K8sClient, dataVolume.Namespace, dataVolume.Name)
Expand Down
1 change: 1 addition & 0 deletions tests/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ var _ = Describe("Importer Test Suite-Block_device", func() {
dataVolume.Annotations[controller.AnnPodRetainAfterCompletion] = "true"
dataVolume, err := utils.CreateDataVolumeFromDefinition(f.CdiClient, f.Namespace.Name, dataVolume)
Expect(err).ToNot(HaveOccurred())
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)

var importer *v1.Pod
By("Find importer pod")
Expand Down
1 change: 1 addition & 0 deletions tests/smartclone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]SmartClone tests",
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.SnapshotForSmartCloneInProgress))
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.SmartClonePVCInProgress))
// Wait for operation Succeeded
f.ForceBindPvcIfDvIsWaitForFirstConsumer(dataVolume)
waitForDvPhase(cdiv1.Succeeded, dataVolume, f)
f.ExpectEvent(dataVolume.Namespace).Should(ContainSubstring(controller.CloneSucceeded))
// Verify PVC's content
Expand Down

0 comments on commit 02cdc10

Please sign in to comment.