Add more subtests to aid in debugging (#3667)
Pass around context more and add more subtests so that the logs actually show what's happening. --- #### 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 - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) * closes #3666 #### Test Plan - [x] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
3ba9daccdf
commit
9cbd46aabe
@ -964,7 +964,8 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
// performs the incremental update required for the test.
|
// performs the incremental update required for the test.
|
||||||
updateUserData func(t *testing.T)
|
//revive:disable-next-line:context-as-argument
|
||||||
|
updateUserData func(t *testing.T, ctx context.Context)
|
||||||
deltaItemsRead int
|
deltaItemsRead int
|
||||||
deltaItemsWritten int
|
deltaItemsWritten int
|
||||||
nonDeltaItemsRead int
|
nonDeltaItemsRead int
|
||||||
@ -973,7 +974,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "clean, no changes",
|
name: "clean, no changes",
|
||||||
updateUserData: func(t *testing.T) {},
|
updateUserData: func(t *testing.T, ctx context.Context) {},
|
||||||
deltaItemsRead: 0,
|
deltaItemsRead: 0,
|
||||||
deltaItemsWritten: 0,
|
deltaItemsWritten: 0,
|
||||||
nonDeltaItemsRead: 8,
|
nonDeltaItemsRead: 8,
|
||||||
@ -982,7 +983,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "move an email folder to a subfolder",
|
name: "move an email folder to a subfolder",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
cat := path.EmailCategory
|
cat := path.EmailCategory
|
||||||
|
|
||||||
// contacts and events cannot be sufoldered; this is an email-only change
|
// contacts and events cannot be sufoldered; this is an email-only change
|
||||||
@ -1006,7 +1007,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "delete a folder",
|
name: "delete a folder",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
for category, d := range dataset {
|
for category, d := range dataset {
|
||||||
containerID := d.dests[container2].containerID
|
containerID := d.dests[container2].containerID
|
||||||
|
|
||||||
@ -1033,7 +1034,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a new folder",
|
name: "add a new folder",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
for category, gen := range dataset {
|
for category, gen := range dataset {
|
||||||
deets := generateContainerOfItems(
|
deets := generateContainerOfItems(
|
||||||
t,
|
t,
|
||||||
@ -1078,7 +1079,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "rename a folder",
|
name: "rename a folder",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
for category, d := range dataset {
|
for category, d := range dataset {
|
||||||
containerID := d.dests[container3].containerID
|
containerID := d.dests[container3].containerID
|
||||||
newLoc := containerRename
|
newLoc := containerRename
|
||||||
@ -1134,7 +1135,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a new item",
|
name: "add a new item",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
for category, d := range dataset {
|
for category, d := range dataset {
|
||||||
containerID := d.dests[container1].containerID
|
containerID := d.dests[container1].containerID
|
||||||
|
|
||||||
@ -1188,7 +1189,7 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "delete an existing item",
|
name: "delete an existing item",
|
||||||
updateUserData: func(t *testing.T) {
|
updateUserData: func(t *testing.T, ctx context.Context) {
|
||||||
for category, d := range dataset {
|
for category, d := range dataset {
|
||||||
containerID := d.dests[container1].containerID
|
containerID := d.dests[container1].containerID
|
||||||
|
|
||||||
@ -1247,11 +1248,22 @@ func testExchangeContinuousBackups(suite *BackupOpIntegrationSuite, toggles cont
|
|||||||
var (
|
var (
|
||||||
t = suite.T()
|
t = suite.T()
|
||||||
incMB = evmock.NewBus()
|
incMB = evmock.NewBus()
|
||||||
incBO = newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sels, incMB, toggles, closer)
|
|
||||||
atid = creds.AzureTenantID
|
atid = creds.AzureTenantID
|
||||||
)
|
)
|
||||||
|
|
||||||
test.updateUserData(t)
|
ctx, flush := tester.WithContext(t, ctx)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
incBO := newTestBackupOp(t, ctx, kw, ms, ctrl, acct, sels, incMB, toggles, closer)
|
||||||
|
|
||||||
|
suite.Run("PreTestSetup", func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.WithContext(t, ctx)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
test.updateUserData(t, ctx)
|
||||||
|
})
|
||||||
|
|
||||||
err := incBO.Run(ctx)
|
err := incBO.Run(ctx)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
@ -1550,20 +1562,21 @@ func runDriveIncrementalTest(
|
|||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
// performs the incremental update required for the test.
|
// performs the incremental update required for the test.
|
||||||
updateFiles func(t *testing.T)
|
//revive:disable-next-line:context-as-argument
|
||||||
|
updateFiles func(t *testing.T, ctx context.Context)
|
||||||
itemsRead int
|
itemsRead int
|
||||||
itemsWritten int
|
itemsWritten int
|
||||||
nonMetaItemsWritten int
|
nonMetaItemsWritten int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "clean incremental, no changes",
|
name: "clean incremental, no changes",
|
||||||
updateFiles: func(t *testing.T) {},
|
updateFiles: func(t *testing.T, ctx context.Context) {},
|
||||||
itemsRead: 0,
|
itemsRead: 0,
|
||||||
itemsWritten: 0,
|
itemsWritten: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "create a new file",
|
name: "create a new file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
targetContainer := containerIDs[container1]
|
targetContainer := containerIDs[container1]
|
||||||
driveItem := models.NewDriveItem()
|
driveItem := models.NewDriveItem()
|
||||||
driveItem.SetName(&newFileName)
|
driveItem.SetName(&newFileName)
|
||||||
@ -1586,7 +1599,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add permission to new file",
|
name: "add permission to new file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
err = onedrive.UpdatePermissions(
|
err = onedrive.UpdatePermissions(
|
||||||
ctx,
|
ctx,
|
||||||
rh,
|
rh,
|
||||||
@ -1604,7 +1617,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove permission from new file",
|
name: "remove permission from new file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
err = onedrive.UpdatePermissions(
|
err = onedrive.UpdatePermissions(
|
||||||
ctx,
|
ctx,
|
||||||
rh,
|
rh,
|
||||||
@ -1622,7 +1635,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add permission to container",
|
name: "add permission to container",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
targetContainer := containerIDs[container1]
|
targetContainer := containerIDs[container1]
|
||||||
err = onedrive.UpdatePermissions(
|
err = onedrive.UpdatePermissions(
|
||||||
ctx,
|
ctx,
|
||||||
@ -1641,7 +1654,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove permission from container",
|
name: "remove permission from container",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
targetContainer := containerIDs[container1]
|
targetContainer := containerIDs[container1]
|
||||||
err = onedrive.UpdatePermissions(
|
err = onedrive.UpdatePermissions(
|
||||||
ctx,
|
ctx,
|
||||||
@ -1660,7 +1673,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "update contents of a file",
|
name: "update contents of a file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
err := suite.ac.Drives().PutItemContent(
|
err := suite.ac.Drives().PutItemContent(
|
||||||
ctx,
|
ctx,
|
||||||
driveID,
|
driveID,
|
||||||
@ -1675,7 +1688,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "rename a file",
|
name: "rename a file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
container := containerIDs[container1]
|
container := containerIDs[container1]
|
||||||
|
|
||||||
driveItem := models.NewDriveItem()
|
driveItem := models.NewDriveItem()
|
||||||
@ -1699,7 +1712,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "move a file between folders",
|
name: "move a file between folders",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
dest := containerIDs[container2]
|
dest := containerIDs[container2]
|
||||||
|
|
||||||
driveItem := models.NewDriveItem()
|
driveItem := models.NewDriveItem()
|
||||||
@ -1727,7 +1740,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "delete file",
|
name: "delete file",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
err := suite.ac.Drives().DeleteItem(
|
err := suite.ac.Drives().DeleteItem(
|
||||||
ctx,
|
ctx,
|
||||||
driveID,
|
driveID,
|
||||||
@ -1742,7 +1755,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "move a folder to a subfolder",
|
name: "move a folder to a subfolder",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
parent := containerIDs[container1]
|
parent := containerIDs[container1]
|
||||||
child := containerIDs[container2]
|
child := containerIDs[container2]
|
||||||
|
|
||||||
@ -1770,7 +1783,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "rename a folder",
|
name: "rename a folder",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
parent := containerIDs[container1]
|
parent := containerIDs[container1]
|
||||||
child := containerIDs[container2]
|
child := containerIDs[container2]
|
||||||
|
|
||||||
@ -1800,7 +1813,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "delete a folder",
|
name: "delete a folder",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
container := containerIDs[containerRename]
|
container := containerIDs[containerRename]
|
||||||
err := suite.ac.Drives().DeleteItem(
|
err := suite.ac.Drives().DeleteItem(
|
||||||
ctx,
|
ctx,
|
||||||
@ -1816,7 +1829,7 @@ func runDriveIncrementalTest(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a new folder",
|
name: "add a new folder",
|
||||||
updateFiles: func(t *testing.T) {
|
updateFiles: func(t *testing.T, ctx context.Context) {
|
||||||
generateContainerOfItems(
|
generateContainerOfItems(
|
||||||
t,
|
t,
|
||||||
ctx,
|
ctx,
|
||||||
@ -1858,9 +1871,17 @@ func runDriveIncrementalTest(
|
|||||||
incBO = newTestBackupOp(t, ctx, kw, ms, cleanCtrl, acct, sel, incMB, ffs, closer)
|
incBO = newTestBackupOp(t, ctx, kw, ms, cleanCtrl, acct, sel, incMB, ffs, closer)
|
||||||
)
|
)
|
||||||
|
|
||||||
tester.LogTimeOfTest(suite.T())
|
ctx, flush := tester.WithContext(t, ctx)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
test.updateFiles(t)
|
suite.Run("PreTestSetup", func() {
|
||||||
|
t := suite.T()
|
||||||
|
|
||||||
|
ctx, flush := tester.WithContext(t, ctx)
|
||||||
|
defer flush()
|
||||||
|
|
||||||
|
test.updateFiles(t, ctx)
|
||||||
|
})
|
||||||
|
|
||||||
err = incBO.Run(ctx)
|
err = incBO.Run(ctx)
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user