unskip event restores (#1019)
## Type of change - [x] 🤖 Test ## Issue(s) * #1018 ## Test Plan - [x] 💚 E2E
This commit is contained in:
parent
f69e27b6fd
commit
7d72cd12a4
@ -28,12 +28,7 @@ var (
|
||||
events = path.EventsCategory
|
||||
)
|
||||
|
||||
// TODO: bring back event restore testing when they no longer produce
|
||||
// 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}
|
||||
var backupDataSets = []path.CategoryType{email, contacts, events}
|
||||
|
||||
type RestoreExchangeIntegrationSuite struct {
|
||||
suite.Suite
|
||||
|
||||
@ -448,9 +448,6 @@ func (suite *ExchangeServiceSuite) TestRestoreEvent() {
|
||||
|
||||
// TestRestoreExchangeObject verifies path.Category usage for restored objects
|
||||
func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
t := suite.T()
|
||||
userID := tester.M365UserID(t)
|
||||
now := time.Now()
|
||||
@ -459,14 +456,14 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
bytes []byte
|
||||
category path.CategoryType
|
||||
cleanupFunc func(context.Context, graph.Service, string, string) error
|
||||
destination func() string
|
||||
destination func(context.Context) string
|
||||
}{
|
||||
{
|
||||
name: "Test Mail",
|
||||
bytes: mockconnector.GetMockMessageBytes("Restore Exchange Object"),
|
||||
category: path.EmailCategory,
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
destination: func(ctx context.Context) string {
|
||||
folderName := "TestRestoreMailObject: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
@ -479,7 +476,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
bytes: mockconnector.GetMockMessageWithDirectAttachment("Restore 1 Attachment"),
|
||||
category: path.EmailCategory,
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
destination: func(ctx context.Context) string {
|
||||
folderName := "TestRestoreMailwithAttachment: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
@ -492,7 +489,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
bytes: mockconnector.GetMockMessageWithLargeAttachment("Restore Large Attachment"),
|
||||
category: path.EmailCategory,
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
destination: func(ctx context.Context) string {
|
||||
folderName := "TestRestoreMailwithLargeAttachment: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
@ -505,7 +502,7 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
bytes: mockconnector.GetMockMessageWithTwoAttachments("Restore 2 Attachments"),
|
||||
category: path.EmailCategory,
|
||||
cleanupFunc: DeleteMailFolder,
|
||||
destination: func() string {
|
||||
destination: func(ctx context.Context) string {
|
||||
folderName := "TestRestoreMailwithAttachments: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateMailFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
@ -514,38 +511,41 @@ func (suite *ExchangeServiceSuite) TestRestoreExchangeObject() {
|
||||
},
|
||||
},
|
||||
// TODO: #884 - reinstate when able to specify root folder by name
|
||||
// {
|
||||
// name: "Test Contact",
|
||||
// bytes: mockconnector.GetMockContactBytes("Test_Omega"),
|
||||
// category: path.ContactsCategory,
|
||||
// cleanupFunc: DeleteContactFolder,
|
||||
// destination: func() string {
|
||||
// folderName := "TestRestoreContactObject: " + common.FormatSimpleDateTime(now)
|
||||
// folder, err := CreateContactFolder(suite.es, userID, folderName)
|
||||
// require.NoError(t, err)
|
||||
{
|
||||
name: "Test Contact",
|
||||
bytes: mockconnector.GetMockContactBytes("Test_Omega"),
|
||||
category: path.ContactsCategory,
|
||||
cleanupFunc: DeleteContactFolder,
|
||||
destination: func(ctx context.Context) string {
|
||||
folderName := "TestRestoreContactObject: " + common.FormatSimpleDateTime(now)
|
||||
folder, err := CreateContactFolder(ctx, suite.es, userID, folderName)
|
||||
require.NoError(t, err)
|
||||
|
||||
// return *folder.GetId()
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: "Test Events",
|
||||
// bytes: mockconnector.GetMockEventBytes("Restored Event Object"),
|
||||
// category: path.EventsCategory,
|
||||
// cleanupFunc: DeleteCalendar,
|
||||
// destination: func() string {
|
||||
// calendarName := "TestRestoreEventObject: " + common.FormatSimpleDateTime(now)
|
||||
// calendar, err := CreateCalendar(suite.es, userID, calendarName)
|
||||
// require.NoError(t, err)
|
||||
return *folder.GetId()
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test Events",
|
||||
bytes: mockconnector.GetMockEventBytes("Restored Event Object"),
|
||||
category: path.EventsCategory,
|
||||
cleanupFunc: DeleteCalendar,
|
||||
destination: func(ctx context.Context) string {
|
||||
calendarName := "TestRestoreEventObject: " + common.FormatSimpleDateTime(now)
|
||||
calendar, err := CreateCalendar(ctx, suite.es, userID, calendarName)
|
||||
require.NoError(t, err)
|
||||
|
||||
// return *calendar.GetId()
|
||||
// },
|
||||
// },
|
||||
return *calendar.GetId()
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
suite.T().Run(test.name, func(t *testing.T) {
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
service := loadService(t)
|
||||
destination := test.destination()
|
||||
destination := test.destination(ctx)
|
||||
info, err := RestoreExchangeObject(
|
||||
ctx,
|
||||
test.bytes,
|
||||
|
||||
@ -231,7 +231,6 @@ func (op *BackupOperation) createBackupModels(
|
||||
events.Service: op.Selectors.Service.String(),
|
||||
events.StartTime: op.Results.StartedAt,
|
||||
events.Status: op.Status,
|
||||
// TODO: events.ExchangeDataObserved: <amount of data retrieved>,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@ -178,10 +178,8 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
|
||||
ctx, flush := tester.NewContext()
|
||||
defer flush()
|
||||
|
||||
t := suite.T()
|
||||
|
||||
m365UserID := tester.M365UserID(t)
|
||||
acct := tester.NewM365Account(t)
|
||||
m365UserID := tester.M365UserID(suite.T())
|
||||
acct := tester.NewM365Account(suite.T())
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -195,7 +193,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
|
||||
return &sel.Selector
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: "Integration Exchange.Contacts",
|
||||
selectFunc: func() *selectors.Selector {
|
||||
@ -209,7 +206,6 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
|
||||
selectFunc: func() *selectors.Selector {
|
||||
sel := selectors.NewExchangeBackup()
|
||||
sel.Include(sel.EventCalendars([]string{m365UserID}, []string{exchange.DefaultCalendar}))
|
||||
|
||||
return &sel.Selector
|
||||
},
|
||||
},
|
||||
@ -250,14 +246,14 @@ func (suite *BackupOpIntegrationSuite) TestBackup_Run() {
|
||||
require.NoError(t, bo.Run(ctx))
|
||||
require.NotEmpty(t, bo.Results)
|
||||
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.ItemsWritten)
|
||||
assert.Less(t, int64(0), bo.Results.BytesRead, "bytes read")
|
||||
assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded")
|
||||
assert.Equal(t, 1, bo.Results.ResourceOwners)
|
||||
assert.Zero(t, bo.Results.ReadErrors)
|
||||
assert.Zero(t, bo.Results.WriteErrors)
|
||||
assert.NoError(t, bo.Results.ReadErrors)
|
||||
assert.NoError(t, bo.Results.WriteErrors)
|
||||
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,
|
||||
@ -316,7 +312,7 @@ func (suite *BackupOpIntegrationSuite) TestBackupOneDrive_Run() {
|
||||
require.NoError(t, bo.Run(ctx))
|
||||
require.NotEmpty(t, bo.Results)
|
||||
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.Less(t, int64(0), bo.Results.BytesRead, "bytes read")
|
||||
assert.Less(t, int64(0), bo.Results.BytesUploaded, "bytes uploaded")
|
||||
|
||||
@ -179,7 +179,11 @@ func (suite *RestoreOpIntegrationSuite) SetupSuite() {
|
||||
suite.sw = sw
|
||||
|
||||
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(
|
||||
ctx,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user