Add restore tests for groups (#4249)

<!-- PR description-->

---

#### 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

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [x] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* closes https://github.com/alcionai/corso/issues/3992

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [x] 💚 E2E
This commit is contained in:
Abin Simon 2023-09-17 10:33:16 +05:30 committed by GitHub
parent 2f4acc2c5f
commit c2a3041cc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 94 additions and 16 deletions

View File

@ -37,7 +37,6 @@ func (suite *GroupsBackupIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T()) suite.its = newIntegrationTesterSetup(suite.T())
} }
// TODO(v0,v1 restore): Library restore
// TODO(v0 export): Channels export // TODO(v0 export): Channels export
func (suite *GroupsBackupIntgSuite) TestBackup_Run_incrementalGroups() { func (suite *GroupsBackupIntgSuite) TestBackup_Run_incrementalGroups() {
@ -194,3 +193,51 @@ func (suite *GroupsBackupIntgSuite) TestBackup_Run_groupsExtensions() {
} }
} }
} }
type GroupsRestoreNightlyIntgSuite struct {
tester.Suite
its intgTesterSetup
}
func TestGroupsRestoreIntgSuite(t *testing.T) {
suite.Run(t, &GroupsRestoreNightlyIntgSuite{
Suite: tester.NewNightlySuite(
t,
[][]string{tconfig.M365AcctCredEnvs, storeTD.AWSStorageCredEnvs}),
})
}
func (suite *GroupsRestoreNightlyIntgSuite) SetupSuite() {
suite.its = newIntegrationTesterSetup(suite.T())
}
func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsWithAdvancedOptions() {
sel := selectors.NewGroupsBackup([]string{suite.its.group.ID})
sel.Include(selTD.GroupsBackupLibraryFolderScope(sel))
sel.Filter(sel.Library("documents"))
sel.DiscreteOwner = suite.its.group.ID
runDriveRestoreWithAdvancedOptions(
suite.T(),
suite,
suite.its.ac,
sel.Selector,
suite.its.group.RootSite.DriveID,
suite.its.group.RootSite.DriveRootFolderID)
}
func (suite *GroupsRestoreNightlyIntgSuite) TestRestore_Run_groupsAlternateProtectedResource() {
sel := selectors.NewGroupsBackup([]string{suite.its.group.ID})
sel.Include(selTD.GroupsBackupLibraryFolderScope(sel))
sel.Filter(sel.Library("documents"))
sel.DiscreteOwner = suite.its.group.ID
runDriveRestoreToAlternateProtectedResource(
suite.T(),
suite,
suite.its.ac,
sel.Selector,
suite.its.group.RootSite,
suite.its.secondaryGroup.RootSite,
suite.its.secondaryGroup.ID)
}

View File

@ -587,6 +587,7 @@ type intgTesterSetup struct {
site ids site ids
secondarySite ids secondarySite ids
group gids group gids
secondaryGroup gids
} }
func newIntegrationTesterSetup(t *testing.T) intgTesterSetup { func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
@ -614,6 +615,7 @@ func newIntegrationTesterSetup(t *testing.T) intgTesterSetup {
// teamID is used here intentionally. We want the group // teamID is used here intentionally. We want the group
// to have access to teams data // to have access to teams data
its.group = groupIDs(t, tconfig.M365TeamID(t), its.ac) its.group = groupIDs(t, tconfig.M365TeamID(t), its.ac)
its.secondaryGroup = groupIDs(t, tconfig.SecondaryM365TeamID(t), its.ac)
return its return its
} }

View File

@ -1284,7 +1284,8 @@ func (suite *OneDriveRestoreNightlyIntgSuite) TestRestore_Run_onedriveAlternateP
suite.its.ac, suite.its.ac,
sel.Selector, sel.Selector,
suite.its.user, suite.its.user,
suite.its.secondaryUser) suite.its.secondaryUser,
suite.its.secondaryUser.ID)
} }
func runDriveRestoreToAlternateProtectedResource( func runDriveRestoreToAlternateProtectedResource(
@ -1292,7 +1293,8 @@ func runDriveRestoreToAlternateProtectedResource(
suite tester.Suite, suite tester.Suite,
ac api.Client, ac api.Client,
sel selectors.Selector, // owner should match 'from', both Restore and Backup types work. sel selectors.Selector, // owner should match 'from', both Restore and Backup types work.
from, to ids, driveFrom, driveTo ids,
toResource string,
) { ) {
ctx, flush := tester.NewContext(t) ctx, flush := tester.NewContext(t)
defer flush() defer flush()
@ -1321,8 +1323,8 @@ func runDriveRestoreToAlternateProtectedResource(
suite.Run("restore original resource", func() { suite.Run("restore original resource", func() {
mb = evmock.NewBus() mb = evmock.NewBus()
fromCtr := count.New() fromCtr := count.New()
driveID := from.DriveID driveID := driveFrom.DriveID
rootFolderID := from.DriveRootFolderID rootFolderID := driveFrom.DriveRootFolderID
restoreCfg.OnCollision = control.Copy restoreCfg.OnCollision = control.Copy
ro, _ := prepNewTestRestoreOp( ro, _ := prepNewTestRestoreOp(
@ -1359,9 +1361,9 @@ func runDriveRestoreToAlternateProtectedResource(
suite.Run("restore to alternate resource", func() { suite.Run("restore to alternate resource", func() {
mb = evmock.NewBus() mb = evmock.NewBus()
toCtr := count.New() toCtr := count.New()
driveID := to.DriveID driveID := driveTo.DriveID
rootFolderID := to.DriveRootFolderID rootFolderID := driveTo.DriveRootFolderID
restoreCfg.ProtectedResource = to.ID restoreCfg.ProtectedResource = toResource
ro, _ := prepNewTestRestoreOp( ro, _ := prepNewTestRestoreOp(
t, t,

View File

@ -225,7 +225,8 @@ func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointAltern
suite.its.ac, suite.its.ac,
sel.Selector, sel.Selector,
suite.its.site, suite.its.site,
suite.its.secondarySite) suite.its.secondarySite,
suite.its.secondarySite.ID)
} }
func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDeletedDrives() { func (suite *SharePointRestoreNightlyIntgSuite) TestRestore_Run_sharepointDeletedDrives() {

View File

@ -31,6 +31,7 @@ const (
TestCfgUserID = "m365userid" TestCfgUserID = "m365userid"
TestCfgSecondaryUserID = "secondarym365userid" TestCfgSecondaryUserID = "secondarym365userid"
TestCfgSecondaryGroupID = "secondarym365groupid" TestCfgSecondaryGroupID = "secondarym365groupid"
TestCfgSecondaryTeamID = "secondarym365teamid"
TestCfgTertiaryUserID = "tertiarym365userid" TestCfgTertiaryUserID = "tertiarym365userid"
TestCfgLoadTestUserID = "loadtestm365userid" TestCfgLoadTestUserID = "loadtestm365userid"
TestCfgLoadTestOrgUsers = "loadtestm365orgusers" TestCfgLoadTestOrgUsers = "loadtestm365orgusers"
@ -45,7 +46,9 @@ const (
EnvCorsoM365TestSiteID = "CORSO_M365_TEST_SITE_ID" EnvCorsoM365TestSiteID = "CORSO_M365_TEST_SITE_ID"
EnvCorsoM365TestSiteURL = "CORSO_M365_TEST_SITE_URL" EnvCorsoM365TestSiteURL = "CORSO_M365_TEST_SITE_URL"
EnvCorsoM365TestTeamID = "CORSO_M365_TEST_TEAM_ID" EnvCorsoM365TestTeamID = "CORSO_M365_TEST_TEAM_ID"
EnvCorsoSecondaryM365TestTeamID = "CORSO_SECONDARY_M365_TEST_TEAM_ID"
EnvCorsoM365TestGroupID = "CORSO_M365_TEST_GROUP_ID" EnvCorsoM365TestGroupID = "CORSO_M365_TEST_GROUP_ID"
EnvCorsoSecondaryM365TestGroupID = "CORSO_SECONDARY_M365_TEST_GROUP_ID"
EnvCorsoM365TestUserID = "CORSO_M365_TEST_USER_ID" EnvCorsoM365TestUserID = "CORSO_M365_TEST_USER_ID"
EnvCorsoSecondaryM365TestSiteID = "CORSO_SECONDARY_M365_TEST_SITE_ID" EnvCorsoSecondaryM365TestSiteID = "CORSO_SECONDARY_M365_TEST_SITE_ID"
EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M365_TEST_USER_ID" EnvCorsoSecondaryM365TestUserID = "CORSO_SECONDARY_M365_TEST_USER_ID"
@ -161,12 +164,24 @@ func ReadTestConfig() (map[string]string, error) {
os.Getenv(EnvCorsoM365TestTeamID), os.Getenv(EnvCorsoM365TestTeamID),
vpr.GetString(TestCfgTeamID), vpr.GetString(TestCfgTeamID),
"6f24b40d-b13d-4752-980f-f5fb9fba7aa0") "6f24b40d-b13d-4752-980f-f5fb9fba7aa0")
fallbackTo(
testEnv,
TestCfgSecondaryTeamID,
os.Getenv(EnvCorsoSecondaryM365TestTeamID),
vpr.GetString(TestCfgSecondaryTeamID),
"20cda3c0-6f9a-4286-9f2f-bb284e1f79c9")
fallbackTo( fallbackTo(
testEnv, testEnv,
TestCfgGroupID, TestCfgGroupID,
os.Getenv(EnvCorsoM365TestGroupID), os.Getenv(EnvCorsoM365TestGroupID),
vpr.GetString(TestCfgGroupID), vpr.GetString(TestCfgGroupID),
"6f24b40d-b13d-4752-980f-f5fb9fba7aa0") "6f24b40d-b13d-4752-980f-f5fb9fba7aa0")
fallbackTo(
testEnv,
TestCfgSecondaryGroupID,
os.Getenv(EnvCorsoSecondaryM365TestGroupID),
vpr.GetString(TestCfgSecondaryGroupID),
"20cda3c0-6f9a-4286-9f2f-bb284e1f79c9")
fallbackTo( fallbackTo(
testEnv, testEnv,
TestCfgSiteURL, TestCfgSiteURL,

View File

@ -234,6 +234,17 @@ func M365TeamID(t *testing.T) string {
return strings.ToLower(cfg[TestCfgTeamID]) return strings.ToLower(cfg[TestCfgTeamID])
} }
// SecondaryM365TeamID returns a teamID string representing the secondarym365TeamID described
// by either the env var CORSO_SECONDARY_M365_TEST_TEAM_ID, the corso_test.toml config
// file or the default value (in that order of priority). The default is a
// last-attempt fallback that will only work on alcion's testing org.
func SecondaryM365TeamID(t *testing.T) string {
cfg, err := ReadTestConfig()
require.NoError(t, err, "retrieving secondary m365 team id from test configuration: %+v", clues.ToCore(err))
return strings.ToLower(cfg[TestCfgSecondaryTeamID])
}
// Groups // Groups
// M365GroupID returns a groupID string representing the m365GroupID described // M365GroupID returns a groupID string representing the m365GroupID described