Enhance unit tests for corruped segment filters

This commit is contained in:
martinsumner 2016-10-24 11:44:28 +01:00
parent c78b5bca7d
commit d988c66ac6
2 changed files with 53 additions and 1 deletions

View file

@ -186,6 +186,15 @@ book_riakput(Pid, RiakObject, IndexSpecs) ->
book_put(Pid, Bucket, Key, Object, IndexSpecs) -> book_put(Pid, Bucket, Key, Object, IndexSpecs) ->
book_put(Pid, Bucket, Key, Object, IndexSpecs, ?STD_TAG). book_put(Pid, Bucket, Key, Object, IndexSpecs, ?STD_TAG).
%% TODO:
%% It is not enough simply to change the value to delete, as the journal
%% needs to know the key is a tombstone at compaction time, and currently at
%% compaction time the clerk only knows the Key and not the Value.
%%
%% The tombstone cannot be removed from the Journal on compaction, as the
%% journal entry the tombstone deletes may not have been reaped - and so if the
%% ledger got erased, the value would be resurrected.
book_riakdelete(Pid, Bucket, Key, IndexSpecs) -> book_riakdelete(Pid, Bucket, Key, IndexSpecs) ->
book_put(Pid, Bucket, Key, delete, IndexSpecs, ?RIAK_TAG). book_put(Pid, Bucket, Key, delete, IndexSpecs, ?RIAK_TAG).

View file

@ -1615,7 +1615,50 @@ merge_seglists_test() ->
check_for_segments(SegBin2, [1024*1024 - 1], true)), check_for_segments(SegBin2, [1024*1024 - 1], true)),
% This match is before the flipped bit, so still works without CRC check % This match is before the flipped bit, so still works without CRC check
?assertMatch({maybe_present, [0]}, ?assertMatch({maybe_present, [0]},
check_for_segments(SegBin2, [0,900], false)). check_for_segments(SegBin2, [0,900], false)),
ExpectedDeltasAll1s = <<4294967295:32/integer>>,
SegBin3 = <<ExpectedTopHashes/bitstring, ExpectedDeltasAll1s/bitstring>>,
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [900], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [200], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [0,900], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [1024*1024 - 1], true)),
% This is so badly mangled, the error gets detected event without CRC
% checking being enforced
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [900], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [200], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [0,900], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin3, [1024*1024 - 1], false)),
ExpectedDeltasNearlyAll1s = <<4294967287:32/integer>>,
SegBin4 = <<ExpectedTopHashes/bitstring,
ExpectedDeltasNearlyAll1s/bitstring>>,
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [900], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [200], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [0,900], true)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [1024*1024 - 1], true)),
% This is so badly mangled, the error gets detected event without CRC
% checking being enforced
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [900], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [200], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [0,900], false)),
?assertMatch(error_so_maybe_present,
check_for_segments(SegBin4, [1024*1024 - 1], false)).
createslot_stage1_test() -> createslot_stage1_test() ->
{KeyList1, KeyList2} = sample_keylist(), {KeyList1, KeyList2} = sample_keylist(),