Merge branch '15648-centos7-upgrade-to-rh-python36'
[arvados.git] / services / keepstore / trash_worker_test.go
index 04b034a97976980c5ce66d59c361b44936dabbca..c5a410b06f05c151bb401c31f9377316c573678a 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 package main
 
 import (
@@ -22,7 +26,8 @@ type TrashWorkerTestData struct {
        UseTrashLifeTime bool
        DifferentMtimes  bool
 
-       DeleteLocator string
+       DeleteLocator    string
+       SpecifyMountUUID bool
 
        ExpectLocator1 bool
        ExpectLocator2 bool
@@ -139,6 +144,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 +267,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()