X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8e1a832244c109351a20a7181da0f65c73e63987..7a6612d56b719165d3aff84754521c9a38d9912a:/services/datamanager/summary/summary_test.go diff --git a/services/datamanager/summary/summary_test.go b/services/datamanager/summary/summary_test.go index 05db2fd7fe..cc4eb92560 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 } @@ -36,12 +36,19 @@ func (cis CollectionIndexSet) ToSlice() (ints []int) { return } +// Helper method to meet interface expected by older tests. +func SummarizeReplication(readCollections collection.ReadCollections, + keepServerInfo keep.ReadServers) (rs ReplicationSummary) { + return BucketReplication(readCollections, keepServerInfo). + SummarizeBuckets(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 @@ -59,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) @@ -94,7 +101,7 @@ func TestSimpleSummary(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{1, 2}}, }) - rc.Summarize() + rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() keepInfo := SpecifyReplication(map[int]int{1: 1, 2: 1}) @@ -123,7 +130,7 @@ func TestMissingBlock(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{1, 2}}, }) - rc.Summarize() + rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() keepInfo := SpecifyReplication(map[int]int{1: 1}) @@ -154,7 +161,7 @@ func TestUnderAndOverReplicatedBlocks(t *testing.T) { rc := collection.MakeTestReadCollections([]collection.TestCollectionSpec{ collection.TestCollectionSpec{ReplicationLevel: 2, Blocks: []int{1, 2}}, }) - rc.Summarize() + rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() keepInfo := SpecifyReplication(map[int]int{1: 1, 2: 3}) @@ -187,7 +194,7 @@ func TestMixedReplication(t *testing.T) { collection.TestCollectionSpec{ReplicationLevel: 1, Blocks: []int{3, 4}}, collection.TestCollectionSpec{ReplicationLevel: 2, Blocks: []int{5, 6}}, }) - rc.Summarize() + rc.Summarize(nil) cIndex := rc.CollectionIndicesForTesting() keepInfo := SpecifyReplication(map[int]int{1: 1, 2: 1, 3: 1, 5: 1, 6: 3, 7: 2}) @@ -208,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) } }