unskip event restores (#1019)

## Type of change

- [x] 🤖 Test

## Issue(s)

* #1018

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2022-10-14 14:38:33 -06:00 committed by GitHub
parent f69e27b6fd
commit 7d72cd12a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 51 deletions

View File

@ -28,12 +28,7 @@ var (
events = path.EventsCategory events = path.EventsCategory
) )
// TODO: bring back event restore testing when they no longer produce var backupDataSets = []path.CategoryType{email, contacts, events}
// notification emails. Currently, the duplication causes our tests
// dataset to grow until timeouts occur.
// var backupDataSets = []path.CategoryType{email, contacts, events}
var backupDataSets = []path.CategoryType{contacts, email}
type RestoreExchangeIntegrationSuite struct { type RestoreExchangeIntegrationSuite struct {
suite.Suite suite.Suite

View File

@ -448,9 +448,6 @@ func (suite *ExchangeServiceSuite) TestRestoreEvent() {
// TestRestoreExchangeObject verifies path.Category usage for restored objects // TestRestoreExchangeObject verifies path.Category usage for restored objects
func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() { func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
ctx, flush := tester.NewContext()
defer flush()
t := suite.T() t := suite.T()
userID := tester.M365UserID(t) userID := tester.M365UserID(t)
now := time.Now() now := time.Now()
@ -459,14 +456,14 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
bytes []byte bytes []byte
category path.CategoryType category path.CategoryType
cleanupFunc func(context.Context, graph.Service, string, string) error cleanupFunc func(context.Context, graph.Service, string, string) error
destination func() string destination func(context.Context) string
}{ }{
{ {
name: "Test Mail", name: "Test Mail",
bytes: mockconnector.GetMockMessageBytes("Restore Exchange Object"), bytes: mockconnector.GetMockMessageBytes("Restore Exchange Object"),
category: path.EmailCategory, category: path.EmailCategory,
cleanupFunc: DeleteMailFolder, cleanupFunc: DeleteMailFolder,
destination: func() string { destination: func(ctx context.Context) string {
folderName := "TestRestoreMailObject: " + common.FormatSimpleDateTime(now) folderName := "TestRestoreMailObject: " + common.FormatSimpleDateTime(now)
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName) folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
require.NoError(t, err) require.NoError(t, err)
@ -479,7 +476,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
bytes: mockconnector.GetMockMessageWithDirectAttachment("Restore 1 Attachment"), bytes: mockconnector.GetMockMessageWithDirectAttachment("Restore 1 Attachment"),
category: path.EmailCategory, category: path.EmailCategory,
cleanupFunc: DeleteMailFolder, cleanupFunc: DeleteMailFolder,
destination: func() string { destination: func(ctx context.Context) string {
folderName := "TestRestoreMailwithAttachment: " + common.FormatSimpleDateTime(now) folderName := "TestRestoreMailwithAttachment: " + common.FormatSimpleDateTime(now)
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName) folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
require.NoError(t, err) require.NoError(t, err)
@ -492,7 +489,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
bytes: mockconnector.GetMockMessageWithLargeAttachment("Restore Large Attachment"), bytes: mockconnector.GetMockMessageWithLargeAttachment("Restore Large Attachment"),
category: path.EmailCategory, category: path.EmailCategory,
cleanupFunc: DeleteMailFolder, cleanupFunc: DeleteMailFolder,
destination: func() string { destination: func(ctx context.Context) string {
folderName := "TestRestoreMailwithLargeAttachment: " + common.FormatSimpleDateTime(now) folderName := "TestRestoreMailwithLargeAttachment: " + common.FormatSimpleDateTime(now)
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName) folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
require.NoError(t, err) require.NoError(t, err)
@ -505,7 +502,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
bytes: mockconnector.GetMockMessageWithTwoAttachments("Restore 2 Attachments"), bytes: mockconnector.GetMockMessageWithTwoAttachments("Restore 2 Attachments"),
category: path.EmailCategory, category: path.EmailCategory,
cleanupFunc: DeleteMailFolder, cleanupFunc: DeleteMailFolder,
destination: func() string { destination: func(ctx context.Context) string {
folderName := "TestRestoreMailwithAttachments: " + common.FormatSimpleDateTime(now) folderName := "TestRestoreMailwithAttachments: " + common.FormatSimpleDateTime(now)
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName) folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
require.NoError(t, err) require.NoError(t, err)
@ -514,38 +511,41 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
}, },
}, },
// TODO: #884 - reinstate when able to specify root folder by name // TODO: #884 - reinstate when able to specify root folder by name
// { {
// name: "Test Contact", name: "Test Contact",
// bytes: mockconnector.GetMockContactBytes("Test_Omega"), bytes: mockconnector.GetMockContactBytes("Test_Omega"),
// category: path.ContactsCategory, category: path.ContactsCategory,
// cleanupFunc: DeleteContactFolder, cleanupFunc: DeleteContactFolder,
// destination: func() string { destination: func(ctx context.Context) string {
// folderName := "TestRestoreContactObject: " + common.FormatSimpleDateTime(now) folderName := "TestRestoreContactObject: " + common.FormatSimpleDateTime(now)
// folder, err := CreateContactFolder(suite.es, userID, folderName) folder, err := CreateContactFolder(ctx, suite.es, userID, folderName)
// require.NoError(t, err) require.NoError(t, err)
// return *folder.GetId() return *folder.GetId()
// }, },
// }, },
// { {
// name: "Test Events", name: "Test Events",
// bytes: mockconnector.GetMockEventBytes("Restored Event Object"), bytes: mockconnector.GetMockEventBytes("Restored Event Object"),
// category: path.EventsCategory, category: path.EventsCategory,
// cleanupFunc: DeleteCalendar, cleanupFunc: DeleteCalendar,
// destination: func() string { destination: func(ctx context.Context) string {
// calendarName := "TestRestoreEventObject: " + common.FormatSimpleDateTime(now) calendarName := "TestRestoreEventObject: " + common.FormatSimpleDateTime(now)
// calendar, err := CreateCalendar(suite.es, userID, calendarName) calendar, err := CreateCalendar(ctx, suite.es, userID, calendarName)
// require.NoError(t, err) require.NoError(t, err)
// return *calendar.GetId() return *calendar.GetId()
// }, },
// }, },
} }
for _, test := range tests { for _, test := range tests {
suite.T().Run(test.name, func(t *testing.T) { suite.T().Run(test.name, func(t *testing.T) {
ctx, flush := tester.NewContext()
defer flush()
service := loadService(t) service := loadService(t)
destination := test.destination() destination := test.destination(ctx)
info, err := RestoreExchangeObject( info, err := RestoreExchangeObject(
ctx, ctx,
test.bytes, test.bytes,

View File

@ -231,7 +231,6 @@ func (op *BackupOperation) createBackupModels(
events.Service: op.Selectors.Service.String(), events.Service: op.Selectors.Service.String(),
events.StartTime: op.Results.StartedAt, events.StartTime: op.Results.StartedAt,
events.Status: op.Status, events.Status: op.Status,
// TODO: events.ExchangeDataObserved: <amount of data retrieved>,
}, },
) )

View File

@ -178,10 +178,8 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
ctx, flush := tester.NewContext() ctx, flush := tester.NewContext()
defer flush() defer flush()
t := suite.T() m365UserID := tester.M365UserID(suite.T())
acct := tester.NewM365Account(suite.T())
m365UserID := tester.M365UserID(t)
acct := tester.NewM365Account(t)
tests := []struct { tests := []struct {
name string name string
@ -195,7 +193,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
return &sel.Selector return &sel.Selector
}, },
}, },
{ {
name: "Integration Exchange.Contacts", name: "Integration Exchange.Contacts",
selectFunc: func() *selectors.Selector { selectFunc: func() *selectors.Selector {
@ -209,7 +206,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
selectFunc: func() *selectors.Selector { selectFunc: func() *selectors.Selector {
sel := selectors.NewExchangeBackup() sel := selectors.NewExchangeBackup()
sel.Include(sel.EventCalendars([]string{m365UserID}, []string{exchange.DefaultCalendar})) sel.Include(sel.EventCalendars([]string{m365UserID}, []string{exchange.DefaultCalendar}))
return &sel.Selector return &sel.Selector
}, },
}, },
@ -250,14 +246,14 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
require.NoError(t, bo.Run(ctx)) require.NoError(t, bo.Run(ctx))
require.NotEmpty(t, bo.Results) require.NotEmpty(t, bo.Results)
require.NotEmpty(t, bo.Results.BackupID) require.NotEmpty(t, bo.Results.BackupID)
assert.Equal(t, bo.Status, Completed) assert.Equalf(t, Completed, bo.Status, "backup status %s is not Completed", bo.Status)
assert.Less(t, 0, bo.Results.ItemsRead) assert.Less(t, 0, bo.Results.ItemsRead)
assert.Less(t, 0, bo.Results.ItemsWritten) assert.Less(t, 0, bo.Results.ItemsWritten)
assert.Less(t, int64(0), bo.Results.BytesRead, "bytes read") assert.Less(t, int64(0), bo.Results.BytesRead, "bytes read")
assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded") assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded")
assert.Equal(t, 1, bo.Results.ResourceOwners) assert.Equal(t, 1, bo.Results.ResourceOwners)
assert.Zero(t, bo.Results.ReadErrors) assert.NoError(t, bo.Results.ReadErrors)
assert.Zero(t, bo.Results.WriteErrors) assert.NoError(t, bo.Results.WriteErrors)
assert.Equal(t, 1, mb.TimesCalled[events.BackupStart], "backup-start events") 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, 1, mb.TimesCalled[events.BackupEnd], "backup-end events")
assert.Equal(t, assert.Equal(t,
@ -316,7 +312,7 @@ func (suite *BackupOpIntegrationSuite) TestBackupOneDrive_Run() {
require.NoError(t, bo.Run(ctx)) require.NoError(t, bo.Run(ctx))
require.NotEmpty(t, bo.Results) require.NotEmpty(t, bo.Results)
require.NotEmpty(t, bo.Results.BackupID) require.NotEmpty(t, bo.Results.BackupID)
assert.Equal(t, bo.Status, Completed) assert.Equalf(t, Completed, bo.Status, "backup status %s is not Completed", bo.Status)
assert.Equal(t, bo.Results.ItemsRead, bo.Results.ItemsWritten) assert.Equal(t, bo.Results.ItemsRead, bo.Results.ItemsWritten)
assert.Less(t, int64(0), bo.Results.BytesRead, "bytes read") assert.Less(t, int64(0), bo.Results.BytesRead, "bytes read")
assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded") assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded")

View File

@ -179,7 +179,11 @@ func (suite *RestoreOpIntegrationSuite) SetupSuite() {
suite.sw = sw suite.sw = sw
bsel := selectors.NewExchangeBackup() bsel := selectors.NewExchangeBackup()
bsel.Include(bsel.MailFolders([]string{m365UserID}, []string{exchange.DefaultMailFolder})) bsel.Include(
bsel.MailFolders([]string{m365UserID}, []string{exchange.DefaultMailFolder}),
bsel.ContactFolders([]string{m365UserID}, []string{exchange.DefaultContactFolder}),
bsel.EventCalendars([]string{m365UserID}, []string{exchange.DefaultCalendar}),
)
bo, err := NewBackupOperation( bo, err := NewBackupOperation(
ctx, ctx,