Fix nightly tests for exchange, onedrive and groups (#4384)

We were trying to delete a single backupOp multiple times across different tests. Added another backupOp to for use in the new test.

<!-- 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. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [x] 💚 E2E
This commit is contained in:
Abin Simon 2023-09-28 11:55:14 +05:30 committed by GitHub
parent db9596d223
commit 7964364e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 69 deletions

View File

@ -561,9 +561,8 @@ func runExchangeDetailsCmdTest(suite *PreparedBackupExchangeE2ESuite, category p
type BackupDeleteExchangeE2ESuite struct { type BackupDeleteExchangeE2ESuite struct {
tester.Suite tester.Suite
dpnd dependencies dpnd dependencies
backupOp operations.BackupOperation backupOps [3]operations.BackupOperation
secondaryBackupOp operations.BackupOperation
} }
func TestBackupDeleteExchangeE2ESuite(t *testing.T) { func TestBackupDeleteExchangeE2ESuite(t *testing.T) {
@ -589,21 +588,15 @@ func (suite *BackupDeleteExchangeE2ESuite) SetupSuite() {
sel := selectors.NewExchangeBackup(users) sel := selectors.NewExchangeBackup(users)
sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch())) sel.Include(sel.MailFolders([]string{api.MailInbox}, selectors.PrefixMatch()))
backupOp, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector) for i := 0; i < cap(suite.backupOps); i++ {
require.NoError(t, err, clues.ToCore(err)) backupOp, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector)
require.NoError(t, err, clues.ToCore(err))
suite.backupOp = backupOp suite.backupOps[i] = backupOp
err = suite.backupOp.Run(ctx) err = suite.backupOps[i].Run(ctx)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
}
backupOp2, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector)
require.NoError(t, err, clues.ToCore(err))
suite.secondaryBackupOp = backupOp2
err = suite.secondaryBackupOp.Run(ctx)
require.NoError(t, err, clues.ToCore(err))
} }
func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd() { func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd() {
@ -619,8 +612,8 @@ func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd() {
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupIDsFN, "--"+flags.BackupIDsFN,
fmt.Sprintf("%s,%s", fmt.Sprintf("%s,%s",
string(suite.backupOp.Results.BackupID), string(suite.backupOps[0].Results.BackupID),
string(suite.secondaryBackupOp.Results.BackupID))) string(suite.backupOps[1].Results.BackupID)))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
// run the command // run the command
@ -631,7 +624,7 @@ func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd() {
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "exchange", "backup", "details", "exchange",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backup", string(suite.backupOp.Results.BackupID)) "--backup", string(suite.backupOps[0].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)
@ -641,7 +634,7 @@ func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd() {
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "exchange", "backup", "details", "exchange",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backup", string(suite.secondaryBackupOp.Results.BackupID)) "--backup", string(suite.backupOps[1].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)
@ -660,7 +653,7 @@ func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd_SingleID(
"backup", "delete", "exchange", "backup", "delete", "exchange",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupFN, "--"+flags.BackupFN,
string(suite.backupOp.Results.BackupID)) string(suite.backupOps[2].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
// run the command // run the command
@ -671,7 +664,7 @@ func (suite *BackupDeleteExchangeE2ESuite) TestExchangeBackupDeleteCmd_SingleID(
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "exchange", "backup", "details", "exchange",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backup", string(suite.secondaryBackupOp.Results.BackupID)) "--backup", string(suite.backupOps[2].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)

View File

@ -497,9 +497,8 @@ func runGroupsDetailsCmdTest(suite *PreparedBackupGroupsE2ESuite, category path.
type BackupDeleteGroupsE2ESuite struct { type BackupDeleteGroupsE2ESuite struct {
tester.Suite tester.Suite
dpnd dependencies dpnd dependencies
backupOp operations.BackupOperation backupOps [3]operations.BackupOperation
secondaryBackupOp operations.BackupOperation
} }
func TestBackupDeleteGroupsE2ESuite(t *testing.T) { func TestBackupDeleteGroupsE2ESuite(t *testing.T) {
@ -525,22 +524,15 @@ func (suite *BackupDeleteGroupsE2ESuite) SetupSuite() {
sel := selectors.NewGroupsBackup(groups) sel := selectors.NewGroupsBackup(groups)
sel.Include(selTD.GroupsBackupChannelScope(sel)) sel.Include(selTD.GroupsBackupChannelScope(sel))
backupOp, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector) for i := 0; i < cap(suite.backupOps); i++ {
require.NoError(t, err, clues.ToCore(err)) backupOp, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector)
require.NoError(t, err, clues.ToCore(err))
suite.backupOp = backupOp suite.backupOps[i] = backupOp
err = suite.backupOp.Run(ctx) err = suite.backupOps[i].Run(ctx)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
}
// secondary backup
secondaryBackupOp, err := suite.dpnd.repo.NewBackup(ctx, sel.Selector)
require.NoError(t, err, clues.ToCore(err))
suite.secondaryBackupOp = secondaryBackupOp
err = suite.secondaryBackupOp.Run(ctx)
require.NoError(t, err, clues.ToCore(err))
} }
func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd() { func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd() {
@ -556,8 +548,8 @@ func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd() {
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupIDsFN, "--"+flags.BackupIDsFN,
fmt.Sprintf("%s,%s", fmt.Sprintf("%s,%s",
string(suite.backupOp.Results.BackupID), string(suite.backupOps[0].Results.BackupID),
string(suite.secondaryBackupOp.Results.BackupID))) string(suite.backupOps[1].Results.BackupID)))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
// run the command // run the command
@ -568,7 +560,7 @@ func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd() {
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "groups", "backup", "details", "groups",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backups", string(suite.backupOp.Results.BackupID)) "--backups", string(suite.backupOps[0].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)
@ -587,7 +579,7 @@ func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd_SingleID() {
"backup", "delete", "groups", "backup", "delete", "groups",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupFN, "--"+flags.BackupFN,
string(suite.backupOp.Results.BackupID)) string(suite.backupOps[2].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
// run the command // run the command
@ -598,7 +590,7 @@ func (suite *BackupDeleteGroupsE2ESuite) TestGroupsBackupDeleteCmd_SingleID() {
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "groups", "backup", "details", "groups",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backup", string(suite.backupOp.Results.BackupID)) "--backup", string(suite.backupOps[2].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)

View File

@ -121,9 +121,8 @@ func (suite *NoBackupOneDriveE2ESuite) TestOneDriveBackupCmd_userNotInTenant() {
type BackupDeleteOneDriveE2ESuite struct { type BackupDeleteOneDriveE2ESuite struct {
tester.Suite tester.Suite
dpnd dependencies dpnd dependencies
backupOp operations.BackupOperation backupOps [3]operations.BackupOperation
secondaryBackupOp operations.BackupOperation
} }
func TestBackupDeleteOneDriveE2ESuite(t *testing.T) { func TestBackupDeleteOneDriveE2ESuite(t *testing.T) {
@ -152,22 +151,15 @@ func (suite *BackupDeleteOneDriveE2ESuite) SetupSuite() {
sel := selectors.NewOneDriveBackup(users) sel := selectors.NewOneDriveBackup(users)
sel.Include(selTD.OneDriveBackupFolderScope(sel)) sel.Include(selTD.OneDriveBackupFolderScope(sel))
backupOp, err := suite.dpnd.repo.NewBackupWithLookup(ctx, sel.Selector, ins) for i := 0; i < cap(suite.backupOps); i++ {
require.NoError(t, err, clues.ToCore(err)) backupOp, err := suite.dpnd.repo.NewBackupWithLookup(ctx, sel.Selector, ins)
require.NoError(t, err, clues.ToCore(err))
suite.backupOp = backupOp suite.backupOps[i] = backupOp
err = suite.backupOp.Run(ctx) err = suite.backupOps[i].Run(ctx)
require.NoError(t, err, clues.ToCore(err)) require.NoError(t, err, clues.ToCore(err))
}
// secondary backup
secondaryBackupOp, err := suite.dpnd.repo.NewBackupWithLookup(ctx, sel.Selector, ins)
require.NoError(t, err, clues.ToCore(err))
suite.secondaryBackupOp = secondaryBackupOp
err = suite.secondaryBackupOp.Run(ctx)
require.NoError(t, err, clues.ToCore(err))
} }
func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd() { func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd() {
@ -185,8 +177,8 @@ func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd() {
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupIDsFN, "--"+flags.BackupIDsFN,
fmt.Sprintf("%s,%s", fmt.Sprintf("%s,%s",
string(suite.backupOp.Results.BackupID), string(suite.backupOps[0].Results.BackupID),
string(suite.secondaryBackupOp.Results.BackupID))) string(suite.backupOps[1].Results.BackupID)))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
cmd.SetErr(&suite.dpnd.recorder) cmd.SetErr(&suite.dpnd.recorder)
@ -201,14 +193,14 @@ func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd() {
strings.HasSuffix( strings.HasSuffix(
result, result,
fmt.Sprintf("Deleted OneDrive backup [%s %s]\n", fmt.Sprintf("Deleted OneDrive backup [%s %s]\n",
string(suite.backupOp.Results.BackupID), string(suite.backupOps[0].Results.BackupID),
string(suite.secondaryBackupOp.Results.BackupID)))) string(suite.backupOps[1].Results.BackupID))))
// a follow-up details call should fail, due to the backup ID being deleted // a follow-up details call should fail, due to the backup ID being deleted
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "onedrive", "backup", "details", "onedrive",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backups", string(suite.backupOp.Results.BackupID)) "--backups", string(suite.backupOps[0].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)
@ -229,7 +221,7 @@ func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd_SingleID(
"backup", "delete", "onedrive", "backup", "delete", "onedrive",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--"+flags.BackupFN, "--"+flags.BackupFN,
string(suite.backupOp.Results.BackupID)) string(suite.backupOps[2].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
cmd.SetErr(&suite.dpnd.recorder) cmd.SetErr(&suite.dpnd.recorder)
@ -244,13 +236,13 @@ func (suite *BackupDeleteOneDriveE2ESuite) TestOneDriveBackupDeleteCmd_SingleID(
strings.HasSuffix( strings.HasSuffix(
result, result,
fmt.Sprintf("Deleted OneDrive backup [%s]\n", fmt.Sprintf("Deleted OneDrive backup [%s]\n",
string(suite.backupOp.Results.BackupID)))) string(suite.backupOps[2].Results.BackupID))))
// a follow-up details call should fail, due to the backup ID being deleted // a follow-up details call should fail, due to the backup ID being deleted
cmd = cliTD.StubRootCmd( cmd = cliTD.StubRootCmd(
"backup", "details", "onedrive", "backup", "details", "onedrive",
"--config-file", suite.dpnd.configFilePath, "--config-file", suite.dpnd.configFilePath,
"--backup", string(suite.backupOp.Results.BackupID)) "--backup", string(suite.backupOps[0].Results.BackupID))
cli.BuildCommandTree(cmd) cli.BuildCommandTree(cmd)
err = cmd.ExecuteContext(ctx) err = cmd.ExecuteContext(ctx)