Consolidate groups version bump tests (#4572)

#### Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No

#### Type of change

- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

* #4569

#### Test Plan

- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-11-13 16:32:03 -08:00 committed by GitHub
parent bb27b8e44d
commit 15418d0dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 157 additions and 420 deletions

View File

@ -904,115 +904,14 @@ func (suite *ExchangeBackupNightlyIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T())
}
func (suite *ExchangeBackupNightlyIntgSuite) TestBackup_Run_exchangeBasic_groups9VersionBump() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
counter = count.New()
sel = selectors.NewExchangeBackup([]string{suite.its.user.ID})
opts = control.DefaultOptions()
ws = deeTD.DriveIDFromRepoRef
)
func (suite *ExchangeBackupNightlyIntgSuite) TestBackup_Run_exchangeVersion9MergeBase() {
sel := selectors.NewExchangeBackup([]string{suite.its.user.ID})
sel.Include(
sel.ContactFolders([]string{api.DefaultContacts}, selectors.PrefixMatch()),
// sel.EventCalendars([]string{api.DefaultCalendar}, selectors.PrefixMatch()),
sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
bo, bod := prepNewTestBackupOp(
t,
ctx,
mb,
sel.Selector,
opts,
version.All8MigrateUserPNToID,
counter)
defer bod.close(t, ctx)
runAndCheckBackup(t, ctx, &bo, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&bo,
bod.sel,
bod.sel.ID(),
path.EmailCategory)
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
bo.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.ExchangeService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
bo.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
mb = evmock.NewBus()
counter = count.New()
notForcedFull := newTestBackupOp(
t,
ctx,
bod,
mb,
opts,
counter)
notForcedFull.BackupVersion = version.Groups9Update
runAndCheckBackup(t, ctx, &notForcedFull, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&notForcedFull,
bod.sel,
bod.sel.ID(),
path.EmailCategory)
_, expectDeets = deeTD.GetDeetsInBackup(
t,
ctx,
notForcedFull.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.ExchangeService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
notForcedFull.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
// The number of items backed up in the second backup should be less than the
// number of items in the original backup.
assert.Greater(
t,
bo.Results.Counts[string(count.PersistedNonCachedFiles)],
notForcedFull.Results.Counts[string(count.PersistedNonCachedFiles)],
"items written")
runMergeBaseGroupsUpdate(suite, sel.Selector, true)
}
type ExchangeRestoreNightlyIntgSuite struct {

View File

@ -4,7 +4,6 @@ import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
evmock "github.com/alcionai/corso/src/internal/events/mock"
@ -215,114 +214,13 @@ func (suite *GroupsBackupNightlyIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T())
}
func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsBasic_groups9VersionBump() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
counter = count.New()
sel = selectors.NewGroupsBackup([]string{suite.its.group.ID})
opts = control.DefaultOptions()
whatSet = deeTD.CategoryFromRepoRef
)
func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9MergeBase() {
sel := selectors.NewGroupsBackup([]string{suite.its.group.ID})
sel.Include(
selTD.GroupsBackupLibraryFolderScope(sel),
selTD.GroupsBackupChannelScope(sel))
bo, bod := prepNewTestBackupOp(
t,
ctx,
mb,
sel.Selector,
opts,
version.All8MigrateUserPNToID,
counter)
defer bod.close(t, ctx)
runAndCheckBackup(t, ctx, &bo, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&bo,
bod.sel,
bod.sel.ID(),
path.ChannelMessagesCategory)
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
bo.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.GroupsService,
whatSet,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
bo.Results.BackupID,
whatSet,
bod.kms,
bod.sss,
expectDeets,
false)
mb = evmock.NewBus()
counter = count.New()
forcedFull := newTestBackupOp(
t,
ctx,
bod,
mb,
opts,
counter)
forcedFull.BackupVersion = version.Groups9Update
runAndCheckBackup(t, ctx, &forcedFull, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&forcedFull,
bod.sel,
bod.sel.ID(),
path.ChannelMessagesCategory)
_, expectDeets = deeTD.GetDeetsInBackup(
t,
ctx,
forcedFull.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.GroupsService,
whatSet,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
forcedFull.Results.BackupID,
whatSet,
bod.kms,
bod.sss,
expectDeets,
false)
// The number of items backed up in the forced full backup should be roughly
// the same as the number of items in the original backup.
assert.Equal(
t,
bo.Results.Counts[string(count.PersistedNonCachedFiles)],
forcedFull.Results.Counts[string(count.PersistedNonCachedFiles)],
"items written")
runMergeBaseGroupsUpdate(suite, sel.Selector, false)
}
func (suite *GroupsBackupNightlyIntgSuite) TestBackup_Run_groupsVersion9AssistBases() {

View File

@ -28,9 +28,11 @@ import (
"github.com/alcionai/corso/src/internal/streamstore"
"github.com/alcionai/corso/src/internal/tester"
"github.com/alcionai/corso/src/internal/tester/tconfig"
"github.com/alcionai/corso/src/internal/version"
"github.com/alcionai/corso/src/pkg/account"
"github.com/alcionai/corso/src/pkg/backup"
"github.com/alcionai/corso/src/pkg/backup/details"
deeTD "github.com/alcionai/corso/src/pkg/backup/details/testdata"
"github.com/alcionai/corso/src/pkg/backup/identity"
"github.com/alcionai/corso/src/pkg/control"
"github.com/alcionai/corso/src/pkg/control/repository"
@ -374,6 +376,147 @@ func checkMetadataFilesExist(
}
}
func runMergeBaseGroupsUpdate(
suite tester.Suite,
sel selectors.Selector,
expectCached bool,
) {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
opts = control.DefaultOptions()
whatSet = deeTD.CategoryFromRepoRef
)
// Need outside the inner test case so bod lasts for the entire test.
bo, bod := prepNewTestBackupOp(
t,
ctx,
mb,
sel,
opts,
version.All8MigrateUserPNToID,
count.New())
defer bod.close(t, ctx)
suite.Run("makeMergeBackup", func() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
runAndCheckBackup(t, ctx, &bo, mb, false)
reasons, err := bod.sel.Reasons(bod.acct.ID(), false)
require.NoError(t, err, clues.ToCore(err))
for _, reason := range reasons {
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&bo,
bod.sel,
bod.sel.ID(),
reason.Category())
}
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
bo.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
bod.sel.PathService(),
whatSet,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
bo.Results.BackupID,
whatSet,
bod.kms,
bod.sss,
expectDeets,
false)
})
suite.Run("makeIncrementalBackup", func() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
opts = control.DefaultOptions()
)
forcedFull := newTestBackupOp(
t,
ctx,
bod,
mb,
opts,
count.New())
forcedFull.BackupVersion = version.Groups9Update
runAndCheckBackup(t, ctx, &forcedFull, mb, false)
reasons, err := bod.sel.Reasons(bod.acct.ID(), false)
require.NoError(t, err, clues.ToCore(err))
for _, reason := range reasons {
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&forcedFull,
bod.sel,
bod.sel.ID(),
reason.Category())
}
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
forcedFull.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
bod.sel.PathService(),
whatSet,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
forcedFull.Results.BackupID,
whatSet,
bod.kms,
bod.sss,
expectDeets,
false)
check := assert.Zero
if expectCached {
check = assert.NotZero
}
check(
t,
forcedFull.Results.Counts[string(count.PersistedCachedFiles)],
"cached items")
})
}
// ---------------------------------------------------------------------------
// Incremental Item Generators
// TODO: this is ripped from factory.go, which is ripped from other tests.

View File

@ -1189,7 +1189,7 @@ type OneDriveBackupNightlyIntgSuite struct {
}
func TestOneDriveBackupNightlyIntgSuite(t *testing.T) {
suite.Run(t, &OneDriveBackupIntgSuite{
suite.Run(t, &OneDriveBackupNightlyIntgSuite{
Suite: tester.NewNightlySuite(
t,
[][]string{tconfig.M365AcctCredEnvs, storeTD.AWSStorageCredEnvs}),
@ -1200,113 +1200,11 @@ func (suite *OneDriveBackupNightlyIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T())
}
func (suite *OneDriveBackupNightlyIntgSuite) TestBackup_Run_oneDriveBasic_groups9VersionBump() {
t := suite.T()
func (suite *OneDriveBackupNightlyIntgSuite) TestBackup_Run_oneDriveVersion9MergeBase() {
sel := selectors.NewOneDriveBackup([]string{suite.its.user.ID})
sel.Include(selTD.OneDriveBackupFolderScope(sel))
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
counter = count.New()
userID = tconfig.SecondaryM365UserID(t)
osel = selectors.NewOneDriveBackup([]string{userID})
ws = deeTD.DriveIDFromRepoRef
opts = control.DefaultOptions()
)
osel.Include(selTD.OneDriveBackupFolderScope(osel))
bo, bod := prepNewTestBackupOp(
t,
ctx,
mb,
osel.Selector,
opts,
version.All8MigrateUserPNToID,
counter)
defer bod.close(t, ctx)
runAndCheckBackup(t, ctx, &bo, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&bo,
bod.sel,
bod.sel.ID(),
path.FilesCategory)
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
bo.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.OneDriveService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
bo.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
mb = evmock.NewBus()
counter = count.New()
notForcedFull := newTestBackupOp(
t,
ctx,
bod,
mb,
opts,
counter)
notForcedFull.BackupVersion = version.Groups9Update
runAndCheckBackup(t, ctx, &notForcedFull, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&notForcedFull,
bod.sel,
bod.sel.ID(),
path.FilesCategory)
_, expectDeets = deeTD.GetDeetsInBackup(
t,
ctx,
notForcedFull.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.OneDriveService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
notForcedFull.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
// The number of items backed up in the second backup should be less than the
// number of items in the original backup.
assert.Greater(
t,
bo.Results.Counts[string(count.PersistedNonCachedFiles)],
notForcedFull.Results.Counts[string(count.PersistedNonCachedFiles)],
"items written")
runMergeBaseGroupsUpdate(suite, sel.Selector, true)
}
//func (suite *OneDriveBackupNightlyIntgSuite) TestBackup_Run_oneDriveVersion9AssistBases() {

View File

@ -200,112 +200,11 @@ func (suite *SharePointBackupNightlyIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T())
}
func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointBasic_groups9VersionBump() {
t := suite.T()
ctx, flush := tester.NewContext(t)
defer flush()
var (
mb = evmock.NewBus()
counter = count.New()
sel = selectors.NewSharePointBackup([]string{suite.its.site.ID})
opts = control.DefaultOptions()
ws = deeTD.DriveIDFromRepoRef
)
func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointVersion9MergeBase() {
sel := selectors.NewSharePointBackup([]string{suite.its.site.ID})
sel.Include(selTD.SharePointBackupFolderScope(sel))
bo, bod := prepNewTestBackupOp(
t,
ctx,
mb,
sel.Selector,
opts,
version.All8MigrateUserPNToID,
counter)
defer bod.close(t, ctx)
runAndCheckBackup(t, ctx, &bo, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&bo,
bod.sel,
bod.sel.ID(),
path.LibrariesCategory)
_, expectDeets := deeTD.GetDeetsInBackup(
t,
ctx,
bo.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.SharePointService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
bo.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
mb = evmock.NewBus()
counter = count.New()
notForcedFull := newTestBackupOp(
t,
ctx,
bod,
mb,
opts,
counter)
notForcedFull.BackupVersion = version.Groups9Update
runAndCheckBackup(t, ctx, &notForcedFull, mb, false)
checkBackupIsInManifests(
t,
ctx,
bod.kw,
bod.sw,
&notForcedFull,
bod.sel,
bod.sel.ID(),
path.LibrariesCategory)
_, expectDeets = deeTD.GetDeetsInBackup(
t,
ctx,
notForcedFull.Results.BackupID,
bod.acct.ID(),
bod.sel.ID(),
path.SharePointService,
ws,
bod.kms,
bod.sss)
deeTD.CheckBackupDetails(
t,
ctx,
notForcedFull.Results.BackupID,
ws,
bod.kms,
bod.sss,
expectDeets,
false)
// The number of items backed up in the second backup should be less than the
// number of items in the original backup.
assert.Greater(
t,
bo.Results.Counts[string(count.PersistedNonCachedFiles)],
notForcedFull.Results.Counts[string(count.PersistedNonCachedFiles)],
"items written")
runMergeBaseGroupsUpdate(suite, sel.Selector, true)
}
func (suite *SharePointBackupNightlyIntgSuite) TestBackup_Run_sharePointVersion9AssistBases() {