@@ -49,13 +49,8 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
49
49
frameworkEntity := framework .NewFramework ("virtual-machine-restore-operation" )
50
50
helper := NewVMOPRestoreTestHelper (frameworkEntity )
51
51
52
- BeforeAll (func () {
53
- frameworkEntity .Before ()
54
- })
55
-
56
- AfterAll (func () {
57
- frameworkEntity .After ()
58
- })
52
+ frameworkEntity .BeforeAll ()
53
+ frameworkEntity .AfterAll ()
59
54
60
55
Context ("Preparing resources" , func () {
61
56
It ("Applying resources" , func () {
@@ -97,15 +92,17 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
97
92
helper .VMOPDryRun = helper .GenerateRestoreVMOP (
98
93
"vmop-dryrun" , frameworkEntity .Namespace ().Name ,
99
94
helper .VMSnapshot .Name ,
95
+ helper .VM .Name ,
100
96
v1alpha2 .VMOPRestoreModeDryRun ,
101
97
)
102
98
err := frameworkEntity .Clients .GenericClient ().Create (context .Background (), helper .VMOPDryRun )
103
99
Expect (err ).ShouldNot (HaveOccurred ())
104
100
})
105
101
106
- It ("Dry run restore VMOP must be ??? " , func () {
102
+ It ("Dry run restore VMOP must be Completed " , func () {
107
103
Eventually (func (g Gomega ) {
108
- // ???
104
+ helper .UpdateState (g )
105
+ g .Expect (helper .VMOPDryRun .Status .Phase ).Should (Equal (v1alpha2 .VMOPPhaseCompleted ))
109
106
}, 120 * time .Second , 1 * time .Second ).Should (Succeed ())
110
107
})
111
108
})
@@ -132,23 +129,25 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
132
129
})
133
130
})
134
131
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
+ })
145
143
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
+ })
152
151
153
152
// Context("Do something", func() {
154
153
// // ???
@@ -172,9 +171,9 @@ var _ = Describe("VirtualMachineRestoreOperation", Serial, ginkgoutil.CommonE2ET
172
171
// })
173
172
// })
174
173
175
- Context ("kek" , func () {
176
- time .Sleep (300 * time .Second )
177
- })
174
+ // Context("kek", func() {
175
+ // time.Sleep(200 * time.Second)
176
+ // })
178
177
})
179
178
180
179
type VMOPRestoreTestHelper struct {
@@ -278,7 +277,7 @@ runcmd:
278
277
- [bash, -c, "systemctl start qemu-guest-agent"]`
279
278
280
279
return vmbuilder .New (
281
- vmbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
280
+ vmbuilder .WithName (name ),
282
281
vmbuilder .WithNamespace (namespace ),
283
282
vmbuilder .WithBlockDeviceRefs (blockDeviceRefs ... ),
284
283
vmbuilder .WithLiveMigrationPolicy (liveMigrationPolicy ),
@@ -295,15 +294,15 @@ runcmd:
295
294
296
295
func (h * VMOPRestoreTestHelper ) GenerateVDBlank (name , namespace , size string ) * v1alpha2.VirtualDisk {
297
296
return vdbuilder .New (
298
- vdbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
297
+ vdbuilder .WithName (name ),
299
298
vdbuilder .WithNamespace (namespace ),
300
299
vdbuilder .WithSize (ptr .To (resource .MustParse (size ))),
301
300
)
302
301
}
303
302
304
303
func (h * VMOPRestoreTestHelper ) GenerateVDFromHttp (name , namespace , size , url string ) * v1alpha2.VirtualDisk {
305
304
return vdbuilder .New (
306
- vdbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
305
+ vdbuilder .WithName (name ),
307
306
vdbuilder .WithNamespace (namespace ),
308
307
vdbuilder .WithSize (ptr .To (resource .MustParse (size ))),
309
308
vdbuilder .WithDataSourceHTTPWithOnlyURL (url ),
@@ -312,7 +311,7 @@ func (h *VMOPRestoreTestHelper) GenerateVDFromHttp(name, namespace, size, url st
312
311
313
312
func (h * VMOPRestoreTestHelper ) GenerateVI (name , namespace , url string ) * v1alpha2.VirtualImage {
314
313
return vibuilder .New (
315
- vibuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
314
+ vibuilder .WithName (name ),
316
315
vibuilder .WithNamespace (namespace ),
317
316
vibuilder .WithDataSourceHTTPWithOnlyURL (url ),
318
317
vibuilder .WithStorageType (ptr .To (v1alpha2 .StorageContainerRegistry )),
@@ -321,14 +320,14 @@ func (h *VMOPRestoreTestHelper) GenerateVI(name, namespace, url string) *v1alpha
321
320
322
321
func (h * VMOPRestoreTestHelper ) GenerateCVI (name , url string ) * v1alpha2.ClusterVirtualImage {
323
322
return cvibuilder .New (
324
- cvibuilder .WithName (fmt .Sprintf ("%s-%s " , name , framework . GetCommitHash () )),
323
+ cvibuilder .WithGenerateName (fmt .Sprintf ("%s-" , name )),
325
324
cvibuilder .WithDataSourceHTTPWithOnlyURL (url ),
326
325
)
327
326
}
328
327
329
328
func (h * VMOPRestoreTestHelper ) GenerateVMBDA (name , namespace , vmName string , bdRef v1alpha2.VMBDAObjectRef ) * v1alpha2.VirtualMachineBlockDeviceAttachment {
330
329
return vmbdabuilder .New (
331
- vmbdabuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
330
+ vmbdabuilder .WithName (name ),
332
331
vmbdabuilder .WithNamespace (namespace ),
333
332
vmbdabuilder .WithVMName (vmName ),
334
333
vmbdabuilder .WithBlockDeviceRef (bdRef ),
@@ -341,25 +340,26 @@ func (h *VMOPRestoreTestHelper) GenerateVMSnapshot(
341
340
keepIpAddress v1alpha2.KeepIPAddress ,
342
341
) * v1alpha2.VirtualMachineSnapshot {
343
342
return vmsnapshotbuilder .New (
344
- vmsnapshotbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
343
+ vmsnapshotbuilder .WithName (name ),
345
344
vmsnapshotbuilder .WithNamespace (namespace ),
346
345
vmsnapshotbuilder .WithVm (vmName ),
347
346
vmsnapshotbuilder .WithKeepIpAddress (keepIpAddress ),
348
347
vmsnapshotbuilder .WithRequiredConsistency (requiredConsistency ),
349
348
)
350
349
}
351
350
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 {
353
352
restoreSpec := & v1alpha2.VirtualMachineOperationRestoreSpec {
354
353
VirtualMachineSnapshotName : vmSnapshotName ,
355
354
Mode : restoreMode ,
356
355
}
357
356
358
357
return vmopbuilder .New (
359
- vmopbuilder .WithName (fmt . Sprintf ( "%s-%s" , name , framework . GetCommitHash ()) ),
358
+ vmopbuilder .WithName (name ),
360
359
vmopbuilder .WithNamespace (namespace ),
361
360
vmopbuilder .WithType (v1alpha2 .VMOPTypeRestore ),
362
361
vmopbuilder .WithRestoreSpec (restoreSpec ),
362
+ vmopbuilder .WithVirtualMachine (vmName ),
363
363
)
364
364
}
365
365
0 commit comments