Skip to content

test: migrate vdsnapshots e2e to new framefork#2350

Open
eofff wants to merge 4 commits into
mainfrom
test/vd-snapshot-e2e-new-framework
Open

test: migrate vdsnapshots e2e to new framefork#2350
eofff wants to merge 4 commits into
mainfrom
test/vd-snapshot-e2e-new-framework

Conversation

@eofff
Copy link
Copy Markdown
Contributor

@eofff eofff commented May 14, 2026

Description

Migrate vdsnapshots e2e to new framefork.

Why do we need it, and what problem does it solve?

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vd
type: chore
summary: Migrate vdsnapshots e2e to new framefork.

Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
Valeriy Khorunzhin added 3 commits May 15, 2026 07:54
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>
@eofff eofff changed the title test: vd_snapshots new framefork test: migrate vdsnapshots e2e to new framefork May 15, 2026
@eofff eofff requested a review from hardcoretime May 15, 2026 08:20
@eofff eofff added this to the v1.9.0 milestone May 15, 2026
@eofff eofff marked this pull request as ready for review May 15, 2026 08:21
@eofff eofff requested a review from Isteb4k as a code owner May 15, 2026 08:21
"github.com/deckhouse/virtualization/test/e2e/internal/framework"
)

// GetDefaultStorageClass loads cluster StorageClasses and returns the current default one.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See IsVDAttached.

Comment on lines +83 to +95
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
}()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap it.

defer cancelVMWatch()
vmWatchErrCh := make(chan error, 1)
var vmWasFrozen atomic.Bool
go func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Ginkgo Recovery when working with goroutines.

Comment on lines +277 to +289
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")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

burst?

vmWatchErrCh := make(chan error, 1)
var vmWasFrozen atomic.Bool
go func() {
wasFrozen, err := ensureVMWasFrozenInProgress(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that Eventually is sufficient for this test case.


const vdSnapshotNSPrefix = "virtual-disk-snapshots"

var _ = Describe("VirtualDiskSnapshots", Label(precheck.PrecheckImmediateStorageClass, precheck.PrecheckSnapshot), func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it under Describe or delete it if the test cases will be split.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants