11644: Test non-empty MountUUID in trash list.
authorTom Clegg <tom@curoverse.com>
Tue, 16 May 2017 17:03:14 +0000 (13:03 -0400)
committerTom Clegg <tom@curoverse.com>
Tue, 16 May 2017 17:03:14 +0000 (13:03 -0400)
services/keepstore/trash_worker_test.go

index 04b034a97976980c5ce66d59c361b44936dabbca..61989cb359e5d20f2dcd1954c804160f121ada2b 100644 (file)
@@ -22,7 +22,8 @@ type TrashWorkerTestData struct {
        UseTrashLifeTime bool
        DifferentMtimes  bool
 
-       DeleteLocator string
+       DeleteLocator    string
+       SpecifyMountUUID bool
 
        ExpectLocator1 bool
        ExpectLocator2 bool
@@ -139,6 +140,29 @@ func TestTrashWorkerIntegration_MtimeMatchesForLocator1ButNotForLocator2(t *test
        performTrashWorkerTest(testData, t)
 }
 
+// Delete a block that exists on both volumes with matching mtimes,
+// but specify a MountUUID in the request so it only gets deleted from
+// the first volume.
+func TestTrashWorkerIntegration_SpecifyMountUUID(t *testing.T) {
+       theConfig.EnableDelete = true
+       testData := TrashWorkerTestData{
+               Locator1: TestHash,
+               Block1:   TestBlock,
+
+               Locator2: TestHash,
+               Block2:   TestBlock,
+
+               CreateData: true,
+
+               DeleteLocator:    TestHash,
+               SpecifyMountUUID: true,
+
+               ExpectLocator1: true,
+               ExpectLocator2: true,
+       }
+       performTrashWorkerTest(testData, t)
+}
+
 /* Two different locators in volume 1.
    Delete one of them.
    Expect the other unaffected.
@@ -239,6 +263,9 @@ func performTrashWorkerTest(testData TrashWorkerTestData, t *testing.T) {
                Locator:    testData.DeleteLocator,
                BlockMtime: oldBlockTime.UnixNano(),
        }
+       if testData.SpecifyMountUUID {
+               trashRequest.MountUUID = KeepVM.Mounts()[0].UUID
+       }
 
        // Run trash worker and put the trashRequest on trashq
        trashList := list.New()