@@ -49,13 +49,8 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
4949 frameworkEntity := framework .NewFramework ("virtual-machine-restore-operation" )
5050 helper := NewVMOPRestoreTestHelper (frameworkEntity )
5151
52- BeforeAll (func () {
53- frameworkEntity .Before ()
54- })
55-
56- AfterAll (func () {
57- frameworkEntity .After ()
58- })
52+ frameworkEntity .BeforeAll ()
53+ frameworkEntity .AfterAll ()
5954
6055 Context ("Preparing resources" , func () {
6156 It ("Applying resources" , func () {
@@ -97,15 +92,17 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
9792 helper .VMOPDryRun = helper .GenerateRestoreVMOP (
9893 "vmop-dryrun" , frameworkEntity .Namespace ().Name ,
9994 helper .VMSnapshot .Name ,
95+ helper .VM .Name ,
10096 v1alpha2 .VMOPRestoreModeDryRun ,
10197 )
10298 err := frameworkEntity .Clients .GenericClient ().Create (context .Background (), helper .VMOPDryRun )
10399 Expect (err ).ShouldNot (HaveOccurred ())
104100 })
105101
106- It ("Dry run restore VMOP must be ??? " , func () {
102+ It ("Dry run restore VMOP must be Completed " , func () {
107103 Eventually (func (g Gomega ) {
108- // ???
104+ helper .UpdateState (g )
105+ g .Expect (helper .VMOPDryRun .Status .Phase ).Should (Equal (v1alpha2 .VMOPPhaseCompleted ))
109106 }, 120 * time .Second , 1 * time .Second ).Should (Succeed ())
110107 })
111108 })
@@ -132,23 +129,25 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
132129 })
133130 })
134131
135- // Context("Restore in ??? mode", func() {
136- // It("Creating VMOP", func() {
137- // helper.VMOPDryRun = helper.GenerateRestoreVMOP(
138- // "vmop-dryrun", frameworkEntity.Namespace().Name,
139- // helper.VMSnapshot.Name,
140- // v1alpha2.VMOPRestoreModeDryRun,
141- // )
142- // err := frameworkEntity.Clients.GenericClient().Create(context.Background(), helper.VMOPDryRun)
143- // Expect(err).ShouldNot(HaveOccurred())
144- // })
132+ Context ("Restore in BestEffort mode" , func () {
133+ It ("Creating VMOP" , func () {
134+ helper .VMOPBestEffort = helper .GenerateRestoreVMOP (
135+ "vmop-besteffort" , frameworkEntity .Namespace ().Name ,
136+ helper .VMSnapshot .Name ,
137+ helper .VM .Name ,
138+ v1alpha2 .VMOPRestoreModeBestEffort ,
139+ )
140+ err := frameworkEntity .Clients .GenericClient ().Create (context .Background (), helper .VMOPBestEffort )
141+ Expect (err ).ShouldNot (HaveOccurred ())
142+ })
145143
146- // It("Dry run restore VMOP must be ???", func() {
147- // Eventually(func(g Gomega) {
148- // // ???
149- // }, 120*time.Second, 1*time.Second).Should(Succeed())
150- // })
151- // })
144+ It ("BestEffort restore VMOP must be Completed" , func () {
145+ Eventually (func (g Gomega ) {
146+ helper .UpdateState (g )
147+ g .Expect (helper .VMOPBestEffort .Status .Phase ).Should (Equal (v1alpha2 .VMOPPhaseCompleted ))
148+ }, 120 * time .Second , 1 * time .Second ).Should (Succeed ())
149+ })
150+ })
152151
153152 // Context("Do something", func() {
154153 // // ???
@@ -172,9 +171,9 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
172171 // })
173172 // })
174173
175- Context ("kek" , func () {
176- time .Sleep (300 * time .Second )
177- })
174+ // Context("kek", func() {
175+ // time.Sleep(200 * time.Second)
176+ // })
178177})
179178
180179type VMOPRestoreTestHelper struct {
@@ -278,7 +277,7 @@ runcmd:
278277- [bash, -c, "systemctl start qemu-guest-agent"]`
279278
280279 return vmbuilder .New (
281- vmbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
280+ vmbuilder .WithName (name ),
282281 vmbuilder .WithNamespace (namespace ),
283282 vmbuilder .WithBlockDeviceRefs (blockDeviceRefs ... ),
284283 vmbuilder .WithLiveMigrationPolicy (liveMigrationPolicy ),
@@ -295,15 +294,15 @@ runcmd:
295294
296295func (h * VMOPRestoreTestHelper ) GenerateVDBlank (name , namespace , size string ) * v1alpha2.VirtualDisk {
297296 return vdbuilder .New (
298- vdbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
297+ vdbuilder .WithName (name ),
299298 vdbuilder .WithNamespace (namespace ),
300299 vdbuilder .WithSize (ptr .To (resource .MustParse (size ))),
301300 )
302301}
303302
304303func (h * VMOPRestoreTestHelper ) GenerateVDFromHttp (name , namespace , size , url string ) * v1alpha2.VirtualDisk {
305304 return vdbuilder .New (
306- vdbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
305+ vdbuilder .WithName (name ),
307306 vdbuilder .WithNamespace (namespace ),
308307 vdbuilder .WithSize (ptr .To (resource .MustParse (size ))),
309308 vdbuilder .WithDataSourceHTTPWithOnlyURL (url ),
@@ -312,7 +311,7 @@ func (h *VMOPRestoreTestHelper) GenerateVDFromHttp(name, namespace, size, url st
312311
313312func (h * VMOPRestoreTestHelper ) GenerateVI (name , namespace , url string ) * v1alpha2.VirtualImage {
314313 return vibuilder .New (
315- vibuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
314+ vibuilder .WithName (name ),
316315 vibuilder .WithNamespace (namespace ),
317316 vibuilder .WithDataSourceHTTPWithOnlyURL (url ),
318317 vibuilder .WithStorageType (ptr .To (v1alpha2 .StorageContainerRegistry )),
@@ -321,14 +320,14 @@ func (h *VMOPRestoreTestHelper) GenerateVI(name, namespace, url string) *v1alpha
321320
322321func (h * VMOPRestoreTestHelper ) GenerateCVI (name , url string ) * v1alpha2.ClusterVirtualImage {
323322 return cvibuilder .New (
324- cvibuilder .WithName (fmt .Sprintf ("%s-%s " , name , framework . GetCommitHash () )),
323+ cvibuilder .WithGenerateName (fmt .Sprintf ("%s-" , name )),
325324 cvibuilder .WithDataSourceHTTPWithOnlyURL (url ),
326325 )
327326}
328327
329328func (h * VMOPRestoreTestHelper ) GenerateVMBDA (name , namespace , vmName string , bdRef v1alpha2.VMBDAObjectRef ) * v1alpha2.VirtualMachineBlockDeviceAttachment {
330329 return vmbdabuilder .New (
331- vmbdabuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
330+ vmbdabuilder .WithName (name ),
332331 vmbdabuilder .WithNamespace (namespace ),
333332 vmbdabuilder .WithVMName (vmName ),
334333 vmbdabuilder .WithBlockDeviceRef (bdRef ),
@@ -341,25 +340,26 @@ func (h *VMOPRestoreTestHelper) GenerateVMSnapshot(
341340 keepIpAddress v1alpha2.KeepIPAddress ,
342341) * v1alpha2.VirtualMachineSnapshot {
343342 return vmsnapshotbuilder .New (
344- vmsnapshotbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
343+ vmsnapshotbuilder .WithName (name ),
345344 vmsnapshotbuilder .WithNamespace (namespace ),
346345 vmsnapshotbuilder .WithVm (vmName ),
347346 vmsnapshotbuilder .WithKeepIpAddress (keepIpAddress ),
348347 vmsnapshotbuilder .WithRequiredConsistency (requiredConsistency ),
349348 )
350349}
351350
352- func (h * VMOPRestoreTestHelper ) GenerateRestoreVMOP (name , namespace , vmSnapshotName string , restoreMode v1alpha2.VMOPRestoreMode ) * v1alpha2.VirtualMachineOperation {
351+ func (h * VMOPRestoreTestHelper ) GenerateRestoreVMOP (name , namespace , vmSnapshotName , vmName string , restoreMode v1alpha2.VMOPRestoreMode ) * v1alpha2.VirtualMachineOperation {
353352 restoreSpec := & v1alpha2.VirtualMachineOperationRestoreSpec {
354353 VirtualMachineSnapshotName : vmSnapshotName ,
355354 Mode : restoreMode ,
356355 }
357356
358357 return vmopbuilder .New (
359- vmopbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
358+ vmopbuilder .WithName (name ),
360359 vmopbuilder .WithNamespace (namespace ),
361360 vmopbuilder .WithType (v1alpha2 .VMOPTypeRestore ),
362361 vmopbuilder .WithRestoreSpec (restoreSpec ),
362+ vmopbuilder .WithVirtualMachine (vmName ),
363363 )
364364}
365365
0 commit comments