Skip to content

Commit a62125c

Browse files
author
Roman Sysoev
committed
fix(test): add immediate storage class support and GinkgoRecover
- Add PrecheckImmediateStorageClass label for phase transition tests - Get immediate storage class to ensure disk becomes Ready immediately - Register defer early to ensure verification runs on test failure - Add GinkgoRecover to handle panics in goroutine Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
1 parent e64c6ac commit a62125c

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

test/e2e/blockdevice/vd_phase_transitions.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/deckhouse/virtualization/test/e2e/internal/util"
3131
)
3232

33-
var _ = Describe("VirtualDiskPhaseTransitions", label.Slow(), Label(precheck.NoPrecheck), func() {
33+
var _ = Describe("VirtualDiskPhaseTransitions", label.Slow(), Label(precheck.PrecheckImmediateStorageClass), func() {
3434
var f *framework.Framework
3535

3636
BeforeEach(func() {
@@ -42,8 +42,13 @@ var _ = Describe("VirtualDiskPhaseTransitions", label.Slow(), Label(precheck.NoP
4242
It("tracks phase transitions during export", func() {
4343
var vd *v1alpha2.VirtualDisk
4444

45+
// Get immediate storage class for the test to ensure disk becomes Ready immediately
46+
sc := framework.GetConfig().StorageClass.ImmediateStorageClass
47+
Expect(sc).NotTo(BeNil(), "immediate storage class is required for this test")
48+
4549
By("Creating VirtualDisk from CVI", func() {
46-
vd = object.NewVDFromCVI("vd-test", f.Namespace().Name, object.PrecreatedCVIAlpineBIOS)
50+
vd = object.NewVDFromCVI("vd-test", f.Namespace().Name, object.PrecreatedCVIAlpineBIOS,
51+
object.WithStorageClass(&sc.Name))
4752

4853
err := f.CreateWithDeferredDeletion(context.Background(), vd)
4954
Expect(err).NotTo(HaveOccurred())
@@ -57,20 +62,19 @@ var _ = Describe("VirtualDiskPhaseTransitions", label.Slow(), Label(precheck.NoP
5762
watcher := util.WatchPhases(context.Background(), vd)
5863
Expect(watcher).NotTo(BeNil(), "failed to create event watcher for VirtualDisk")
5964

65+
// Register defer early to ensure verification runs even if test fails later
66+
defer util.VerifyPhaseTransitions(watcher,
67+
string(v1alpha2.DiskReady),
68+
string(v1alpha2.DiskExporting),
69+
string(v1alpha2.DiskReady))
70+
6071
By("Exporting VirtualDisk", func() {
6172
DataExport(f, "vd", vd.Name, "exported-disk-phases.img")
6273
})
6374

6475
By("Waiting for VirtualDisk to return to Ready after export", func() {
6576
util.UntilObjectPhase(string(v1alpha2.DiskReady), framework.LongTimeout, vd)
6677
})
67-
68-
DeferCleanup(func() {
69-
util.VerifyPhaseTransitions(watcher,
70-
string(v1alpha2.DiskReady),
71-
string(v1alpha2.DiskExporting),
72-
string(v1alpha2.DiskReady))
73-
})
7478
})
7579
})
7680
})

test/e2e/internal/object/vd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ func NewVDFromCVI(name, namespace, cviName string, opts ...vd.Option) *v1alpha2.
6464
baseOpts = append(baseOpts, opts...)
6565
return vd.New(baseOpts...)
6666
}
67+
68+
// WithStorageClass is an option to set storage class for VirtualDisk.
69+
func WithStorageClass(storageClass *string) vd.Option {
70+
return vd.WithStorageClass(storageClass)
71+
}

test/e2e/internal/util/event_watcher.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ func kindToResource(gvk schema.GroupVersionKind) (schema.GroupVersionResource, e
136136
}
137137

138138
func (ew *EventPhaseWatcher) run(ctx context.Context) {
139+
defer GinkgoRecover()
140+
139141
dynClient := framework.GetClients().DynamicClient()
140142

141143
watcher, err := dynClient.Resource(ew.gvr).

0 commit comments

Comments
 (0)