@@ -97,40 +97,16 @@ var _ = Describe("Backup Deleter Test", func() {
9797
9898 })
9999
100- mockBackupForRestore := func (
101- testCtx * testutil.TestContext , actionSetName , backupPVCName string ,
102- mockBackupCompleted , useVolumeSnapshotBackup bool ,
103- backupType dpv1alpha1.BackupType ,
104- startTime , endTime string ,
105- backupName string ,
106- ) * dpv1alpha1.Backup {
107- backup := testdp .NewFakeBackup (testCtx , func (backup * dpv1alpha1.Backup ) {
108- if backup .Labels == nil {
109- backup .Labels = make (map [string ]string )
110- }
111- backup .Labels [dptypes .BackupTypeLabelKey ] = string (backupType )
112- backup .Labels [dptypes .BackupPolicyLabelKey ] = testdp .BackupPolicyName
113- if backupName != "" {
114- backup .Name = backupName
115- }
116- })
100+ mockBackupForRestore := func (testCtx * testutil.TestContext , actionSetName , backupPVCName string , mockBackupCompleted , useVolumeSnapshotBackup bool ) * dpv1alpha1.Backup {
101+ backup := testdp .NewFakeBackup (testCtx , nil )
117102 if mockBackupCompleted {
118103 // then mock backup to completed
119104 backupMethodName := testdp .BackupMethodName
120105 if useVolumeSnapshotBackup {
121106 backupMethodName = testdp .VSBackupMethodName
122107 }
123108 Expect (testapps .ChangeObjStatus (testCtx , backup , func () {
124- var end * metav1.Time
125- if endTime != "" {
126- endTime , _ := time .Parse (time .RFC3339 , endTime )
127- end = & metav1.Time {Time : endTime }
128- }
129- var start * metav1.Time
130- if startTime != "" {
131- startTime , _ := time .Parse (time .RFC3339 , startTime )
132- start = & metav1.Time {Time : startTime }
133- }
109+ endTime , _ := time .Parse (time .RFC3339 , "2023-01-01T10:00:00Z" )
134110 backup .Status .Phase = dpv1alpha1 .BackupPhaseCompleted
135111 backup .Status .PersistentVolumeClaimName = backupPVCName
136112 testdp .MockBackupStatusTarget (backup , dpv1alpha1 .PodSelectionStrategyAny )
@@ -139,8 +115,7 @@ var _ = Describe("Backup Deleter Test", func() {
139115 }
140116 backup .Status .TimeRange = & dpv1alpha1.BackupTimeRange {
141117 TimeZone : "+08:00" ,
142- Start : start ,
143- End : end ,
118+ End : & metav1.Time {Time : endTime },
144119 }
145120 testdp .MockBackupStatusMethod (backup , backupMethodName , testdp .DataVolumeName , actionSetName )
146121 })).Should (Succeed ())
@@ -150,7 +125,7 @@ var _ = Describe("Backup Deleter Test", func() {
150125
151126 initResources := func (reqCtx intctrlutil.RequestCtx , _ int , useVolumeSnapshot bool , change func (f * testdp.MockRestoreFactory )) (* RestoreManager , * BackupActionSet ) {
152127 By ("create a completed backup" )
153- backup := mockBackupForRestore (& testCtx , actionSet .Name , testdp .BackupPVCName , true , useVolumeSnapshot , dpv1alpha1 . BackupTypeFull , "" , "2023-01-01T10:00:00Z" , "" )
128+ backup := mockBackupForRestore (& testCtx , actionSet .Name , testdp .BackupPVCName , true , useVolumeSnapshot )
154129
155130 schedulingSpec := dpv1alpha1.SchedulingSpec {
156131 NodeName : nodeName ,
@@ -383,57 +358,6 @@ var _ = Describe("Backup Deleter Test", func() {
383358 })).Should (Succeed ())
384359 testPostReady (false )
385360 })
386-
387- Context ("BuildContinuousRestoreManager" , func () {
388- It ("respects UnifyFullAndContinuousRestore annotation" , func () {
389- By ("create a continuous backup" )
390- continuousBackup := mockBackupForRestore (
391- & testCtx , actionSet .Name , testdp .BackupPVCName , true , false , dpv1alpha1 .BackupTypeContinuous ,
392- "2023-01-01T09:00:00Z" , "2023-01-01T12:00:00Z" , "test-backup-continuous" ,
393- )
394-
395- By ("create a completed backup" )
396- _ = mockBackupForRestore (& testCtx , actionSet .Name , testdp .BackupPVCName , true , false , dpv1alpha1 .BackupTypeFull , "" , "2023-01-01T10:00:00Z" , "" )
397-
398- schedulingSpec := dpv1alpha1.SchedulingSpec {
399- NodeName : nodeName ,
400- }
401-
402- By ("create restore" )
403- restore := testdp .NewRestoreFactory (testCtx .DefaultNamespace , testdp .RestoreName ).
404- SetBackup (continuousBackup .Name , testCtx .DefaultNamespace ).
405- SetSchedulingSpec (schedulingSpec ).
406- Create (& testCtx ).
407- SetRestoreTime ("2023-01-01T11:30:00Z" ).
408- Get ()
409-
410- By ("create restore manager" )
411- reqCtx := getReqCtx ()
412- restoreMGR := NewRestoreManager (restore , recorder , k8sClient .Scheme (), k8sClient )
413- backupSet , err := restoreMGR .GetBackupActionSetByNamespaced (reqCtx , k8sClient , continuousBackup .Name , testCtx .DefaultNamespace )
414- Expect (err ).ShouldNot (HaveOccurred ())
415-
416- Expect (restoreMGR .BuildContinuousRestoreManager (reqCtx , k8sClient , * backupSet )).Should (Succeed ())
417- Expect (restoreMGR .PostReadyBackupSets ).Should (HaveLen (2 ))
418-
419- By ("set UnifyFullAndContinuousRestore annotation" )
420- Eventually (testapps .GetAndChangeObj (& testCtx , client .ObjectKeyFromObject (actionSet ), func (actionset * dpv1alpha1.ActionSet ) {
421- if actionset .Annotations == nil {
422- actionset .Annotations = make (map [string ]string )
423- }
424- actionset .Annotations [constant .SkipBaseBackupRestoreInPitrAnnotationKey ] = "true"
425- })).Should (Succeed ())
426-
427- By ("check length of backupsets" )
428- restoreMGR = NewRestoreManager (restore , recorder , k8sClient .Scheme (), k8sClient )
429- backupSet , err = restoreMGR .GetBackupActionSetByNamespaced (reqCtx , k8sClient , continuousBackup .Name , testCtx .DefaultNamespace )
430- Expect (err ).ShouldNot (HaveOccurred ())
431-
432- Expect (restoreMGR .BuildContinuousRestoreManager (reqCtx , k8sClient , * backupSet )).Should (Succeed ())
433- Expect (restoreMGR .PostReadyBackupSets ).Should (HaveLen (1 ))
434-
435- })
436- })
437361 })
438362
439363})
0 commit comments