From 8e4d320b218850d02ee4387124f8f9db88c579b6 Mon Sep 17 00:00:00 2001 From: neha_gupta Date: Tue, 10 Oct 2023 19:15:12 +0530 Subject: [PATCH] remove start events from operations (#4442) remove start events from all operations #### Does this PR need a docs update or release note? - [ ] :no_entry: No #### Type of change - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * https://github.com/alcionai/corso/issues/4440 #### Test Plan - [ ] :muscle: Manual - [ ] :zap: Unit test --- src/internal/events/events.go | 16 ++++++---------- src/internal/operations/backup.go | 9 --------- src/internal/operations/export.go | 10 ---------- src/internal/operations/maintenance.go | 7 ------- src/internal/operations/restore.go | 10 ---------- src/internal/operations/restore_test.go | 1 - src/internal/operations/test/exchange_test.go | 8 -------- src/internal/operations/test/helper_test.go | 4 ---- src/internal/operations/test/onedrive_test.go | 8 -------- .../operations/test/restore_helper_test.go | 1 - 10 files changed, 6 insertions(+), 68 deletions(-) diff --git a/src/internal/events/events.go b/src/internal/events/events.go index b2efa81c3..261763094 100644 --- a/src/internal/events/events.go +++ b/src/internal/events/events.go @@ -28,16 +28,12 @@ const ( tenantIDDeprecated = "m365_tenant_hash_deprecated" // Event Keys - RepoInit = "Repo Init" - RepoConnect = "Repo Connect" - BackupStart = "Backup Start" - BackupEnd = "Backup End" - RestoreStart = "Restore Start" - RestoreEnd = "Restore End" - ExportStart = "Export Start" - ExportEnd = "Export End" - MaintenanceStart = "Maintenance Start" - MaintenanceEnd = "Maintenance End" + RepoInit = "Repo Init" + RepoConnect = "Repo Connect" + BackupEnd = "Backup End" + RestoreEnd = "Restore End" + ExportEnd = "Export End" + MaintenanceEnd = "Maintenance End" // Event Data Keys BackupCreateTime = "backup_creation_time" diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 80b74277e..a5e9b59b7 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -247,15 +247,6 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) { "incremental", op.incremental, "disable_assist_backup", op.disableAssistBackup) - op.bus.Event( - ctx, - events.BackupStart, - map[string]any{ - events.StartTime: startTime, - events.Service: op.Selectors.Service.String(), - events.BackupID: op.Results.BackupID, - }) - defer func() { op.bus.Event( ctx, diff --git a/src/internal/operations/export.go b/src/internal/operations/export.go index 6f09b8c5d..fe807d25b 100644 --- a/src/internal/operations/export.go +++ b/src/internal/operations/export.go @@ -229,16 +229,6 @@ func (op *ExportOperation) do( "backup_snapshot_id", bup.SnapshotID, "backup_version", bup.Version) - op.bus.Event( - ctx, - events.ExportStart, - map[string]any{ - events.StartTime: start, - events.BackupID: op.BackupID, - events.BackupCreateTime: bup.CreationTime, - events.ExportID: opStats.exportID, - }) - observe.Message(ctx, fmt.Sprintf("Discovered %d items in backup %s to export", len(paths), op.BackupID)) kopiaComplete := observe.MessageWithCompletion(ctx, "Enumerating items in repository") diff --git a/src/internal/operations/maintenance.go b/src/internal/operations/maintenance.go index 4c4003733..d05d97182 100644 --- a/src/internal/operations/maintenance.go +++ b/src/internal/operations/maintenance.go @@ -57,13 +57,6 @@ func (op *MaintenanceOperation) Run(ctx context.Context) (err error) { op.Results.StartedAt = time.Now() - op.bus.Event( - ctx, - events.MaintenanceStart, - map[string]any{ - events.StartTime: op.Results.StartedAt, - }) - defer func() { op.bus.Event( ctx, diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index dcb387c03..c1778912b 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -266,16 +266,6 @@ func (op *RestoreOperation) do( "backup_snapshot_id", bup.SnapshotID, "backup_version", bup.Version) - op.bus.Event( - ctx, - events.RestoreStart, - map[string]any{ - events.StartTime: start, - events.BackupID: op.BackupID, - events.BackupCreateTime: bup.CreationTime, - events.RestoreID: opStats.restoreID, - }) - observe.Message(ctx, fmt.Sprintf("Discovered %d items in backup %s to restore", len(paths), op.BackupID)) progressBar := observe.MessageWithCompletion(ctx, "Enumerating items in repository") diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index d8d1767e5..a22ab3998 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -367,6 +367,5 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() { assert.Zero(t, ro.Results.ResourceOwners, "resource owners") assert.Zero(t, ro.Results.BytesRead, "bytes read") // no restore start, because we'd need to find the backup first. - assert.Equal(t, 0, mb.TimesCalled[events.RestoreStart], "restore-start events") assert.Equal(t, 1, mb.TimesCalled[events.RestoreEnd], "restore-end events") } diff --git a/src/internal/operations/test/exchange_test.go b/src/internal/operations/test/exchange_test.go index 26898fc5b..1947eb4bf 100644 --- a/src/internal/operations/test/exchange_test.go +++ b/src/internal/operations/test/exchange_test.go @@ -226,11 +226,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() { assert.Equal(t, bo.Results.ResourceOwners, incBO.Results.ResourceOwners, "incremental backup resource owner") assert.NoError(t, incBO.Errors.Failure(), "incremental non-recoverable error", clues.ToCore(bo.Errors.Failure())) assert.Empty(t, incBO.Errors.Recovered(), "count incremental recoverable/iteration errors") - assert.Equal(t, 1, incMB.TimesCalled[events.BackupStart], "incremental backup-start events") assert.Equal(t, 1, incMB.TimesCalled[events.BackupEnd], "incremental backup-end events") - assert.Equal(t, - incMB.CalledWith[events.BackupStart][0][events.BackupID], - incBO.Results.BackupID, "incremental backupID pre-declaration") }) } } @@ -876,11 +872,7 @@ func testExchangeContinuousBackups(suite *ExchangeBackupIntgSuite, toggles contr // assert.Equal(t, test.nonMetaItemsWritten, incBO.Results.ItemsWritten, "non meta incremental items write") assert.NoError(t, incBO.Errors.Failure(), "incremental non-recoverable error", clues.ToCore(incBO.Errors.Failure())) assert.Empty(t, incBO.Errors.Recovered(), "incremental recoverable/iteration errors") - assert.Equal(t, 1, incMB.TimesCalled[events.BackupStart], "incremental backup-start events") assert.Equal(t, 1, incMB.TimesCalled[events.BackupEnd], "incremental backup-end events") - assert.Equal(t, - incMB.CalledWith[events.BackupStart][0][events.BackupID], - bupID, "incremental backupID pre-declaration") }) } } diff --git a/src/internal/operations/test/helper_test.go b/src/internal/operations/test/helper_test.go index 6c1dde603..3d29e8ccc 100644 --- a/src/internal/operations/test/helper_test.go +++ b/src/internal/operations/test/helper_test.go @@ -224,11 +224,7 @@ func runAndCheckBackup( assert.Equal(t, 1, bo.Results.ResourceOwners, "count of resource owners") assert.NoError(t, bo.Errors.Failure(), "incremental non-recoverable error", clues.ToCore(bo.Errors.Failure())) assert.Empty(t, bo.Errors.Recovered(), "incremental recoverable/iteration errors") - assert.Equal(t, 1, mb.TimesCalled[events.BackupStart], "backup-start events") assert.Equal(t, 1, mb.TimesCalled[events.BackupEnd], "backup-end events") - assert.Equal(t, - mb.CalledWith[events.BackupStart][0][events.BackupID], - bo.Results.BackupID, "backupID pre-declaration") } func checkBackupIsInManifests( diff --git a/src/internal/operations/test/onedrive_test.go b/src/internal/operations/test/onedrive_test.go index 6e53566c9..3343adae8 100644 --- a/src/internal/operations/test/onedrive_test.go +++ b/src/internal/operations/test/onedrive_test.go @@ -801,11 +801,7 @@ func runDriveIncrementalTest( assert.NoError(t, incBO.Errors.Failure(), "incremental non-recoverable error", clues.ToCore(incBO.Errors.Failure())) assert.Empty(t, incBO.Errors.Recovered(), "incremental recoverable/iteration errors") - assert.Equal(t, 1, incMB.TimesCalled[events.BackupStart], "incremental backup-start events") assert.Equal(t, 1, incMB.TimesCalled[events.BackupEnd], "incremental backup-end events") - assert.Equal(t, - incMB.CalledWith[events.BackupStart][0][events.BackupID], - bupID, "incremental backupID pre-declaration") }) } } @@ -912,11 +908,7 @@ func (suite *OneDriveBackupIntgSuite) TestBackup_Run_oneDriveOwnerMigration() { assert.LessOrEqual(t, 2, incBO.Results.ItemsRead, "items read") assert.NoError(t, incBO.Errors.Failure(), "non-recoverable error", clues.ToCore(incBO.Errors.Failure())) assert.Empty(t, incBO.Errors.Recovered(), "recoverable/iteration errors") - assert.Equal(t, 1, incMB.TimesCalled[events.BackupStart], "backup-start events") assert.Equal(t, 1, incMB.TimesCalled[events.BackupEnd], "backup-end events") - assert.Equal(t, - incMB.CalledWith[events.BackupStart][0][events.BackupID], - incBO.Results.BackupID, "backupID pre-declaration") bid := incBO.Results.BackupID bup := &backup.Backup{} diff --git a/src/internal/operations/test/restore_helper_test.go b/src/internal/operations/test/restore_helper_test.go index 32b73c8a7..b57ee3aa4 100644 --- a/src/internal/operations/test/restore_helper_test.go +++ b/src/internal/operations/test/restore_helper_test.go @@ -205,7 +205,6 @@ func runAndCheckRestore( assert.NotZero(t, ro.Results.ItemsRead, "count of items read") assert.NotZero(t, ro.Results.BytesRead, "bytes read") assert.Equal(t, 1, ro.Results.ResourceOwners, "count of resource owners") - assert.Equal(t, 1, mb.TimesCalled[events.RestoreStart], "restore-start events") assert.Equal(t, 1, mb.TimesCalled[events.RestoreEnd], "restore-end events") return deets