Skip to content

Commit

Permalink
fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Artoul committed Aug 8, 2019
1 parent 4a82857 commit 9de2fb0
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/dbnode/storage/repair/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func TestReplicaMetadataComparerCompare(t *testing.T) {
Host: hosts[1],
Metadata: block.NewMetadata(ident.StringID("bar"), ident.Tags{}, now.Add(time.Second), int64(1), &ten, time.Time{}),
},
// hosts[0] has a checksum but hosts[1] doesn't so this block will not be repaired (skipped until the next attempt) at
// which points hosts[1] will have merged the blocks and an accurate comparison can be made.
block.ReplicaMetadata{
Host: hosts[0],
Metadata: block.NewMetadata(ident.StringID("baz"), ident.Tags{}, now.Add(2*time.Second), int64(2), &twenty, time.Time{}),
Expand All @@ -260,6 +262,15 @@ func TestReplicaMetadataComparerCompare(t *testing.T) {
Host: hosts[1],
Metadata: block.NewMetadata(ident.StringID("baz"), ident.Tags{}, now.Add(2*time.Second), int64(2), nil, time.Time{}),
},
// hosts[0] and hosts[1] both have a checksum, but they differ, so this should trigger a checksum mismatch.
block.ReplicaMetadata{
Host: hosts[0],
Metadata: block.NewMetadata(ident.StringID("boz"), ident.Tags{}, now.Add(2*time.Second), int64(2), &twenty, time.Time{}),
},
block.ReplicaMetadata{
Host: hosts[1],
Metadata: block.NewMetadata(ident.StringID("boz"), ident.Tags{}, now.Add(2*time.Second), int64(2), &ten, time.Time{}),
},
// Block only exists for host[1] but host[0] is the origin so should be consider a size/checksum mismatch.
block.ReplicaMetadata{
Host: hosts[1],
Expand All @@ -282,26 +293,26 @@ func TestReplicaMetadataComparerCompare(t *testing.T) {
inputs[3],
}},
{ident.StringID("gah"), now.Add(3 * time.Second), []block.ReplicaMetadata{
inputs[6],
inputs[8],
}},
}

checksumExpected := []testBlock{
{ident.StringID("baz"), now.Add(2 * time.Second), []block.ReplicaMetadata{
inputs[4],
inputs[5],
{ident.StringID("boz"), now.Add(2 * time.Second), []block.ReplicaMetadata{
inputs[6],
inputs[7],
}},
{ident.StringID("gah"), now.Add(3 * time.Second), []block.ReplicaMetadata{
inputs[6],
inputs[8],
}},
}

m := NewReplicaMetadataComparer(hosts[0], testRepairOptions()).(replicaMetadataComparer)
m.metadata = metadata

res := m.Compare()
require.Equal(t, int64(5), res.NumSeries)
require.Equal(t, int64(5), res.NumBlocks)
require.Equal(t, int64(6), res.NumSeries)
require.Equal(t, int64(6), res.NumBlocks)
assertEqual(t, sizeExpected, res.SizeDifferences)
assertEqual(t, checksumExpected, res.ChecksumDifferences)
}

0 comments on commit 9de2fb0

Please sign in to comment.