mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-04 20:24:02 +00:00
BIAv2 async operations controller work
Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
@@ -47,6 +47,7 @@ import (
|
||||
"github.com/vmware-tanzu/velero/pkg/discovery"
|
||||
"github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/fake"
|
||||
informers "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions"
|
||||
"github.com/vmware-tanzu/velero/pkg/itemoperation"
|
||||
"github.com/vmware-tanzu/velero/pkg/metrics"
|
||||
"github.com/vmware-tanzu/velero/pkg/persistence"
|
||||
persistencemocks "github.com/vmware-tanzu/velero/pkg/persistence/mocks"
|
||||
@@ -75,6 +76,13 @@ func (b *fakeBackupper) BackupWithResolvers(logger logrus.FieldLogger, backup *p
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (b *fakeBackupper) FinalizeBackup(logger logrus.FieldLogger, backup *pkgbackup.Request, inBackupFile io.Reader, outBackupFile io.Writer,
|
||||
backupItemActionResolver framework.BackupItemActionResolverV2,
|
||||
asyncBIAOperations []*itemoperation.BackupOperation) error {
|
||||
args := b.Called(logger, backup, inBackupFile, outBackupFile, backupItemActionResolver, asyncBIAOperations)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func defaultBackup() *builder.BackupBuilder {
|
||||
return builder.ForBackup(velerov1api.DefaultNamespace, "backup-1")
|
||||
}
|
||||
@@ -597,7 +605,7 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
backupExists bool
|
||||
existenceCheckError error
|
||||
}{
|
||||
// Completed
|
||||
// FinalizingAfterPluginOperations
|
||||
{
|
||||
name: "backup with no backup location gets the default",
|
||||
backup: defaultBackup().Result(),
|
||||
@@ -625,12 +633,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -661,12 +668,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -700,12 +706,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -737,12 +742,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
Expiration: &metav1.Time{now.Add(10 * time.Minute)},
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
Expiration: &metav1.Time{now.Add(10 * time.Minute)},
|
||||
StartTimestamp: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -774,12 +778,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -812,12 +815,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -850,12 +852,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -888,12 +889,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.True(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -926,12 +926,11 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
DefaultVolumesToFsBackup: boolptr.False(),
|
||||
},
|
||||
Status: velerov1api.BackupStatus{
|
||||
Phase: velerov1api.BackupPhaseCompleted,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
CompletionTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
Phase: velerov1api.BackupPhaseFinalizingAfterPluginOperations,
|
||||
Version: 1,
|
||||
FormatVersion: "1.1.0",
|
||||
StartTimestamp: ×tamp,
|
||||
Expiration: ×tamp,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1079,13 +1078,16 @@ func TestProcessBackupCompletions(t *testing.T) {
|
||||
|
||||
// Ensure we have a CompletionTimestamp when uploading and that the backup name matches the backup in the object store.
|
||||
// Failures will display the bytes in buf.
|
||||
hasNameAndCompletionTimestamp := func(info persistence.BackupInfo) bool {
|
||||
hasNameAndCompletionTimestampIfCompleted := func(info persistence.BackupInfo) bool {
|
||||
buf := new(bytes.Buffer)
|
||||
buf.ReadFrom(info.Metadata)
|
||||
return info.Name == test.backup.Name &&
|
||||
strings.Contains(buf.String(), `"completionTimestamp": "2006-01-02T22:04:05Z"`)
|
||||
(!(strings.Contains(buf.String(), `"phase": "Completed"`) ||
|
||||
strings.Contains(buf.String(), `"phase": "Failed"`) ||
|
||||
strings.Contains(buf.String(), `"phase": "PartiallyFailed"`)) ||
|
||||
strings.Contains(buf.String(), `"completionTimestamp": "2006-01-02T22:04:05Z"`))
|
||||
}
|
||||
backupStore.On("PutBackup", mock.MatchedBy(hasNameAndCompletionTimestamp)).Return(nil)
|
||||
backupStore.On("PutBackup", mock.MatchedBy(hasNameAndCompletionTimestampIfCompleted)).Return(nil)
|
||||
|
||||
// add the test's backup to the informer/lister store
|
||||
require.NotNil(t, test.backup)
|
||||
|
||||
Reference in New Issue
Block a user