scope integration tests to specific folders (#806)

## Description

Exchange app e2e tests need to scope their
backup dataset to only the primary folder, else
we risk exponential duplication of data when
the next backup picks up all the corso-copied
folders.

## Type of change

- [x] 🌻 Feature
- [x] 🐛 Bugfix

## Issue(s)

* #501
### Awaiting completion 
- #810 
- #811
## Test Plan

- [ ] 💪 Manual
- [ ]  Unit test
- [x] 💚 E2E
This commit is contained in:
Keepers 2022-09-27 08:09:10 -06:00 committed by GitHub
parent f27c3e0b83
commit ed2dd9a026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 37 additions and 53 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/alcionai/corso/src/cli" "github.com/alcionai/corso/src/cli"
"github.com/alcionai/corso/src/cli/config" "github.com/alcionai/corso/src/cli/config"
"github.com/alcionai/corso/src/cli/print" "github.com/alcionai/corso/src/cli/print"
"github.com/alcionai/corso/src/internal/connector/exchange"
"github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/operations"
"github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/account"
@ -187,13 +188,13 @@ func (suite *PreparedBackupExchangeIntegrationSuite) SetupSuite() {
switch set { switch set {
case email: case email:
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{"Inbox"}) scopes = sel.MailFolders([]string{suite.m365UserID}, []string{exchange.DefaultMailFolder})
case contacts: case contacts:
scopes = sel.ContactFolders([]string{suite.m365UserID}, selectors.Any()) scopes = sel.ContactFolders([]string{suite.m365UserID}, []string{exchange.DefaultContactFolder})
case events: case events:
scopes = sel.EventCalendars([]string{suite.m365UserID}, selectors.Any()) scopes = sel.EventCalendars([]string{suite.m365UserID}, []string{exchange.DefaultCalendar})
} }
sel.Include(scopes) sel.Include(scopes)
@ -351,7 +352,7 @@ func (suite *BackupDeleteExchangeIntegrationSuite) SetupSuite() {
// some tests require an existing backup // some tests require an existing backup
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.MailFolders([]string{m365UserID}, []string{"Inbox"})) sel.Include(sel.MailFolders([]string{m365UserID}, []string{exchange.DefaultMailFolder}))
suite.backupOp, err = suite.repo.NewBackup(ctx, sel.Selector) suite.backupOp, err = suite.repo.NewBackup(ctx, sel.Selector)
require.NoError(t, suite.backupOp.Run(ctx)) require.NoError(t, suite.backupOp.Run(ctx))

View File

@ -9,6 +9,7 @@ import (
"github.com/alcionai/corso/src/cli" "github.com/alcionai/corso/src/cli"
"github.com/alcionai/corso/src/cli/config" "github.com/alcionai/corso/src/cli/config"
"github.com/alcionai/corso/src/internal/connector/exchange"
"github.com/alcionai/corso/src/internal/operations" "github.com/alcionai/corso/src/internal/operations"
"github.com/alcionai/corso/src/internal/tester" "github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/account"
@ -31,7 +32,7 @@ var (
// dataset to grow until timeouts occur. // dataset to grow until timeouts occur.
// var backupDataSets = []path.CategoryType{email, contacts, events} // var backupDataSets = []path.CategoryType{email, contacts, events}
var backupDataSets = []path.CategoryType{email} var backupDataSets = []path.CategoryType{contacts, email}
type RestoreExchangeIntegrationSuite struct { type RestoreExchangeIntegrationSuite struct {
suite.Suite suite.Suite
@ -96,13 +97,13 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
switch set { switch set {
case email: case email:
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{"Inbox"}) scopes = sel.MailFolders([]string{suite.m365UserID}, []string{exchange.DefaultMailFolder})
case contacts: case contacts:
scopes = sel.ContactFolders([]string{suite.m365UserID}, selectors.Any()) scopes = sel.ContactFolders([]string{suite.m365UserID}, []string{exchange.DefaultContactFolder})
case events: case events:
scopes = sel.EventCalendars([]string{suite.m365UserID}, selectors.Any()) scopes = sel.EventCalendars([]string{suite.m365UserID}, []string{exchange.DefaultCalendar})
} }
sel.Include(scopes) sel.Include(scopes)

View File

@ -319,7 +319,7 @@ func (suite *ExchangeServiceSuite) TestGetContainerID() {
}{ }{
{ {
name: "Mail Valid", name: "Mail Valid",
containerName: "Inbox", containerName: DefaultMailFolder,
category: messages, category: messages,
checkError: assert.NoError, checkError: assert.NoError,
}, },
@ -349,7 +349,7 @@ func (suite *ExchangeServiceSuite) TestGetContainerID() {
}, },
{ {
name: "Event Valid", name: "Event Valid",
containerName: "Calendar", containerName: DefaultCalendar,
category: events, category: events,
checkError: assert.NoError, checkError: assert.NoError,
}, },
@ -401,8 +401,6 @@ func (suite *ExchangeServiceSuite) TestRestoreMessages() {
func (suite *ExchangeServiceSuite) TestRestoreContact() { func (suite *ExchangeServiceSuite) TestRestoreContact() {
t := suite.T() t := suite.T()
ctx := context.Background() ctx := context.Background()
// TODO: #884 - reinstate when able to specify root folder by name
t.Skip("#884 - reinstate when able to specify root folder by name")
userID := tester.M365UserID(t) userID := tester.M365UserID(t)
now := time.Now() now := time.Now()
@ -428,8 +426,8 @@ func (suite *ExchangeServiceSuite) TestRestoreContact() {
func (suite *ExchangeServiceSuite) TestRestoreEvent() { func (suite *ExchangeServiceSuite) TestRestoreEvent() {
t := suite.T() t := suite.T()
ctx := context.Background() ctx := context.Background()
// TODO: #884 - reinstate when able to specify root folder by name // TODO: #779 - reinstate when restored events to not generate notifications
t.Skip("#884 - reinstate when able to specify root folder by name") t.Skip("#779 - reinstate when restored events to not generate notifications")
userID := tester.M365UserID(t) userID := tester.M365UserID(t)
name := "TestRestoreEvent: " + common.FormatSimpleDateTime(time.Now()) name := "TestRestoreEvent: " + common.FormatSimpleDateTime(time.Now())
calendar, err := CreateCalendar(ctx, suite.es, userID, name) calendar, err := CreateCalendar(ctx, suite.es, userID, name)

View File

@ -116,8 +116,8 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
scope: mailScope, scope: mailScope,
transformer: models.CreateMessageCollectionResponseFromDiscriminatorValue, transformer: models.CreateMessageCollectionResponseFromDiscriminatorValue,
folderNames: map[string]struct{}{ folderNames: map[string]struct{}{
"Inbox": {}, DefaultMailFolder: {},
"Sent Items": {}, "Sent Items": {},
}, },
}, { }, {
name: "Contacts Iterative Check", name: "Contacts Iterative Check",
@ -144,9 +144,9 @@ func (suite *ExchangeIteratorSuite) TestIterativeFunctions() {
scope: mailScope, scope: mailScope,
transformer: models.CreateMailFolderCollectionResponseFromDiscriminatorValue, transformer: models.CreateMailFolderCollectionResponseFromDiscriminatorValue,
folderNames: map[string]struct{}{ folderNames: map[string]struct{}{
"Inbox": {}, DefaultMailFolder: {},
"Sent Items": {}, "Sent Items": {},
"Deleted Items": {}, "Deleted Items": {},
}, },
}, { }, {
name: "Folder Iterative Check Contacts", name: "Folder Iterative Check Contacts",

View File

@ -296,7 +296,7 @@ func TestMailFolderCacheIntegrationSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoGraphConnectorTests, tester.CorsoGraphConnectorTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(MailFolderCacheIntegrationSuite)) suite.Run(t, new(MailFolderCacheIntegrationSuite))

View File

@ -50,7 +50,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllCalendars() {
}, },
{ {
name: "root calendar", name: "root calendar",
contains: "Calendar", contains: DefaultCalendar,
user: suite.m365UserID, user: suite.m365UserID,
expectCount: assert.Greater, expectCount: assert.Greater,
expectErr: assert.NoError, expectErr: assert.NoError,
@ -96,7 +96,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllContactFolders() {
}, },
{ {
name: "root folder", name: "root folder",
contains: "Contact", contains: "Contact", // DefaultContactFolder doesn't work here?
user: user, user: user,
expectCount: assert.Greater, expectCount: assert.Greater,
expectErr: assert.NoError, expectErr: assert.NoError,
@ -141,7 +141,7 @@ func (suite *ServiceFunctionsIntegrationSuite) TestGetAllMailFolders() {
}, },
{ {
name: "Root folder", name: "Root folder",
contains: "Inbox", contains: DefaultMailFolder,
user: suite.m365UserID, user: suite.m365UserID,
expectCount: assert.Greater, expectCount: assert.Greater,
expectErr: assert.NoError, expectErr: assert.NoError,

View File

@ -144,13 +144,7 @@ func (suite *GraphConnectorIntegrationSuite) TestMailSerializationRegression() {
connector := loadConnector(ctx, t) connector := loadConnector(ctx, t)
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.MailFolders([]string{suite.user}, []string{exchange.DefaultMailFolder})) sel.Include(sel.MailFolders([]string{suite.user}, []string{exchange.DefaultMailFolder}))
eb, err := sel.ToExchangeBackup() collection, err := connector.createCollections(context.Background(), sel.Scopes()[0])
require.NoError(t, err)
scopes := eb.Scopes()
suite.Len(scopes, 1)
mailScope := scopes[0]
collection, err := connector.createCollections(context.Background(), mailScope)
require.NoError(t, err) require.NoError(t, err)
for _, edc := range collection { for _, edc := range collection {
@ -189,14 +183,7 @@ func (suite *GraphConnectorIntegrationSuite) TestContactSerializationRegression(
getCollection: func(t *testing.T) []*exchange.Collection { getCollection: func(t *testing.T) []*exchange.Collection {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.ContactFolders([]string{suite.user}, []string{exchange.DefaultContactFolder})) sel.Include(sel.ContactFolders([]string{suite.user}, []string{exchange.DefaultContactFolder}))
eb, err := sel.ToExchangeBackup() collections, err := connector.createCollections(context.Background(), sel.Scopes()[0])
require.NoError(t, err)
scopes := eb.Scopes()
suite.Len(scopes, 1)
contactsOnly := scopes[0]
collections, err := connector.createCollections(context.Background(), contactsOnly)
require.NoError(t, err) require.NoError(t, err)
return collections return collections
@ -246,9 +233,7 @@ func (suite *GraphConnectorIntegrationSuite) TestEventsSerializationRegression()
getCollection: func(t *testing.T) []*exchange.Collection { getCollection: func(t *testing.T) []*exchange.Collection {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.EventCalendars([]string{suite.user}, []string{exchange.DefaultCalendar})) sel.Include(sel.EventCalendars([]string{suite.user}, []string{exchange.DefaultCalendar}))
scopes := sel.Scopes() collections, err := connector.createCollections(context.Background(), sel.Scopes()[0])
suite.Equal(len(scopes), 1)
collections, err := connector.createCollections(context.Background(), scopes[0])
require.NoError(t, err) require.NoError(t, err)
return collections return collections
@ -260,9 +245,7 @@ func (suite *GraphConnectorIntegrationSuite) TestEventsSerializationRegression()
getCollection: func(t *testing.T) []*exchange.Collection { getCollection: func(t *testing.T) []*exchange.Collection {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.EventCalendars([]string{suite.user}, []string{"Birthdays"})) sel.Include(sel.EventCalendars([]string{suite.user}, []string{"Birthdays"}))
scopes := sel.Scopes() collections, err := connector.createCollections(context.Background(), sel.Scopes()[0])
suite.Equal(len(scopes), 1)
collections, err := connector.createCollections(context.Background(), scopes[0])
require.NoError(t, err) require.NoError(t, err)
return collections return collections

View File

@ -59,7 +59,7 @@ func TestWrapperIntegrationSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoKopiaWrapperTests, tester.CorsoKopiaWrapperTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(WrapperIntegrationSuite)) suite.Run(t, new(WrapperIntegrationSuite))

View File

@ -64,7 +64,7 @@ func TestModelStoreIntegrationSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoModelStoreTests, tester.CorsoModelStoreTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(ModelStoreIntegrationSuite)) suite.Run(t, new(ModelStoreIntegrationSuite))
@ -662,7 +662,7 @@ func TestModelStoreRegressionSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoModelStoreTests, tester.CorsoModelStoreTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(ModelStoreRegressionSuite)) suite.Run(t, new(ModelStoreRegressionSuite))

View File

@ -607,7 +607,7 @@ func TestKopiaIntegrationSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoKopiaWrapperTests, tester.CorsoKopiaWrapperTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(KopiaIntegrationSuite)) suite.Run(t, new(KopiaIntegrationSuite))
@ -800,7 +800,7 @@ func TestKopiaSimpleRepoIntegrationSuite(t *testing.T) {
tester.CorsoCITests, tester.CorsoCITests,
tester.CorsoKopiaWrapperTests, tester.CorsoKopiaWrapperTests,
); err != nil { ); err != nil {
t.Skip() t.Skip(err)
} }
suite.Run(t, new(KopiaSimpleRepoIntegrationSuite)) suite.Run(t, new(KopiaSimpleRepoIntegrationSuite))

View File

@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/alcionai/corso/src/internal/connector/exchange"
"github.com/alcionai/corso/src/internal/connector/support" "github.com/alcionai/corso/src/internal/connector/support"
"github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/events"
evmock "github.com/alcionai/corso/src/internal/events/mock" evmock "github.com/alcionai/corso/src/internal/events/mock"
@ -158,7 +159,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
name: "Integration Exchange.Mail", name: "Integration Exchange.Mail",
selectFunc: func() *selectors.Selector { selectFunc: func() *selectors.Selector {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.MailFolders([]string{m365UserID}, []string{"Inbox"})) sel.Include(sel.MailFolders([]string{m365UserID}, []string{exchange.DefaultMailFolder}))
return &sel.Selector return &sel.Selector
}, },
}, },
@ -167,7 +168,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
name: "Integration Exchange.Contacts", name: "Integration Exchange.Contacts",
selectFunc: func() *selectors.Selector { selectFunc: func() *selectors.Selector {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.ContactFolders([]string{m365UserID}, selectors.Any())) sel.Include(sel.ContactFolders([]string{m365UserID}, []string{exchange.DefaultContactFolder}))
return &sel.Selector return &sel.Selector
}, },
}, },
@ -175,7 +176,7 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
name: "Integration Exchange.Events", name: "Integration Exchange.Events",
selectFunc: func() *selectors.Selector { selectFunc: func() *selectors.Selector {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.EventCalendars([]string{m365UserID}, selectors.Any())) sel.Include(sel.EventCalendars([]string{m365UserID}, []string{exchange.DefaultCalendar}))
return &sel.Selector return &sel.Selector
}, },

View File

@ -147,7 +147,7 @@ func (suite *RestoreOpIntegrationSuite) SetupSuite() {
suite.sw = sw suite.sw = sw
bsel := selectors.NewExchangeBackup() bsel := selectors.NewExchangeBackup()
bsel.Include(bsel.MailFolders([]string{m365UserID}, []string{"Inbox"})) bsel.Include(bsel.MailFolders([]string{m365UserID}, []string{exchange.DefaultMailFolder}))
bo, err := NewBackupOperation( bo, err := NewBackupOperation(
ctx, ctx,