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/config"
"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/tester"
"github.com/alcionai/corso/src/pkg/account"
@ -187,13 +188,13 @@ func (suite *PreparedBackupExchangeIntegrationSuite) SetupSuite() {
switch set {
case email:
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{"Inbox"})
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{exchange.DefaultMailFolder})
case contacts:
scopes = sel.ContactFolders([]string{suite.m365UserID}, selectors.Any())
scopes = sel.ContactFolders([]string{suite.m365UserID}, []string{exchange.DefaultContactFolder})
case events:
scopes = sel.EventCalendars([]string{suite.m365UserID}, selectors.Any())
scopes = sel.EventCalendars([]string{suite.m365UserID}, []string{exchange.DefaultCalendar})
}
sel.Include(scopes)
@ -351,7 +352,7 @@ func (suite *BackupDeleteExchangeIntegrationSuite) SetupSuite() {
// some tests require an existing backup
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)
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/config"
"github.com/alcionai/corso/src/internal/connector/exchange"
"github.com/alcionai/corso/src/internal/operations"
"github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/pkg/account"
@ -31,7 +32,7 @@ var (
// dataset to grow until timeouts occur.
// var backupDataSets = []path.CategoryType{email, contacts, events}
var backupDataSets = []path.CategoryType{email}
var backupDataSets = []path.CategoryType{contacts, email}
type RestoreExchangeIntegrationSuite struct {
suite.Suite
@ -96,13 +97,13 @@ func (suite *RestoreExchangeIntegrationSuite) SetupSuite() {
switch set {
case email:
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{"Inbox"})
scopes = sel.MailFolders([]string{suite.m365UserID}, []string{exchange.DefaultMailFolder})
case contacts:
scopes = sel.ContactFolders([]string{suite.m365UserID}, selectors.Any())
scopes = sel.ContactFolders([]string{suite.m365UserID}, []string{exchange.DefaultContactFolder})
case events:
scopes = sel.EventCalendars([]string{suite.m365UserID}, selectors.Any())
scopes = sel.EventCalendars([]string{suite.m365UserID}, []string{exchange.DefaultCalendar})
}
sel.Include(scopes)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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