Test improvements
Improve the speed of leveled_cdb tests by disabling sync on write. Improve the strength of check of the correct behaviour when compacting with a reduced journal size.
This commit is contained in:
parent
e3913a6c07
commit
0966ce9929
2 changed files with 25 additions and 19 deletions
|
@ -63,7 +63,6 @@
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
-ifdef(slow_test).
|
-ifdef(slow_test).
|
||||||
-define(KEYCOUNT, 2048).
|
|
||||||
-define(SPECIAL_DELFUN, fun(_F) -> ok end).
|
-define(SPECIAL_DELFUN, fun(_F) -> ok end).
|
||||||
% There are problems with the pendingdelete_test/0 in riak make test
|
% There are problems with the pendingdelete_test/0 in riak make test
|
||||||
% The deletion of the file causes the process to crash and the test to
|
% The deletion of the file causes the process to crash and the test to
|
||||||
|
@ -71,7 +70,6 @@
|
||||||
% Workaround this problem by not performing the delete when running unit
|
% Workaround this problem by not performing the delete when running unit
|
||||||
% tests in R16
|
% tests in R16
|
||||||
-else.
|
-else.
|
||||||
-define(KEYCOUNT, 16384).
|
|
||||||
-define(SPECIAL_DELFUN, fun(F) -> file:delete(F) end).
|
-define(SPECIAL_DELFUN, fun(F) -> file:delete(F) end).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
|
@ -2341,18 +2339,19 @@ get_keys_byposition_simple_test() ->
|
||||||
ok = file:delete(F2).
|
ok = file:delete(F2).
|
||||||
|
|
||||||
generate_sequentialkeys(0, KVList) ->
|
generate_sequentialkeys(0, KVList) ->
|
||||||
lists:reverse(KVList);
|
KVList;
|
||||||
generate_sequentialkeys(Count, KVList) ->
|
generate_sequentialkeys(Count, KVList) ->
|
||||||
KV = {"Key" ++ integer_to_list(Count), "Value" ++ integer_to_list(Count)},
|
KV = {"Key" ++ integer_to_list(Count), "Value" ++ integer_to_list(Count)},
|
||||||
generate_sequentialkeys(Count - 1, KVList ++ [KV]).
|
generate_sequentialkeys(Count - 1, [KV|KVList]).
|
||||||
|
|
||||||
get_keys_byposition_manykeys_test_() ->
|
get_keys_byposition_manykeys_test_() ->
|
||||||
{timeout, 600, fun get_keys_byposition_manykeys_test_to/0}.
|
{timeout, 600, fun get_keys_byposition_manykeys_test_to/0}.
|
||||||
|
|
||||||
get_keys_byposition_manykeys_test_to() ->
|
get_keys_byposition_manykeys_test_to() ->
|
||||||
KeyCount = ?KEYCOUNT,
|
KeyCount = 16384,
|
||||||
{ok, P1} = cdb_open_writer("test/test_area/poskeymany.pnd",
|
{ok, P1} = cdb_open_writer("test/test_area/poskeymany.pnd",
|
||||||
#cdb_options{binary_mode=false}),
|
#cdb_options{binary_mode=false,
|
||||||
|
sync_strategy=none}),
|
||||||
KVList = generate_sequentialkeys(KeyCount, []),
|
KVList = generate_sequentialkeys(KeyCount, []),
|
||||||
lists:foreach(fun({K, V}) -> cdb_put(P1, K, V) end, KVList),
|
lists:foreach(fun({K, V}) -> cdb_put(P1, K, V) end, KVList),
|
||||||
ok = cdb_roll(P1),
|
ok = cdb_roll(P1),
|
||||||
|
|
|
@ -603,6 +603,7 @@ busted_journal_test(MaxJournalSize, PressMethod, PressPoint, Bust) ->
|
||||||
|
|
||||||
allkeydelta_journal_multicompact(_Config) ->
|
allkeydelta_journal_multicompact(_Config) ->
|
||||||
RootPath = testutil:reset_filestructure(),
|
RootPath = testutil:reset_filestructure(),
|
||||||
|
CompPath = filename:join(RootPath, "journal/journal_files/post_compact"),
|
||||||
B = <<"test_bucket">>,
|
B = <<"test_bucket">>,
|
||||||
StartOptsFun =
|
StartOptsFun =
|
||||||
fun(JOC) ->
|
fun(JOC) ->
|
||||||
|
@ -621,14 +622,10 @@ allkeydelta_journal_multicompact(_Config) ->
|
||||||
false),
|
false),
|
||||||
compact_and_wait(Bookie1, 0),
|
compact_and_wait(Bookie1, 0),
|
||||||
compact_and_wait(Bookie1, 0),
|
compact_and_wait(Bookie1, 0),
|
||||||
{ok, FileList1} =
|
{ok, FileList1} = file:list_dir(CompPath),
|
||||||
file:list_dir(
|
|
||||||
filename:join(RootPath, "journal/journal_files/post_compact")),
|
|
||||||
io:format("Number of files after compaction ~w~n", [length(FileList1)]),
|
io:format("Number of files after compaction ~w~n", [length(FileList1)]),
|
||||||
compact_and_wait(Bookie1, 0),
|
compact_and_wait(Bookie1, 0),
|
||||||
{ok, FileList2} =
|
{ok, FileList2} = file:list_dir(CompPath),
|
||||||
file:list_dir(
|
|
||||||
filename:join(RootPath, "journal/journal_files/post_compact")),
|
|
||||||
io:format("Number of files after compaction ~w~n", [length(FileList2)]),
|
io:format("Number of files after compaction ~w~n", [length(FileList2)]),
|
||||||
true = FileList1 == FileList2,
|
true = FileList1 == FileList2,
|
||||||
|
|
||||||
|
@ -652,9 +649,7 @@ allkeydelta_journal_multicompact(_Config) ->
|
||||||
KSpcL2,
|
KSpcL2,
|
||||||
false),
|
false),
|
||||||
compact_and_wait(Bookie2, 0),
|
compact_and_wait(Bookie2, 0),
|
||||||
{ok, FileList3} =
|
{ok, FileList3} = file:list_dir(CompPath),
|
||||||
file:list_dir(
|
|
||||||
filename:join(RootPath, "journal/journal_files/post_compact")),
|
|
||||||
io:format("Number of files after compaction ~w~n", [length(FileList3)]),
|
io:format("Number of files after compaction ~w~n", [length(FileList3)]),
|
||||||
|
|
||||||
ok = leveled_bookie:book_close(Bookie2),
|
ok = leveled_bookie:book_close(Bookie2),
|
||||||
|
@ -673,13 +668,25 @@ allkeydelta_journal_multicompact(_Config) ->
|
||||||
B,
|
B,
|
||||||
KSpcL1 ++ KSpcL2 ++ KSpcL3 ++ KSpcL4,
|
KSpcL1 ++ KSpcL2 ++ KSpcL3 ++ KSpcL4,
|
||||||
V4),
|
V4),
|
||||||
{ok, FileList4} =
|
{ok, FileList4} = file:list_dir(CompPath),
|
||||||
file:list_dir(
|
|
||||||
filename:join(RootPath, "journal/journal_files/post_compact")),
|
|
||||||
io:format("Number of files after compaction ~w~n", [length(FileList4)]),
|
io:format("Number of files after compaction ~w~n", [length(FileList4)]),
|
||||||
true = length(FileList4) >= length(FileList3) + 3,
|
|
||||||
|
|
||||||
ok = leveled_bookie:book_close(Bookie3),
|
ok = leveled_bookie:book_close(Bookie3),
|
||||||
|
|
||||||
|
NewlyCompactedFiles = lists:subtract(FileList4, FileList3),
|
||||||
|
true = length(NewlyCompactedFiles) >= 3,
|
||||||
|
CDBFilterFun = fun(_K, _V, _P, Acc, _EF) -> {loop, Acc + 1} end,
|
||||||
|
CheckLengthFun =
|
||||||
|
fun(FN) ->
|
||||||
|
{ok, CF} =
|
||||||
|
leveled_cdb:cdb_open_reader(filename:join(CompPath, FN)),
|
||||||
|
{_LP, TK} =
|
||||||
|
leveled_cdb:cdb_scan(CF, CDBFilterFun, 0, undefined),
|
||||||
|
io:format("File ~s has ~w keys~n", [FN, TK]),
|
||||||
|
true = TK =< 7000
|
||||||
|
end,
|
||||||
|
lists:foreach(CheckLengthFun, NewlyCompactedFiles),
|
||||||
|
|
||||||
testutil:reset_filestructure(10000).
|
testutil:reset_filestructure(10000).
|
||||||
|
|
||||||
recompact_keydeltas(_Config) ->
|
recompact_keydeltas(_Config) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue