- // Put some blocks which will be backdated later on
- collectionWithOldBlocks := createMultiStreamBlockCollection(t, "to be deleted collection with old blocks", 5, 5)
- oldBlocks := geLocatorsFromCollection(t, collectionWithOldBlocks)
-
- collectionWithNewerBlocks := createMultiStreamBlockCollection(t, "to be deleted collection with newer and older blocks", 5, 5)
- newerBlocks := geLocatorsFromCollection(t, collectionWithNewerBlocks)
-
- expected := []string{}
- expected = append(expected, oldBlocks...)
- expected = append(expected, newerBlocks...)
- verifyBlocks(t, nil, expected, 2)
-
- // Backdate old blocks and delete the collection
- backdateBlocks(t, oldBlocks)
- deleteCollection(t, collectionWithOldBlocks)
-
- // Backdate first block from the newer blocks and delete the collection; the rest are still be reachable
- backdateBlocks(t, newerBlocks[0:1])
- deleteCollection(t, collectionWithNewerBlocks)
-
- // run datamanager
- dataManagerSingleRun(t)
-
- notExpected := []string{}
- notExpected = append(notExpected, oldBlocks...)
- notExpected = append(notExpected, newerBlocks[0])
-
- verifyBlocks(t, notExpected, newerBlocks[1:], 2)
-}
-
-/*
- Create a collection with multiple blocks in one stream using arv-put
- Generated manifest will be for the format:
- . 83d2e2d0938718a56c9b0c518a4b2930+41+A4b671b8c7525c0af302365b03a44406999e42eec@565f7809 0:41:temp-test-file053866981
- . cb790454ba6cc9a3ffab377937e06225+41+Ab5460755c3480fb899025b74dc59fadb71402bfc@565f7809 0:41:temp-test-file213181952
-*/
-func createMultiBlockCollection(t *testing.T, data string, numBlocks int) string {
- tempdir, err := ioutil.TempDir(os.TempDir(), "temp-test-dir")
- defer os.Remove(tempdir)
-
- filenames := []string{}
- for i := 0; i < numBlocks; i++ {
- tempfile, err := ioutil.TempFile(tempdir, "temp-test-file")
- defer os.Remove(tempfile.Name())
-
- _, err = tempfile.Write([]byte(fmt.Sprintf("%s%d", data, i)))
- if err != nil {
- t.Fatalf("Error writing to tempfile %v", err)
- }
-
- filenames = append(filenames, tempfile.Name())