diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index fd5333464..4f5020e47 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -126,7 +126,7 @@ jobs: go run . exchange emails \ --user ${TEST_USER} \ --tenant ${{ env.AZURE_TENANT_ID }} \ - --destination Corso_Restore_st_${{ steps.repo-init.outputs.result }} \ + --destination Corso_Test_sanity${{ steps.repo-init.outputs.result }} \ --count 4 - name: Backup exchange test @@ -192,7 +192,7 @@ jobs: echo -e "\nBackup Exchange restore test\n" >> ${CORSO_LOG_FILE} ./corso restore exchange \ --no-stats \ - --email-folder Corso_Restore_st_${{ steps.repo-init.outputs.result }} \ + --email-folder Corso_Test_sanity${{ steps.repo-init.outputs.result }} \ --hide-progress \ --backup "${{ steps.exchange-test.outputs.result }}" \ 2>&1 | tee $TEST_RESULT/exchange-restore-test.txt @@ -202,7 +202,7 @@ jobs: env: SANITY_RESTORE_FOLDER: ${{ steps.exchange-restore-test.outputs.result }} SANITY_RESTORE_SERVICE: "exchange" - TEST_DATA: Corso_Restore_st_${{ steps.repo-init.outputs.result }} + TEST_DATA: Corso_Test_sanity${{ steps.repo-init.outputs.result }} run: | set -euo pipefail ./sanityTest @@ -239,7 +239,7 @@ jobs: --no-stats \ --hide-progress \ --backup "${{ steps.exchange-incremental-test.outputs.result }}" \ - --email-folder Corso_Restore_st_${{ steps.repo-init.outputs.result }} \ + --email-folder Corso_Test_sanity${{ steps.repo-init.outputs.result }} \ 2>&1 | tee $TEST_RESULT/exchange-incremantal-restore-test.txt echo result=$(grep -i -e 'Restoring to folder ' $TEST_RESULT/exchange-incremantal-restore-test.txt | sed "s/Restoring to folder//" ) >> $GITHUB_OUTPUT @@ -247,7 +247,7 @@ jobs: env: SANITY_RESTORE_FOLDER: ${{ steps.exchange-incremantal-restore-test.outputs.result }} SANITY_RESTORE_SERVICE: "exchange" - TEST_DATA: Corso_Restore_st_${{ steps.repo-init.outputs.result }} + TEST_DATA: Corso_Test_sanity${{ steps.repo-init.outputs.result }} BASE_BACKUP: ${{ steps.exchange-restore-test.outputs.result }} run: | set -euo pipefail @@ -272,7 +272,7 @@ jobs: --user ${TEST_USER} \ --secondaryuser ${{ env.SECONDARY_TEST_USER }} \ --tenant ${{ env.AZURE_TENANT_ID }} \ - --destination Corso_Restore_st_$suffix \ + --destination Corso_Test_sanity$suffix \ --count 4 echo result="$suffix" >> $GITHUB_OUTPUT @@ -341,7 +341,7 @@ jobs: ./corso restore onedrive \ --no-stats \ --restore-permissions \ - --folder Corso_Restore_st_${{ steps.new-data-creation-onedrive.outputs.result }} \ + --folder Corso_Test_sanity${{ steps.new-data-creation-onedrive.outputs.result }} \ --hide-progress \ --backup "${{ steps.onedrive-test.outputs.result }}" \ 2>&1 | tee $TEST_RESULT/onedrive-restore-test.txt @@ -351,7 +351,7 @@ jobs: env: SANITY_RESTORE_FOLDER: ${{ steps.onedrive-restore-test.outputs.result }} SANITY_RESTORE_SERVICE: "onedrive" - TEST_DATA: Corso_Restore_st_${{ steps.new-data-creation-onedrive.outputs.result }} + TEST_DATA: Corso_Test_sanity${{ steps.new-data-creation-onedrive.outputs.result }} run: | set -euo pipefail ./sanityTest @@ -368,7 +368,7 @@ jobs: --user ${TEST_USER} \ --secondaryuser ${{ env.SECONDARY_TEST_USER }} \ --tenant ${{ env.AZURE_TENANT_ID }} \ - --destination Corso_Restore_st_${{ steps.new-data-creation-onedrive.outputs.result }} \ + --destination Corso_Test_sanity${{ steps.new-data-creation-onedrive.outputs.result }} \ --count 4 # incremental backup @@ -404,7 +404,7 @@ jobs: --no-stats \ --restore-permissions \ --hide-progress \ - --folder Corso_Restore_st_${{ steps.new-data-creation-onedrive.outputs.result }} \ + --folder Corso_Test_sanity${{ steps.new-data-creation-onedrive.outputs.result }} \ --backup "${{ steps.onedrive-incremental-test.outputs.result }}" \ 2>&1 | tee $TEST_RESULT/onedrive-incremental-restore-test.txt echo result=$(grep -i -e 'Restoring to folder ' $TEST_RESULT/onedrive-incremental-restore-test.txt | sed "s/Restoring to folder//") >> $GITHUB_OUTPUT @@ -413,7 +413,7 @@ jobs: env: SANITY_RESTORE_FOLDER: ${{ steps.onedrive-incremental-restore-test.outputs.result }} SANITY_RESTORE_SERVICE: "onedrive" - TEST_DATA: Corso_Restore_st_${{ steps.new-data-creation-onedrive.outputs.result }} + TEST_DATA: Corso_Test_sanity${{ steps.new-data-creation-onedrive.outputs.result }} run: | set -euo pipefail ./sanityTest diff --git a/src/cli/backup/onedrive_e2e_test.go b/src/cli/backup/onedrive_e2e_test.go index 9e6c134bc..73cedd2ca 100644 --- a/src/cli/backup/onedrive_e2e_test.go +++ b/src/cli/backup/onedrive_e2e_test.go @@ -22,6 +22,7 @@ import ( "github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/repository" "github.com/alcionai/corso/src/pkg/selectors" + selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" "github.com/alcionai/corso/src/pkg/storage" ) @@ -172,7 +173,7 @@ func (suite *BackupDeleteOneDriveE2ESuite) SetupSuite() { // some tests require an existing backup sel := selectors.NewOneDriveBackup(users) - sel.Include(sel.Folders(selectors.Any())) + sel.Include(selTD.OneDriveBackupFolderScope(sel)) backupOp, err := suite.repo.NewBackupWithLookup(ctx, sel.Selector, ins) require.NoError(t, err, clues.ToCore(err)) diff --git a/src/internal/connector/data_collections_test.go b/src/internal/connector/data_collections_test.go index fedc85106..3025a385c 100644 --- a/src/internal/connector/data_collections_test.go +++ b/src/internal/connector/data_collections_test.go @@ -20,7 +20,7 @@ import ( "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/selectors" - "github.com/alcionai/corso/src/pkg/selectors/testdata" + selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" ) // --------------------------------------------------------------------------- @@ -160,7 +160,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() name: "Invalid onedrive backup user", getSelector: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup(owners) - sel.Include(sel.Folders(selectors.Any())) + sel.Include(selTD.OneDriveBackupFolderScope(sel)) return sel.Selector }, }, @@ -168,7 +168,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() name: "Invalid sharepoint backup site", getSelector: func(t *testing.T) selectors.Selector { sel := selectors.NewSharePointBackup(owners) - sel.Include(testdata.SharePointBackupFolderScope(sel)) + sel.Include(selTD.SharePointBackupFolderScope(sel)) return sel.Selector }, }, @@ -185,7 +185,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() name: "missing onedrive backup user", getSelector: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup(owners) - sel.Include(sel.Folders(selectors.Any())) + sel.Include(selTD.OneDriveBackupFolderScope(sel)) sel.DiscreteOwner = "" return sel.Selector }, @@ -194,7 +194,7 @@ func (suite *DataCollectionIntgSuite) TestDataCollections_invalidResourceOwner() name: "missing sharepoint backup site", getSelector: func(t *testing.T) selectors.Selector { sel := selectors.NewSharePointBackup(owners) - sel.Include(testdata.SharePointBackupFolderScope(sel)) + sel.Include(selTD.SharePointBackupFolderScope(sel)) sel.DiscreteOwner = "" return sel.Selector }, @@ -239,7 +239,7 @@ func (suite *DataCollectionIntgSuite) TestSharePointDataCollection() { name: "Libraries", getSelector: func() selectors.Selector { sel := selectors.NewSharePointBackup(selSites) - sel.Include(testdata.SharePointBackupFolderScope(sel)) + sel.Include(selTD.SharePointBackupFolderScope(sel)) return sel.Selector }, }, diff --git a/src/internal/connector/exchange/container_resolver_test.go b/src/internal/connector/exchange/container_resolver_test.go index 572162263..de050d25a 100644 --- a/src/internal/connector/exchange/container_resolver_test.go +++ b/src/internal/connector/exchange/container_resolver_test.go @@ -549,7 +549,7 @@ func (suite *FolderCacheIntegrationSuite) TestCreateContainerDestination() { var ( user = tester.M365UserID(suite.T()) directoryCaches = make(map[path.CategoryType]graph.ContainerResolver) - folderName = tester.DefaultTestRestoreDestination().ContainerName + folderName = tester.DefaultTestRestoreDestination("").ContainerName tests = []struct { name string pathFunc1 func(t *testing.T) path.Path diff --git a/src/internal/connector/exchange/restore_test.go b/src/internal/connector/exchange/restore_test.go index 1aa2beece..b6ec9168f 100644 --- a/src/internal/connector/exchange/restore_test.go +++ b/src/internal/connector/exchange/restore_test.go @@ -3,14 +3,12 @@ package exchange import ( "context" "testing" - "time" "github.com/alcionai/clues" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/connector/exchange/api" exchMock "github.com/alcionai/corso/src/internal/connector/exchange/mock" @@ -67,8 +65,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreContact() { var ( t = suite.T() userID = tester.M365UserID(t) - now = time.Now() - folderName = "TestRestoreContact: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName = tester.DefaultTestRestoreDestination("contact").ContainerName ) aFolder, err := suite.ac.Contacts().CreateContactFolder(ctx, userID, folderName) @@ -102,7 +99,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreEvent() { var ( t = suite.T() userID = tester.M365UserID(t) - subject = "TestRestoreEvent: " + dttm.FormatNow(dttm.SafeForTesting) + subject = tester.DefaultTestRestoreDestination("event").ContainerName ) calendar, err := suite.ac.Events().CreateCalendar(ctx, userID, subject) @@ -172,7 +169,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { } userID := tester.M365UserID(suite.T()) - now := time.Now() + tests := []struct { name string bytes []byte @@ -184,7 +181,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageBytes("Restore Exchange Object"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailObject: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailobj").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -196,7 +193,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithDirectAttachment("Restore 1 Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailwithAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailwattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -208,7 +205,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithItemAttachmentEvent("Event Item Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreEventItemAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("eventwattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -220,7 +217,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithItemAttachmentMail("Mail Item Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailItemAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailitemattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -235,7 +232,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { ), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailBasicItemAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailbasicattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -250,7 +247,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { ), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "ItemMailAttachmentwAttachment " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailnestattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -265,7 +262,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { ), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "ItemMailAttachment_Contact " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailcontactattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -277,7 +274,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithNestedItemAttachmentEvent("Nested Item Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreNestedEventItemAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("nestedattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -289,7 +286,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithLargeAttachment("Restore Large Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailwithLargeAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("maillargeattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -301,7 +298,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithTwoAttachments("Restore 2 Attachments"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailwithAttachments: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailtwoattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -313,7 +310,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.MessageWithOneDriveAttachment("Restore Reference(OneDrive) Attachment"), category: path.EmailCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreMailwithReferenceAttachment: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("mailrefattch").ContainerName folder, err := suite.ac.Mail().CreateMailFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -326,7 +323,7 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.ContactBytes("Test_Omega"), category: path.ContactsCategory, destination: func(t *testing.T, ctx context.Context) string { - folderName := "TestRestoreContactObject: " + dttm.FormatTo(now, dttm.SafeForTesting) + folderName := tester.DefaultTestRestoreDestination("contact").ContainerName folder, err := suite.ac.Contacts().CreateContactFolder(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) @@ -338,8 +335,8 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.EventBytes("Restored Event Object"), category: path.EventsCategory, destination: func(t *testing.T, ctx context.Context) string { - calendarName := "TestRestoreEventObject: " + dttm.FormatTo(now, dttm.SafeForTesting) - calendar, err := suite.ac.Events().CreateCalendar(ctx, userID, calendarName) + folderName := tester.DefaultTestRestoreDestination("event").ContainerName + calendar, err := suite.ac.Events().CreateCalendar(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) return ptr.Val(calendar.GetId()) @@ -350,8 +347,8 @@ func (suite *ExchangeRestoreSuite) TestRestoreExchangeObject() { bytes: exchMock.EventWithAttachment("Restored Event Attachment"), category: path.EventsCategory, destination: func(t *testing.T, ctx context.Context) string { - calendarName := "TestRestoreEventObject_" + dttm.FormatTo(now, dttm.SafeForTesting) - calendar, err := suite.ac.Events().CreateCalendar(ctx, userID, calendarName) + folderName := tester.DefaultTestRestoreDestination("eventobj").ContainerName + calendar, err := suite.ac.Events().CreateCalendar(ctx, userID, folderName) require.NoError(t, err, clues.ToCore(err)) return ptr.Val(calendar.GetId()) diff --git a/src/internal/connector/graph_connector_disconnected_test.go b/src/internal/connector/graph_connector_disconnected_test.go index b95f75335..23a6ab1dc 100644 --- a/src/internal/connector/graph_connector_disconnected_test.go +++ b/src/internal/connector/graph_connector_disconnected_test.go @@ -11,6 +11,7 @@ import ( "github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/pkg/selectors" + selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" ) // --------------------------------------------------------------- @@ -82,19 +83,19 @@ func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs_allServices checkError: assert.NoError, excludes: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"elliotReid@someHospital.org", "foo@SomeCompany.org"}) - sel.Exclude(sel.Folders(selectors.Any())) + sel.Exclude(selTD.OneDriveBackupFolderScope(sel)) sel.DiscreteOwner = "elliotReid@someHospital.org" return sel.Selector }, filters: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"elliotReid@someHospital.org", "foo@SomeCompany.org"}) - sel.Filter(sel.Folders(selectors.Any())) + sel.Filter(selTD.OneDriveBackupFolderScope(sel)) sel.DiscreteOwner = "elliotReid@someHospital.org" return sel.Selector }, includes: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"elliotReid@someHospital.org", "foo@SomeCompany.org"}) - sel.Include(sel.Folders(selectors.Any())) + sel.Include(selTD.OneDriveBackupFolderScope(sel)) sel.DiscreteOwner = "elliotReid@someHospital.org" return sel.Selector }, @@ -104,17 +105,17 @@ func (suite *DisconnectedGraphConnectorSuite) TestVerifyBackupInputs_allServices checkError: assert.NoError, excludes: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"foo@SomeCompany.org"}) - sel.Exclude(sel.Folders(selectors.Any())) + sel.Exclude(selTD.OneDriveBackupFolderScope(sel)) return sel.Selector }, filters: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"foo@SomeCompany.org"}) - sel.Filter(sel.Folders(selectors.Any())) + sel.Filter(selTD.OneDriveBackupFolderScope(sel)) return sel.Selector }, includes: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{"foo@SomeCompany.org"}) - sel.Include(sel.Folders(selectors.Any())) + sel.Include(selTD.OneDriveBackupFolderScope(sel)) return sel.Selector }, }, diff --git a/src/internal/connector/graph_connector_helper_test.go b/src/internal/connector/graph_connector_helper_test.go index 6934162ab..99043e5bc 100644 --- a/src/internal/connector/graph_connector_helper_test.go +++ b/src/internal/connector/graph_connector_helper_test.go @@ -1099,7 +1099,7 @@ func makeSharePointBackupSel( } // backupSelectorForExpected creates a selector that can be used to backup the -// given items in expected based on the item paths. Fails the test if items from +// given dests based on the item paths. Fails the test if items from // multiple services are in expected. func backupSelectorForExpected( t *testing.T, diff --git a/src/internal/connector/graph_connector_test.go b/src/internal/connector/graph_connector_test.go index 00731b93e..37dc480f3 100644 --- a/src/internal/connector/graph_connector_test.go +++ b/src/internal/connector/graph_connector_test.go @@ -295,7 +295,7 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() { var ( t = suite.T() acct = tester.NewM365Account(t) - dest = tester.DefaultTestRestoreDestination() + dest = tester.DefaultTestRestoreDestination("") sel = selectors.Selector{ Service: selectors.ServiceUnknown, } @@ -323,7 +323,7 @@ func (suite *GraphConnectorIntegrationSuite) TestRestoreFailsBadService() { } func (suite *GraphConnectorIntegrationSuite) TestEmptyCollections() { - dest := tester.DefaultTestRestoreDestination() + dest := tester.DefaultTestRestoreDestination("") table := []struct { name string col []data.RestoreCollection @@ -579,7 +579,7 @@ func runRestoreBackupTest( service: test.service, tenant: tenant, resourceOwners: resourceOwners, - dest: tester.DefaultTestRestoreDestination(), + dest: tester.DefaultTestRestoreDestination(""), } totalItems, totalKopiaItems, collections, expectedData := getCollectionsAndExpected( @@ -625,7 +625,7 @@ func runRestoreTestWithVerion( service: test.service, tenant: tenant, resourceOwners: resourceOwners, - dest: tester.DefaultTestRestoreDestination(), + dest: tester.DefaultTestRestoreDestination(""), } totalItems, _, collections, _ := getCollectionsAndExpected( @@ -664,7 +664,7 @@ func runRestoreBackupTestVersions( service: test.service, tenant: tenant, resourceOwners: resourceOwners, - dest: tester.DefaultTestRestoreDestination(), + dest: tester.DefaultTestRestoreDestination(""), } totalItems, _, collections, _ := getCollectionsAndExpected( @@ -1042,7 +1042,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMultiFolderBackupDifferentNames for i, collection := range test.collections { // Get a dest per collection so they're independent. - dest := tester.DefaultTestRestoreDestination() + dest := tester.DefaultTestRestoreDestination("") expectedDests = append(expectedDests, destAndCats{ resourceOwner: suite.user, dest: dest.ContainerName, @@ -1214,9 +1214,7 @@ func (suite *GraphConnectorIntegrationSuite) TestBackup_CreatesPrefixCollections resource: Users, selectorFunc: func(t *testing.T) selectors.Selector { sel := selectors.NewOneDriveBackup([]string{suite.user}) - sel.Include( - sel.Folders([]string{selectors.NoneTgt}), - ) + sel.Include(sel.Folders([]string{selectors.NoneTgt})) return sel.Selector }, diff --git a/src/internal/connector/onedrive/drive_test.go b/src/internal/connector/onedrive/drive_test.go index d2f1a68b6..2a5d4b5a8 100644 --- a/src/internal/connector/onedrive/drive_test.go +++ b/src/internal/connector/onedrive/drive_test.go @@ -279,24 +279,24 @@ func (suite *OneDriveUnitSuite) TestDrives() { // Integration tests -type OneDriveSuite struct { +type OneDriveIntgSuite struct { tester.Suite userID string } func TestOneDriveSuite(t *testing.T) { - suite.Run(t, &OneDriveSuite{ + suite.Run(t, &OneDriveIntgSuite{ Suite: tester.NewIntegrationSuite( t, [][]string{tester.M365AcctCredEnvs}), }) } -func (suite *OneDriveSuite) SetupSuite() { +func (suite *OneDriveIntgSuite) SetupSuite() { suite.userID = tester.SecondaryM365UserID(suite.T()) } -func (suite *OneDriveSuite) TestCreateGetDeleteFolder() { +func (suite *OneDriveIntgSuite) TestCreateGetDeleteFolder() { ctx, flush := tester.NewContext() defer flush() @@ -401,7 +401,7 @@ func (fm testFolderMatcher) Matches(p string) bool { return fm.scope.Matches(selectors.OneDriveFolder, p) } -func (suite *OneDriveSuite) TestOneDriveNewCollections() { +func (suite *OneDriveIntgSuite) TestOneDriveNewCollections() { creds, err := tester.NewM365Account(suite.T()).M365Config() require.NoError(suite.T(), err, clues.ToCore(err)) diff --git a/src/internal/connector/onedrive/item_test.go b/src/internal/connector/onedrive/item_test.go index 65b69ede7..47feea0ff 100644 --- a/src/internal/connector/onedrive/item_test.go +++ b/src/internal/connector/onedrive/item_test.go @@ -128,8 +128,7 @@ func (suite *ItemIntegrationSuite) TestItemReader_oneDrive() { } // TestItemWriter is an integration test for uploading data to OneDrive -// It creates a new `testfolder_ item and writes data to it +// It creates a new folder with a new item and writes data to it func (suite *ItemIntegrationSuite) TestItemWriter() { table := []struct { name string @@ -155,24 +154,20 @@ func (suite *ItemIntegrationSuite) TestItemWriter() { root, err := srv.Client().DrivesById(test.driveID).Root().Get(ctx, nil) require.NoError(t, err, clues.ToCore(err)) - // Test Requirement 2: "Test Folder" should exist - folder, err := api.GetFolderByName(ctx, srv, test.driveID, ptr.Val(root.GetId()), "Test Folder") - require.NoError(t, err, clues.ToCore(err)) - - newFolderName := "testfolder_" + dttm.FormatNow(dttm.SafeForTesting) - t.Logf("Test will create folder %s", newFolderName) + newFolderName := tester.DefaultTestRestoreDestination("folder").ContainerName + t.Logf("creating folder %s", newFolderName) newFolder, err := CreateItem( ctx, srv, test.driveID, - ptr.Val(folder.GetId()), + ptr.Val(root.GetId()), newItem(newFolderName, true)) require.NoError(t, err, clues.ToCore(err)) require.NotNil(t, newFolder.GetId()) newItemName := "testItem_" + dttm.FormatNow(dttm.SafeForTesting) - t.Logf("Test will create item %s", newItemName) + t.Logf("creating item %s", newItemName) newItem, err := CreateItem( ctx, diff --git a/src/internal/connector/sharepoint/api/pages_test.go b/src/internal/connector/sharepoint/api/pages_test.go index 32d0aa07c..c56c3bc86 100644 --- a/src/internal/connector/sharepoint/api/pages_test.go +++ b/src/internal/connector/sharepoint/api/pages_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/connector/sharepoint" "github.com/alcionai/corso/src/internal/connector/sharepoint/api" spMock "github.com/alcionai/corso/src/internal/connector/sharepoint/mock" @@ -81,7 +80,7 @@ func (suite *SharePointPageSuite) TestRestoreSinglePage() { t := suite.T() - destName := "Corso_Restore_" + dttm.FormatNow(dttm.SafeForTesting) + destName := tester.DefaultTestRestoreDestination("").ContainerName testName := "MockPage" // Create Test Page @@ -98,8 +97,7 @@ func (suite *SharePointPageSuite) TestRestoreSinglePage() { suite.service, pageData, suite.siteID, - destName, - ) + destName) require.NoError(t, err, clues.ToCore(err)) require.NotNil(t, info) diff --git a/src/internal/connector/sharepoint/collection_test.go b/src/internal/connector/sharepoint/collection_test.go index 6beb811f3..596b1bb34 100644 --- a/src/internal/connector/sharepoint/collection_test.go +++ b/src/internal/connector/sharepoint/collection_test.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/internal/common/ptr" "github.com/alcionai/corso/src/internal/connector/sharepoint/api" spMock "github.com/alcionai/corso/src/internal/connector/sharepoint/mock" @@ -193,7 +192,7 @@ func (suite *SharePointCollectionSuite) TestListCollection_Restore() { info: sharePointListInfo(listing, int64(len(byteArray))), } - destName := "Corso_Restore_" + dttm.FormatNow(dttm.SafeForTesting) + destName := tester.DefaultTestRestoreDestination("").ContainerName deets, err := restoreListItem(ctx, service, listData, suite.siteID, destName) assert.NoError(t, err, clues.ToCore(err)) diff --git a/src/internal/connector/sharepoint/restore.go b/src/internal/connector/sharepoint/restore.go index 1c06e8ae3..013f2ef79 100644 --- a/src/internal/connector/sharepoint/restore.go +++ b/src/internal/connector/sharepoint/restore.go @@ -125,7 +125,7 @@ func RestoreCollections( } // restoreListItem utility function restores a List to the siteID. -// The name is changed to to Corso_Restore_{timeStame}_name +// The name is changed to to {DestName}_{name} // API Reference: https://learn.microsoft.com/en-us/graph/api/list-create?view=graph-rest-1.0&tabs=http // Restored List can be verified within the Site contents. func restoreListItem( diff --git a/src/internal/operations/backup_integration_test.go b/src/internal/operations/backup_integration_test.go index fefbb5dde..bc69c1d90 100644 --- a/src/internal/operations/backup_integration_test.go +++ b/src/internal/operations/backup_integration_test.go @@ -46,10 +46,13 @@ import ( "github.com/alcionai/corso/src/pkg/fault" "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/selectors" - "github.com/alcionai/corso/src/pkg/selectors/testdata" + selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" "github.com/alcionai/corso/src/pkg/store" ) +// Does not use the tester.DefaultTestRestoreDestination syntax as some of these +// items are created directly, not as a result of restoration, and we want to ensure +// they get clearly selected without accidental overlap. const incrementalsDestContainerPrefix = "incrementals_ci_" // --------------------------------------------------------------------------- @@ -1136,7 +1139,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDrive() { osel = selectors.NewOneDriveBackup([]string{m365UserID}) ) - osel.Include(osel.AllData()) + osel.Include(selTD.OneDriveBackupFolderScope(osel)) bo, _, _, _, _, _, closer := prepNewTestBackupOp(t, ctx, mb, osel.Selector, control.Toggles{}, version.Backup) defer closer() @@ -1694,7 +1697,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveOwnerMigration() { uname := ptr.Val(userable.GetUserPrincipalName()) oldsel := selectors.NewOneDriveBackup([]string{uname}) - oldsel.Include(oldsel.Folders([]string{"test"}, selectors.ExactMatch())) + oldsel.Include(selTD.OneDriveBackupFolderScope(oldsel)) bo, _, kw, ms, gc, sel, closer := prepNewTestBackupOp(t, ctx, mb, oldsel.Selector, ffs, 0) defer closer() @@ -1716,7 +1719,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_oneDriveOwnerMigration() { runAndCheckBackup(t, ctx, &bo, mb, false) newsel := selectors.NewOneDriveBackup([]string{uid}) - newsel.Include(newsel.Folders([]string{"test"}, selectors.ExactMatch())) + newsel.Include(selTD.OneDriveBackupFolderScope(newsel)) sel = newsel.SetDiscreteOwnerIDName(uid, uname) var ( @@ -1795,7 +1798,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run_sharePoint() { sel = selectors.NewSharePointBackup([]string{suite.site}) ) - sel.Include(testdata.SharePointBackupFolderScope(sel)) + sel.Include(selTD.SharePointBackupFolderScope(sel)) bo, _, kw, _, _, sels, closer := prepNewTestBackupOp(t, ctx, mb, sel.Selector, control.Toggles{}, version.Backup) defer closer() diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index 320f2933d..ea42a5c4f 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -55,7 +55,7 @@ func (suite *RestoreOpSuite) TestRestoreOperation_PersistResults() { gc = &mock.GraphConnector{} acct = account.Account{} now = time.Now() - dest = tester.DefaultTestRestoreDestination() + dest = tester.DefaultTestRestoreDestination("") ) table := []struct { @@ -220,7 +220,7 @@ func (suite *RestoreOpIntegrationSuite) TestNewRestoreOperation() { sw = &store.Wrapper{} gc = &mock.GraphConnector{} acct = tester.NewM365Account(suite.T()) - dest = tester.DefaultTestRestoreDestination() + dest = tester.DefaultTestRestoreDestination("") opts = control.Defaults() ) @@ -392,7 +392,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run() { { name: "Exchange_Restore", owner: tester.M365UserID(suite.T()), - dest: tester.DefaultTestRestoreDestination(), + dest: tester.DefaultTestRestoreDestination(""), getSelector: func(t *testing.T, owners []string) selectors.Selector { rsel := selectors.NewExchangeRestore(owners) rsel.Include(rsel.AllData()) @@ -464,7 +464,7 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoResults() { var ( t = suite.T() - dest = tester.DefaultTestRestoreDestination() + dest = tester.DefaultTestRestoreDestination("") mb = evmock.NewBus() ) diff --git a/src/internal/tester/restore_destination.go b/src/internal/tester/restore_destination.go index b22e8593b..af247258d 100644 --- a/src/internal/tester/restore_destination.go +++ b/src/internal/tester/restore_destination.go @@ -1,11 +1,26 @@ package tester import ( + "strings" + "github.com/alcionai/corso/src/internal/common/dttm" "github.com/alcionai/corso/src/pkg/control" ) -func DefaultTestRestoreDestination() control.RestoreDestination { - // Use microsecond granularity to help reduce collisions. - return control.DefaultRestoreDestination(dttm.SafeForTesting) +const RestoreFolderPrefix = "Corso_Test" + +func DefaultTestRestoreDestination(namespace string) control.RestoreDestination { + var ( + dest = control.DefaultRestoreDestination(dttm.SafeForTesting) + sft = dttm.FormatNow(dttm.SafeForTesting) + ) + + parts := []string{RestoreFolderPrefix, namespace, sft} + if len(namespace) == 0 { + parts = []string{RestoreFolderPrefix, sft} + } + + dest.ContainerName = strings.Join(parts, "_") + + return dest } diff --git a/src/pkg/repository/loadtest/repository_load_test.go b/src/pkg/repository/loadtest/repository_load_test.go index 4d9b718c1..7ef56fdb0 100644 --- a/src/pkg/repository/loadtest/repository_load_test.go +++ b/src/pkg/repository/loadtest/repository_load_test.go @@ -24,6 +24,7 @@ import ( "github.com/alcionai/corso/src/pkg/path" "github.com/alcionai/corso/src/pkg/repository" "github.com/alcionai/corso/src/pkg/selectors" + selTD "github.com/alcionai/corso/src/pkg/selectors/testdata" "github.com/alcionai/corso/src/pkg/storage" ) @@ -150,7 +151,7 @@ func runRestoreLoadTest( t.Skip("restore load test is toggled off") } - dest := tester.DefaultTestRestoreDestination() + dest := tester.DefaultTestRestoreDestination("") rst, err := r.NewRestore(ctx, backupID, restSel, dest) require.NoError(t, err, clues.ToCore(err)) @@ -541,7 +542,7 @@ func (suite *LoadOneDriveSuite) TestOneDrive() { defer flush() bsel := selectors.NewOneDriveBackup(suite.usersUnderTest) - bsel.Include(bsel.AllData()) + bsel.Include(selTD.OneDriveBackupFolderScope(bsel)) sel := bsel.Selector runLoadTest( @@ -588,7 +589,7 @@ func (suite *IndividualLoadOneDriveSuite) TestOneDrive() { defer flush() bsel := selectors.NewOneDriveBackup(suite.usersUnderTest) - bsel.Include(bsel.AllData()) + bsel.Include(selTD.OneDriveBackupFolderScope(bsel)) sel := bsel.Selector runLoadTest( diff --git a/src/pkg/repository/repository_test.go b/src/pkg/repository/repository_test.go index 1a80d6793..8efe44f31 100644 --- a/src/pkg/repository/repository_test.go +++ b/src/pkg/repository/repository_test.go @@ -242,7 +242,7 @@ func (suite *RepositoryIntegrationSuite) TestNewRestore() { t := suite.T() acct := tester.NewM365Account(t) - dest := tester.DefaultTestRestoreDestination() + dest := tester.DefaultTestRestoreDestination("") // need to initialize the repository before we can test connecting to it. st := tester.NewPrefixedS3Storage(t) diff --git a/src/pkg/selectors/testdata/onedrive.go b/src/pkg/selectors/testdata/onedrive.go new file mode 100644 index 000000000..8592d3d80 --- /dev/null +++ b/src/pkg/selectors/testdata/onedrive.go @@ -0,0 +1,9 @@ +package testdata + +import "github.com/alcionai/corso/src/pkg/selectors" + +// OneDriveBackupFolderScope is the standard folder scope that should be used +// in integration backups with onedrive. +func OneDriveBackupFolderScope(sel *selectors.OneDriveBackup) []selectors.OneDriveScope { + return sel.Folders([]string{"test"}, selectors.PrefixMatch()) +}