Improve test coverage
Make compress on receipt/compaction configurable
This commit is contained in:
parent
61b7be5039
commit
1d475235d1
7 changed files with 56 additions and 35 deletions
|
@ -137,6 +137,7 @@
|
|||
compaction_pending = false :: boolean(),
|
||||
is_snapshot = false :: boolean(),
|
||||
compression_method :: lz4|native,
|
||||
compress_on_receipt :: boolean(),
|
||||
source_inker :: pid() | undefined}).
|
||||
|
||||
|
||||
|
@ -510,12 +511,13 @@ start_from_file(InkOpts) ->
|
|||
ReloadStrategy = InkOpts#inker_options.reload_strategy,
|
||||
MRL = InkOpts#inker_options.max_run_length,
|
||||
WRP = InkOpts#inker_options.waste_retention_period,
|
||||
Compression = InkOpts#inker_options.compression_method,
|
||||
PressMethod = InkOpts#inker_options.compression_method,
|
||||
PressOnReceipt = InkOpts#inker_options.compress_on_receipt,
|
||||
IClerkOpts = #iclerk_options{inker = self(),
|
||||
cdb_options=IClerkCDBOpts,
|
||||
waste_retention_period = WRP,
|
||||
reload_strategy = ReloadStrategy,
|
||||
compression_method = Compression,
|
||||
compression_method = PressMethod,
|
||||
max_run_length = MRL},
|
||||
{ok, Clerk} = leveled_iclerk:clerk_new(IClerkOpts),
|
||||
|
||||
|
@ -531,7 +533,8 @@ start_from_file(InkOpts) ->
|
|||
active_journaldb = ActiveJournal,
|
||||
root_path = RootPath,
|
||||
cdb_options = CDBopts#cdb_options{waste_path=WasteFP},
|
||||
compression_method = Compression,
|
||||
compression_method = PressMethod,
|
||||
compress_on_receipt = PressOnReceipt,
|
||||
clerk = Clerk}}.
|
||||
|
||||
|
||||
|
@ -543,7 +546,8 @@ put_object(LedgerKey, Object, KeyChanges, State) ->
|
|||
NewSQN,
|
||||
Object,
|
||||
KeyChanges,
|
||||
State#state.compression_method),
|
||||
State#state.compression_method,
|
||||
State#state.compress_on_receipt),
|
||||
case leveled_cdb:cdb_put(ActiveJournal,
|
||||
JournalKey,
|
||||
JournalBin) of
|
||||
|
@ -586,22 +590,14 @@ get_object(LedgerKey, SQN, Manifest) ->
|
|||
get_object(LedgerKey, SQN, Manifest, ToIgnoreKeyChanges) ->
|
||||
JournalP = leveled_imanifest:find_entry(SQN, Manifest),
|
||||
{InkerKey, _V, true} =
|
||||
leveled_codec:to_inkerkv(LedgerKey,
|
||||
SQN,
|
||||
to_fetch,
|
||||
null,
|
||||
not_applicable),
|
||||
leveled_codec:to_inkerkv(LedgerKey, SQN, to_fetch),
|
||||
Obj = leveled_cdb:cdb_get(JournalP, InkerKey),
|
||||
leveled_codec:from_inkerkv(Obj, ToIgnoreKeyChanges).
|
||||
|
||||
key_check(LedgerKey, SQN, Manifest) ->
|
||||
JournalP = leveled_imanifest:find_entry(SQN, Manifest),
|
||||
{InkerKey, _V, true} =
|
||||
leveled_codec:to_inkerkv(LedgerKey,
|
||||
SQN,
|
||||
to_fetch,
|
||||
null,
|
||||
not_applicable),
|
||||
leveled_codec:to_inkerkv(LedgerKey, SQN, to_fetch),
|
||||
leveled_cdb:cdb_keycheck(JournalP, InkerKey).
|
||||
|
||||
build_manifest(ManifestFilenames,
|
||||
|
@ -944,7 +940,8 @@ simple_inker_test() ->
|
|||
CDBopts = #cdb_options{max_size=300000, binary_mode=true},
|
||||
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
|
||||
cdb_options=CDBopts,
|
||||
compression_method=native}),
|
||||
compression_method=native,
|
||||
compress_on_receipt=true}),
|
||||
Obj1 = ink_get(Ink1, "Key1", 1),
|
||||
?assertMatch({{1, "Key1"}, {"TestValue1", []}}, Obj1),
|
||||
Obj3 = ink_get(Ink1, "Key1", 3),
|
||||
|
@ -967,7 +964,8 @@ simple_inker_completeactivejournal_test() ->
|
|||
ok = file:rename(F1, F1r),
|
||||
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
|
||||
cdb_options=CDBopts,
|
||||
compression_method=native}),
|
||||
compression_method=native,
|
||||
compress_on_receipt=true}),
|
||||
Obj1 = ink_get(Ink1, "Key1", 1),
|
||||
?assertMatch({{1, "Key1"}, {"TestValue1", []}}, Obj1),
|
||||
Obj2 = ink_get(Ink1, "Key4", 4),
|
||||
|
@ -986,7 +984,8 @@ compact_journal_test() ->
|
|||
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
|
||||
cdb_options=CDBopts,
|
||||
reload_strategy=RStrategy,
|
||||
compression_method=native}),
|
||||
compression_method=native,
|
||||
compress_on_receipt=false}),
|
||||
{ok, NewSQN1, _ObjSize} = ink_put(Ink1,
|
||||
test_ledgerkey("KeyAA"),
|
||||
"TestValueAA",
|
||||
|
@ -1053,7 +1052,8 @@ empty_manifest_test() ->
|
|||
CDBopts = #cdb_options{max_size=300000},
|
||||
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
|
||||
cdb_options=CDBopts,
|
||||
compression_method=native}),
|
||||
compression_method=native,
|
||||
compress_on_receipt=true}),
|
||||
?assertMatch(not_present, ink_fetch(Ink1, "Key1", 1)),
|
||||
|
||||
CheckFun = fun(L, K, SQN) -> lists:member({SQN, K}, L) end,
|
||||
|
@ -1074,7 +1074,8 @@ empty_manifest_test() ->
|
|||
|
||||
{ok, Ink2} = ink_start(#inker_options{root_path=RootPath,
|
||||
cdb_options=CDBopts,
|
||||
compression_method=native}),
|
||||
compression_method=native,
|
||||
compress_on_receipt=false}),
|
||||
?assertMatch(not_present, ink_fetch(Ink2, "Key1", 1)),
|
||||
{ok, SQN, Size} = ink_put(Ink2, "Key1", "Value1", {[], infinity}),
|
||||
?assertMatch(2, SQN),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue