X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6eb3d1fb8fe71623fa63da46c250184cf2e4fbb8..f9e3d32c92920a806d50548dbb9b6c0aab7d8c54:/services/datamanager/summary/summary_test.go diff --git a/services/datamanager/summary/summary_test.go b/services/datamanager/summary/summary_test.go index 04ca5a5c59..8268404127 100644 --- a/services/datamanager/summary/summary_test.go +++ b/services/datamanager/summary/summary_test.go @@ -12,7 +12,7 @@ import ( func BlockSetFromSlice(digests []int) (bs BlockSet) { bs = make(BlockSet) for _, digest := range digests { - bs.Insert(blockdigest.MakeTestBlockDigest(digest)) + bs.Insert(blockdigest.MakeTestDigestWithSize(digest)) } return } @@ -46,9 +46,9 @@ func SummarizeReplication(readCollections collection.ReadCollections, // Takes a map from block digest to replication level and represents // it in a keep.ReadServers structure. func SpecifyReplication(digestToReplication map[int]int) (rs keep.ReadServers) { - rs.BlockToServers = make(map[blockdigest.BlockDigest][]keep.BlockServerInfo) + rs.BlockToServers = make(map[blockdigest.DigestWithSize][]keep.BlockServerInfo) for digest, replication := range digestToReplication { - rs.BlockToServers[blockdigest.MakeTestBlockDigest(digest)] = + rs.BlockToServers[blockdigest.MakeTestDigestWithSize(digest)] = make([]keep.BlockServerInfo, replication) } return @@ -66,10 +66,10 @@ func VerifyToCollectionIndexSet( expected := CollectionIndexSetFromSlice(expectedCollections) rc := collection.ReadCollections{ - BlockToCollectionIndices: map[blockdigest.BlockDigest][]int{}, + BlockToCollectionIndices: map[blockdigest.DigestWithSize][]int{}, } for digest, indices := range blockToCollectionIndices { - rc.BlockToCollectionIndices[blockdigest.MakeTestBlockDigest(digest)] = indices + rc.BlockToCollectionIndices[blockdigest.MakeTestDigestWithSize(digest)] = indices } returned := make(CollectionIndexSet) @@ -85,21 +85,21 @@ func VerifyToCollectionIndexSet( } func TestToCollectionIndexSet(t *testing.T) { - VerifyToCollectionIndexSet(t, []int{6}, map[int][]int{6: []int{0}}, []int{0}) - VerifyToCollectionIndexSet(t, []int{4}, map[int][]int{4: []int{1}}, []int{1}) - VerifyToCollectionIndexSet(t, []int{4}, map[int][]int{4: []int{1, 9}}, []int{1, 9}) + VerifyToCollectionIndexSet(t, []int{6}, map[int][]int{6: {0}}, []int{0}) + VerifyToCollectionIndexSet(t, []int{4}, map[int][]int{4: {1}}, []int{1}) + VerifyToCollectionIndexSet(t, []int{4}, map[int][]int{4: {1, 9}}, []int{1, 9}) VerifyToCollectionIndexSet(t, []int{5, 6}, - map[int][]int{5: []int{2, 3}, 6: []int{3, 4}}, + map[int][]int{5: {2, 3}, 6: {3, 4}}, []int{2, 3, 4}) VerifyToCollectionIndexSet(t, []int{5, 6}, - map[int][]int{5: []int{8}, 6: []int{4}}, + map[int][]int{5: {8}, 6: {4}}, []int{4, 8}) - VerifyToCollectionIndexSet(t, []int{6}, map[int][]int{5: []int{0}}, []int{}) + VerifyToCollectionIndexSet(t, []int{6}, map[int][]int{5: {0}}, []int{}) } func TestSimpleSummary(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ - collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{1, 2}}, + {ReplicationLevel: 1, Blocks: []int{1, 2}}, }) rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() @@ -128,7 +128,7 @@ func TestSimpleSummary(t *testing.T) { func TestMissingBlock(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ - collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{1, 2}}, + {ReplicationLevel: 1, Blocks: []int{1, 2}}, }) rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() @@ -159,7 +159,7 @@ func TestMissingBlock(t *testing.T) { func TestUnderAndOverReplicatedBlocks(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ - collection.TestCollectionSpec{ReplicationLevel: 2, Blocks: []int{1, 2}}, + {ReplicationLevel: 2, Blocks: []int{1, 2}}, }) rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() @@ -190,9 +190,9 @@ func TestUnderAndOverReplicatedBlocks(t *testing.T) { func TestMixedReplication(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ - collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{1, 2}}, - collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{3, 4}}, - collection.TestCollectionSpec{ReplicationLevel: 2, Blocks: []int{5, 6}}, + {ReplicationLevel: 1, Blocks: []int{1, 2}}, + {ReplicationLevel: 1, Blocks: []int{3, 4}}, + {ReplicationLevel: 2, Blocks: []int{5, 6}}, }) rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() @@ -215,6 +215,6 @@ func TestMixedReplication(t *testing.T) { returnedSummary := SummarizeReplication(rc, keepInfo) if !reflect.DeepEqual(returnedSummary, expectedSummary) { - t.Fatalf("Expected returnedSummary to look like: \n%+v but instead it is: \n%+v. Index to UUID is %v. BlockToCollectionIndices is %v.", expectedSummary, returnedSummary, rc.CollectionIndexToUuid, rc.BlockToCollectionIndices) + t.Fatalf("Expected returnedSummary to look like: \n%+v but instead it is: \n%+v. Index to UUID is %v. BlockToCollectionIndices is %v.", expectedSummary, returnedSummary, rc.CollectionIndexToUUID, rc.BlockToCollectionIndices) } }