test: migrate vdsnapshots e2e to new framefork#2350
Conversation
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
| "github.com/deckhouse/virtualization/test/e2e/internal/framework" | ||
| ) | ||
|
|
||
| // GetDefaultStorageClass loads cluster StorageClasses and returns the current default one. |
There was a problem hiding this comment.
Use the DefaultStorageClass config field. The default storage class is checked in the common pre-check.
| }).WithTimeout(timeout).WithPolling(time.Second).Should(Succeed()) | ||
| } | ||
|
|
||
| func IsDiskAttachedToVM(vm *v1alpha2.VirtualMachine, vd *v1alpha2.VirtualDisk) bool { |
| ctxVMWatch, cancelVMWatch := context.WithCancel(ctx) | ||
| defer cancelVMWatch() | ||
| vmWatchErrCh := make(chan error, 1) | ||
| var vmWasFrozen atomic.Bool | ||
| go func() { | ||
| wasFrozen, err := ensureVMWasFrozenInProgress( | ||
| ctxVMWatch, | ||
| f.VirtClient().VirtualMachines(f.Namespace().Name), | ||
| vm, | ||
| ) | ||
| vmWasFrozen.Store(wasFrozen) | ||
| vmWatchErrCh <- err | ||
| }() |
| defer cancelVMWatch() | ||
| vmWatchErrCh := make(chan error, 1) | ||
| var vmWasFrozen atomic.Bool | ||
| go func() { |
There was a problem hiding this comment.
Use Ginkgo Recovery when working with goroutines.
| volumeSnapshot := &unstructured.Unstructured{} | ||
| volumeSnapshot.SetAPIVersion("snapshot.storage.k8s.io/v1") | ||
| volumeSnapshot.SetKind("VolumeSnapshot") | ||
| err = f.GenericClient().Get(ctx, crclient.ObjectKey{ | ||
| Namespace: actualVDSnapshot.Namespace, | ||
| Name: actualVDSnapshot.Status.VolumeSnapshotName, | ||
| }, volumeSnapshot) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| readyToUse, found, err := unstructured.NestedBool(volumeSnapshot.Object, "status", "readyToUse") | ||
| Expect(err).NotTo(HaveOccurred()) | ||
| Expect(found).To(BeTrue(), "VolumeSnapshot status.readyToUse must be present") | ||
| Expect(readyToUse).To(BeTrue(), "VolumeSnapshot status.readyToUse must be true") |
There was a problem hiding this comment.
Is this required in the test?
| It("validates snapshots for a disk with no consumer", func() { | ||
| By("Environment preparation") | ||
| defaultSC, scList := util.GetDefaultStorageClass(ctx, f) | ||
| immediateSC := config.FindImmediateStorageClass(defaultSC, scList) |
There was a problem hiding this comment.
Use the ImmediateStorageClass config field. The immediate storage class is checked in the immediate sc pre-check.
| vmWatchErrCh <- err | ||
| }() | ||
|
|
||
| vdSnapshots := burstVDSnapshotsCreation(ctx, f, []*v1alpha2.VirtualDisk{vdRoot, vdAttach}, 5) |
| vmWatchErrCh := make(chan error, 1) | ||
| var vmWasFrozen atomic.Bool | ||
| go func() { | ||
| wasFrozen, err := ensureVMWasFrozenInProgress( |
There was a problem hiding this comment.
It seems that Eventually is sufficient for this test case.
|
|
||
| const vdSnapshotNSPrefix = "virtual-disk-snapshots" | ||
|
|
||
| var _ = Describe("VirtualDiskSnapshots", Label(precheck.PrecheckImmediateStorageClass, precheck.PrecheckSnapshot), func() { |
There was a problem hiding this comment.
Without ordering, all It containers will run simultaneously when Ginkgo runs in parallel. If you want to run it in parallel, split it.
| "github.com/deckhouse/virtualization/test/e2e/internal/util" | ||
| ) | ||
|
|
||
| const vdSnapshotNSPrefix = "virtual-disk-snapshots" |
There was a problem hiding this comment.
Move it under Describe or delete it if the test cases will be split.
Description
Migrate vdsnapshots e2e to new framefork.
Why do we need it, and what problem does it solve?
What is the expected result?
Checklist
Changelog entries