From e60610193c92f51568d4abb6d9f303f472ae4193 Mon Sep 17 00:00:00 2001 From: Keepers Date: Thu, 13 Jul 2023 19:21:53 -0600 Subject: [PATCH] specify sharepoint restore libraries (#3801) #### Does this PR need a docs update or release note? - [x] :no_entry: No #### Type of change - [x] :robot: Supportability/Tests #### Test Plan - [x] :green_heart: E2E --- src/internal/m365/helper_test.go | 5 ++++- src/internal/operations/restore_test.go | 17 +++++++---------- src/internal/tester/tconfig/consts.go | 8 ++++++++ src/pkg/backup/details/testdata/in_deets.go | 6 ++++-- src/pkg/selectors/testdata/sharepoint.go | 4 +++- 5 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 src/internal/tester/tconfig/consts.go diff --git a/src/internal/m365/helper_test.go b/src/internal/m365/helper_test.go index 4befc991c..25f4bb18c 100644 --- a/src/internal/m365/helper_test.go +++ b/src/internal/m365/helper_test.go @@ -1180,7 +1180,10 @@ func getSelectorWith( case path.SharePointService: if forRestore { - return selectors.NewSharePointRestore(resourceOwners).Selector + sel := selectors.NewSharePointRestore(resourceOwners) + sel.Include(sel.Library(tconfig.LibraryDocuments), sel.Library(tconfig.LibraryMoreDocuments)) + + return sel.Selector } return selectors.NewSharePointBackup(resourceOwners).Selector diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 7cf9fcf2e..cc5634234 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -350,11 +350,6 @@ func setupSharePointBackup( evmock.NewBus()) require.NoError(t, err, clues.ToCore(err)) - spPgr := ctrl.AC.Drives().NewSiteDrivePager(owner, []string{"id", "name"}) - - drives, err := api.GetAllDrives(ctx, spPgr, true, 3) - require.NoError(t, err, clues.ToCore(err)) - err = bo.Run(ctx) require.NoError(t, err, clues.ToCore(err)) require.NotEmpty(t, bo.Results.BackupID) @@ -362,12 +357,14 @@ func setupSharePointBackup( return bupResults{ selectorResourceOwners: sites, backupID: bo.Results.BackupID, - // Discount metadata files (1 delta, 1 prev path) + // Discount metadata files (2: 1 delta, 1 prev path) // assume only one folder, and therefore 1 dirmeta per drive - // assume only one file in each folder, and therefore 1 meta per drive. - // These meta files are used to aid restore, but are not themselves + // (2 drives: documents and more documents) + // assume only one file in each folder, and therefore 1 meta per drive + // (2 drives: documents and more documents) + // Meta files are used to aid restore, but are not themselves // restored (ie: counted as writes). - items: bo.Results.ItemsWritten - 2 - len(drives) - len(drives), + items: bo.Results.ItemsWritten - 6, ctrl: ctrl, } } @@ -398,7 +395,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run() { restoreCfg: control.DefaultRestoreConfig(dttm.SafeForTesting), getSelector: func(t *testing.T, owners []string) selectors.Selector { rsel := selectors.NewSharePointRestore(owners) - rsel.Include(rsel.AllData()) + rsel.Include(rsel.Library(tconfig.LibraryDocuments), rsel.Library(tconfig.LibraryMoreDocuments)) return rsel.Selector }, diff --git a/src/internal/tester/tconfig/consts.go b/src/internal/tester/tconfig/consts.go new file mode 100644 index 000000000..ce341afef --- /dev/null +++ b/src/internal/tester/tconfig/consts.go @@ -0,0 +1,8 @@ +package tconfig + +// SharePoint +const ( + // commonly used drive names + LibraryDocuments = "Documents" + LibraryMoreDocuments = "More Documents" +) diff --git a/src/pkg/backup/details/testdata/in_deets.go b/src/pkg/backup/details/testdata/in_deets.go index ecefe8b89..b9b0ce001 100644 --- a/src/pkg/backup/details/testdata/in_deets.go +++ b/src/pkg/backup/details/testdata/in_deets.go @@ -329,18 +329,20 @@ func CheckBackupDetails( } // Compare folders. + // Have result first since it may be a Subset call. check( t, - maps.Keys(expect.Sets[set].Locations), maps.Keys(result.Sets[set].Locations), + maps.Keys(expect.Sets[set].Locations), "results in %s missing expected location", set) // Compare items in folders. for lr, items := range expect.Sets[set].Locations { + // Have result first since it may be a Subset call. check( t, - maps.Keys(items), maps.Keys(result.Sets[set].Locations[lr]), + maps.Keys(items), "results in set %s location %s missing expected item", set, lr) diff --git a/src/pkg/selectors/testdata/sharepoint.go b/src/pkg/selectors/testdata/sharepoint.go index 6051c2fda..c6cc414ff 100644 --- a/src/pkg/selectors/testdata/sharepoint.go +++ b/src/pkg/selectors/testdata/sharepoint.go @@ -1,6 +1,8 @@ package testdata -import "github.com/alcionai/corso/src/pkg/selectors" +import ( + "github.com/alcionai/corso/src/pkg/selectors" +) // SharePointBackupFolderScope is the standard folder scope that should be used // in integration backups with sharepoint.