Merge pull request #248 from martinsumner/mas-i246-dotdotwhy

Change file references in unit tests
This commit is contained in:
Martin Sumner 2019-01-17 21:03:20 +00:00 committed by GitHub
commit 67104c85c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 119 additions and 102 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@
*~
.DS_Store
rebar.lock
test/test_area/*

View file

@ -2373,7 +2373,7 @@ update_timings(SW, {fold, setup}, Timings) ->
-ifdef(TEST).
reset_filestructure() ->
RootPath = "../test",
RootPath = "test/test_area",
leveled_inker:clean_testdir(RootPath ++ "/" ++ ?JOURNAL_FP),
leveled_penciller:clean_testdir(RootPath ++ "/" ++ ?LEDGER_FP),
RootPath.

View file

@ -1996,7 +1996,7 @@ cyclecount_test() ->
end end,
[],
KVL1),
{ok, P1} = cdb_open_writer("../test/cycle_count.pnd",
{ok, P1} = cdb_open_writer("test/test_area/cycle_count.pnd",
#cdb_options{binary_mode=false}),
ok = cdb_mput(P1, KVL2),
{ok, F2} = cdb_complete(P1),
@ -2012,16 +2012,16 @@ cyclecount_test() ->
lists:seq(1, 5000)),
ok = cdb_close(P2),
ok = file:delete("../test/cycle_count.cdb").
ok = file:delete("test/test_area/cycle_count.cdb").
full_1_test() ->
List1 = lists:sort([{"key1","value1"},{"key2","value2"}]),
create("../test/simple.cdb",
create("test/test_area/simple.cdb",
lists:sort([{"key1","value1"},{"key2","value2"}])),
List2 = lists:sort(dump("../test/simple.cdb")),
List2 = lists:sort(dump("test/test_area/simple.cdb")),
?assertMatch(List1,List2),
ok = file:delete("../test/simple.cdb").
ok = file:delete("test/test_area/simple.cdb").
full_2_test() ->
List1 = lists:sort([{lists:flatten(io_lib:format("~s~p",[Prefix,Plug])),
@ -2029,34 +2029,34 @@ full_2_test() ->
|| Plug <- lists:seq(1,200),
Prefix <- ["dsd","so39ds","oe9%#*(","020dkslsldclsldowlslf%$#",
"tiep4||","qweq"]]),
create("../test/full.cdb",List1),
List2 = lists:sort(dump("../test/full.cdb")),
create("test/test_area/full.cdb",List1),
List2 = lists:sort(dump("test/test_area/full.cdb")),
?assertMatch(List1,List2),
ok = file:delete("../test/full.cdb").
ok = file:delete("test/test_area/full.cdb").
from_dict_test() ->
D = dict:new(),
D1 = dict:store("a","b",D),
D2 = dict:store("c","d",D1),
ok = from_dict("../test/from_dict_test.cdb",D2),
ok = from_dict("test/test_area/from_dict_test.cdb",D2),
io:format("Store created ~n", []),
KVP = lists:sort(dump("../test/from_dict_test.cdb")),
KVP = lists:sort(dump("test/test_area/from_dict_test.cdb")),
D3 = lists:sort(dict:to_list(D2)),
io:format("KVP is ~w~n", [KVP]),
io:format("D3 is ~w~n", [D3]),
?assertMatch(KVP, D3),
ok = file:delete("../test/from_dict_test.cdb").
ok = file:delete("test/test_area/from_dict_test.cdb").
to_dict_test() ->
D = dict:new(),
D1 = dict:store("a","b",D),
D2 = dict:store("c","d",D1),
ok = from_dict("../test/from_dict_test1.cdb",D2),
Dict = to_dict("../test/from_dict_test1.cdb"),
ok = from_dict("test/test_area/from_dict_test1.cdb",D2),
Dict = to_dict("test/test_area/from_dict_test1.cdb"),
D3 = lists:sort(dict:to_list(D2)),
D4 = lists:sort(dict:to_list(Dict)),
?assertMatch(D4,D3),
ok = file:delete("../test/from_dict_test1.cdb").
ok = file:delete("test/test_area/from_dict_test1.cdb").
crccheck_emptyvalue_test() ->
?assertMatch(false, crccheck(<<>>, <<"Key">>)).
@ -2094,32 +2094,42 @@ activewrite_singlewrite_test() ->
Value = "some text as new value",
InitialD = dict:new(),
InitialD1 = dict:store("0001", "Initial value", InitialD),
ok = from_dict("../test/test_mem.cdb", InitialD1),
ok = from_dict("test/test_area/test_mem.cdb", InitialD1),
io:format("New db file created ~n", []),
{LastPosition, KeyDict, _} = open_active_file("../test/test_mem.cdb"),
{LastPosition, KeyDict, _} =
open_active_file("test/test_area/test_mem.cdb"),
io:format("File opened as new active file "
"with LastPosition=~w ~n", [LastPosition]),
{_, _, UpdKeyDict} = put("../test/test_mem.cdb",
{_, _, UpdKeyDict} = put("test/test_area/test_mem.cdb",
Key, Value,
{LastPosition, KeyDict}),
io:format("New key and value added to active file ~n", []),
?assertMatch({Key, Value},
get_mem(Key, "../test/test_mem.cdb", UpdKeyDict, false)),
get_mem(Key,
"test/test_area/test_mem.cdb",
UpdKeyDict,
false)),
?assertMatch(probably,
get_mem(Key, "../test/test_mem.cdb", UpdKeyDict,
false, loose_presence)),
get_mem(Key,
"test/test_area/test_mem.cdb",
UpdKeyDict,
false,
loose_presence)),
?assertMatch(missing,
get_mem("not_present", "../test/test_mem.cdb", UpdKeyDict,
false, loose_presence)),
ok = file:delete("../test/test_mem.cdb").
get_mem("not_present",
"test/test_area/test_mem.cdb",
UpdKeyDict,
false,
loose_presence)),
ok = file:delete("test/test_area/test_mem.cdb").
search_hash_table_findinslot_test() ->
Key1 = "key1", % this is in slot 3 if count is 8
D = dict:from_list([{Key1, "value1"}, {"K2", "V2"}, {"K3", "V3"},
{"K4", "V4"}, {"K5", "V5"}, {"K6", "V6"}, {"K7", "V7"},
{"K8", "V8"}]),
ok = from_dict("../test/hashtable1_test.cdb",D),
{ok, Handle} = file:open("../test/hashtable1_test.cdb",
ok = from_dict("test/test_area/hashtable1_test.cdb",D),
{ok, Handle} = file:open("test/test_area/hashtable1_test.cdb",
[binary, raw, read, write]),
Hash = hash(Key1),
Index = hash_to_index(Hash),
@ -2158,13 +2168,13 @@ search_hash_table_findinslot_test() ->
RBin),
ok = file:close(Handle),
io:format("Find key following change to hash table~n"),
?assertMatch(missing, get("../test/hashtable1_test.cdb", Key1, false)),
ok = file:delete("../test/hashtable1_test.cdb").
?assertMatch(missing, get("test/test_area/hashtable1_test.cdb", Key1, false)),
ok = file:delete("test/test_area/hashtable1_test.cdb").
newactivefile_test() ->
{LastPosition, _, _} = open_active_file("../test/activefile_test.cdb"),
{LastPosition, _, _} = open_active_file("test/test_area/activefile_test.cdb"),
?assertMatch(256 * ?DWORD_SIZE, LastPosition),
ok = file:delete("../test/activefile_test.cdb").
ok = file:delete("test/test_area/activefile_test.cdb").
emptyvalue_fromdict_test() ->
D = dict:new(),
@ -2172,31 +2182,31 @@ emptyvalue_fromdict_test() ->
D2 = dict:store("K2", "", D1),
D3 = dict:store("K3", "V3", D2),
D4 = dict:store("K4", "", D3),
ok = from_dict("../test/from_dict_test_ev.cdb",D4),
ok = from_dict("test/test_area/from_dict_test_ev.cdb",D4),
io:format("Store created ~n", []),
KVP = lists:sort(dump("../test/from_dict_test_ev.cdb")),
KVP = lists:sort(dump("test/test_area/from_dict_test_ev.cdb")),
D_Result = lists:sort(dict:to_list(D4)),
io:format("KVP is ~w~n", [KVP]),
io:format("D_Result is ~w~n", [D_Result]),
?assertMatch(KVP, D_Result),
ok = file:delete("../test/from_dict_test_ev.cdb").
ok = file:delete("test/test_area/from_dict_test_ev.cdb").
empty_roll_test() ->
file:delete("../test/empty_roll.cdb"),
file:delete("../test/empty_roll.pnd"),
{ok, P1} = cdb_open_writer("../test/empty_roll.pnd",
file:delete("test/test_area/empty_roll.cdb"),
file:delete("test/test_area/empty_roll.pnd"),
{ok, P1} = cdb_open_writer("test/test_area/empty_roll.pnd",
#cdb_options{binary_mode=true}),
ok = cdb_roll(P1),
true = finished_rolling(P1),
{ok, P2} = cdb_open_reader("../test/empty_roll.cdb",
{ok, P2} = cdb_open_reader("test/test_area/empty_roll.cdb",
#cdb_options{binary_mode=true}),
ok = cdb_close(P2),
ok = file:delete("../test/empty_roll.cdb").
ok = file:delete("test/test_area/empty_roll.cdb").
find_lastkey_test() ->
file:delete("../test/lastkey.pnd"),
{ok, P1} = cdb_open_writer("../test/lastkey.pnd",
file:delete("test/test_area/lastkey.pnd"),
{ok, P1} = cdb_open_writer("test/test_area/lastkey.pnd",
#cdb_options{binary_mode=false}),
ok = cdb_put(P1, "Key1", "Value1"),
ok = cdb_put(P1, "Key3", "Value3"),
@ -2205,7 +2215,7 @@ find_lastkey_test() ->
?assertMatch("Key1", cdb_firstkey(P1)),
probably = cdb_keycheck(P1, "Key2"),
ok = cdb_close(P1),
{ok, P2} = cdb_open_writer("../test/lastkey.pnd",
{ok, P2} = cdb_open_writer("test/test_area/lastkey.pnd",
#cdb_options{binary_mode=false}),
?assertMatch("Key2", cdb_lastkey(P2)),
probably = cdb_keycheck(P2, "Key2"),
@ -2216,10 +2226,10 @@ find_lastkey_test() ->
{ok, P4} = cdb_open_reader(F2),
?assertMatch("Key2", cdb_lastkey(P4)),
ok = cdb_close(P4),
ok = file:delete("../test/lastkey.cdb").
ok = file:delete("test/test_area/lastkey.cdb").
get_keys_byposition_simple_test() ->
{ok, P1} = cdb_open_writer("../test/poskey.pnd",
{ok, P1} = cdb_open_writer("test/test_area/poskey.pnd",
#cdb_options{binary_mode=false}),
ok = cdb_put(P1, "Key1", "Value1"),
ok = cdb_put(P1, "Key3", "Value3"),
@ -2263,7 +2273,7 @@ get_keys_byposition_manykeys_test_() ->
get_keys_byposition_manykeys_test_to() ->
KeyCount = ?KEYCOUNT,
{ok, P1} = cdb_open_writer("../test/poskeymany.pnd",
{ok, P1} = cdb_open_writer("test/test_area/poskeymany.pnd",
#cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(KeyCount, []),
lists:foreach(fun({K, V}) -> cdb_put(P1, K, V) end, KVList),
@ -2310,7 +2320,7 @@ get_keys_byposition_manykeys_test_to() ->
nokeys_test() ->
{ok, P1} = cdb_open_writer("../test/nohash_emptyfile.pnd",
{ok, P1} = cdb_open_writer("test/test_area/nohash_emptyfile.pnd",
#cdb_options{binary_mode=false}),
{ok, F2} = cdb_complete(P1),
{ok, P2} = cdb_open_reader(F2, #cdb_options{binary_mode=false}),
@ -2323,7 +2333,7 @@ nokeys_test() ->
mput_test() ->
KeyCount = 1024,
{ok, P1} = cdb_open_writer("../test/nohash_keysinfile.pnd",
{ok, P1} = cdb_open_writer("test/test_area/nohash_keysinfile.pnd",
#cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(KeyCount, []),
ok = cdb_mput(P1, KVList),
@ -2343,7 +2353,7 @@ mput_test() ->
ok = file:delete(F2).
state_test() ->
{ok, P1} = cdb_open_writer("../test/state_test.pnd",
{ok, P1} = cdb_open_writer("test/test_area/state_test.pnd",
#cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(1000, []),
ok = cdb_mput(P1, KVList),
@ -2362,7 +2372,7 @@ state_test() ->
hashclash_test() ->
{ok, P1} = cdb_open_writer("../test/hashclash_test.pnd",
{ok, P1} = cdb_open_writer("test/test_area/hashclash_test.pnd",
#cdb_options{binary_mode=false}),
Key1 = "Key4184465780",
Key99 = "Key4254669179",
@ -2405,8 +2415,8 @@ hashclash_test() ->
ok = cdb_close(P2).
corruptfile_test() ->
file:delete("../test/corrupt_test.pnd"),
{ok, P1} = cdb_open_writer("../test/corrupt_test.pnd",
file:delete("test/test_area/corrupt_test.pnd"),
{ok, P1} = cdb_open_writer("test/test_area/corrupt_test.pnd",
#cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(100, []),
ok = cdb_mput(P1, []), % Not relevant to this test, but needs testing
@ -2417,15 +2427,15 @@ corruptfile_test() ->
ok = cdb_close(P1),
lists:foreach(fun(Offset) -> corrupt_testfile_at_offset(Offset) end,
lists:seq(1, 40)),
ok = file:delete("../test/corrupt_test.pnd").
ok = file:delete("test/test_area/corrupt_test.pnd").
corrupt_testfile_at_offset(Offset) ->
{ok, F1} = file:open("../test/corrupt_test.pnd", ?WRITE_OPS),
{ok, F1} = file:open("test/test_area/corrupt_test.pnd", ?WRITE_OPS),
{ok, EofPos} = file:position(F1, eof),
file:position(F1, EofPos - Offset),
ok = file:truncate(F1),
ok = file:close(F1),
{ok, P2} = cdb_open_writer("../test/corrupt_test.pnd",
{ok, P2} = cdb_open_writer("test/test_area/corrupt_test.pnd",
#cdb_options{binary_mode=false}),
?assertMatch(probably, cdb_keycheck(P2, "Key1")),
?assertMatch({"Key1", "Value1"}, cdb_get(P2, "Key1")),
@ -2435,8 +2445,8 @@ corrupt_testfile_at_offset(Offset) ->
ok = cdb_close(P2).
crc_corrupt_writer_test() ->
file:delete("../test/corruptwrt_test.pnd"),
{ok, P1} = cdb_open_writer("../test/corruptwrt_test.pnd",
file:delete("test/test_area/corruptwrt_test.pnd"),
{ok, P1} = cdb_open_writer("test/test_area/corruptwrt_test.pnd",
#cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(100, []),
ok = cdb_mput(P1, KVList),
@ -2444,12 +2454,12 @@ crc_corrupt_writer_test() ->
?assertMatch({"Key1", "Value1"}, cdb_get(P1, "Key1")),
?assertMatch({"Key100", "Value100"}, cdb_get(P1, "Key100")),
ok = cdb_close(P1),
{ok, Handle} = file:open("../test/corruptwrt_test.pnd", ?WRITE_OPS),
{ok, Handle} = file:open("test/test_area/corruptwrt_test.pnd", ?WRITE_OPS),
{ok, EofPos} = file:position(Handle, eof),
% zero the last byte of the last value
ok = file:pwrite(Handle, EofPos - 5, <<0:8/integer>>),
ok = file:close(Handle),
{ok, P2} = cdb_open_writer("../test/corruptwrt_test.pnd",
{ok, P2} = cdb_open_writer("test/test_area/corruptwrt_test.pnd",
#cdb_options{binary_mode=false}),
?assertMatch(probably, cdb_keycheck(P2, "Key1")),
?assertMatch({"Key1", "Value1"}, cdb_get(P2, "Key1")),
@ -2470,7 +2480,7 @@ safe_read_test() ->
ValueL= byte_size(ValToWrite),
FlippedValL = endian_flip(ValueL),
TestFN = "../test/saferead.pnd",
TestFN = "test/test_area/saferead.pnd",
BinToWrite =
<<FlippedKeyL:32/integer,
FlippedValL:32/integer,
@ -2542,7 +2552,7 @@ safe_read_test() ->
get_positions_corruption_test() ->
F1 = "../test/corruptpos_test.pnd",
F1 = "test/test_area/corruptpos_test.pnd",
file:delete(F1),
{ok, P1} = cdb_open_writer(F1, #cdb_options{binary_mode=false}),
KVList = generate_sequentialkeys(1000, []),
@ -2576,7 +2586,7 @@ get_positions_corruption_test() ->
file:delete(F2).
badly_written_test() ->
F1 = "../test/badfirstwrite_test.pnd",
F1 = "test/test_area/badfirstwrite_test.pnd",
file:delete(F1),
{ok, Handle} = file:open(F1, ?WRITE_OPS),
ok = file:pwrite(Handle, 256 * ?DWORD_SIZE, <<1:8/integer>>),

View file

@ -843,7 +843,7 @@ simple_score_test() ->
?assertMatch(-60.0, score_run(Run3, {4, 70.0, 40.0})).
file_gc_test() ->
State = #state{waste_path="test/waste/",
State = #state{waste_path="test/test_area/waste/",
waste_retention_period=1},
ok = filelib:ensure_dir(State#state.waste_path),
file:write_file(State#state.waste_path ++ "1.cdb", term_to_binary("Hello")),
@ -931,7 +931,8 @@ fetch_testcdb(RP) ->
leveled_cdb:cdb_open_reader(FN2, #cdb_options{binary_mode=true}).
check_single_file_test() ->
RP = "../test/journal",
RP = "test/test_area/",
ok = filelib:ensure_dir(leveled_inker:filepath(RP, journal_dir)),
{ok, CDB} = fetch_testcdb(RP),
LedgerSrv1 = [{8, {o, "Bucket", "Key1", null}},
{2, {o, "Bucket", "Key2", null}},
@ -957,7 +958,8 @@ check_single_file_test() ->
compact_single_file_setup() ->
RP = "../test/journal",
RP = "test/test_area/",
ok = filelib:ensure_dir(leveled_inker:filepath(RP, journal_dir)),
{ok, CDB} = fetch_testcdb(RP),
Candidate = #candidate{journal = CDB,
low_sqn = 1,
@ -1055,7 +1057,8 @@ compact_single_file_retain_test() ->
ok = leveled_cdb:cdb_destroy(CDB).
compact_empty_file_test() ->
RP = "../test/journal",
RP = "test/test_area/",
ok = filelib:ensure_dir(leveled_inker:filepath(RP, journal_dir)),
FN1 = leveled_inker:filepath(RP, 1, new_journal),
CDBopts = #cdb_options{binary_mode=true},
{ok, CDB1} = leveled_cdb:cdb_open_writer(FN1, CDBopts),
@ -1083,8 +1086,8 @@ compact_singlefile_totwosmallfiles_test_() ->
{timeout, 60, fun compact_singlefile_totwosmallfiles_testto/0}.
compact_singlefile_totwosmallfiles_testto() ->
RP = "../test/journal",
CP = "../test/journal/journal_file/post_compact/",
RP = "test/test_area/",
CP = "test/test_area/journal/journal_file/post_compact/",
ok = filelib:ensure_dir(CP),
FN1 = leveled_inker:filepath(RP, 1, new_journal),
CDBoptsLarge = #cdb_options{binary_mode=true, max_size=30000000},

View file

@ -311,7 +311,7 @@ buildrandomfashion_test() ->
?assertMatch(ManL0, to_list(Man2)).
empty_active_journal_test() ->
Path = "../test/journal/journal_files/",
Path = "test/test_area/journal/journal_files/",
ok = filelib:ensure_dir(Path),
{ok, ActJ} = leveled_cdb:cdb_open_writer(Path ++ "test_emptyactive_file.pnd"),
?assertMatch([], generate_entry(ActJ)),

View file

@ -1279,7 +1279,7 @@ build_dummy_journal() ->
build_dummy_journal(fun key_converter/1).
build_dummy_journal(KeyConvertF) ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
clean_testdir(RootPath),
JournalFP = filepath(RootPath, journal_dir),
ManifestFP = filepath(RootPath, manifest_dir),
@ -1326,8 +1326,8 @@ build_dummy_journal(KeyConvertF) ->
create_value_for_journal({V4, ?TEST_KC}, false)),
LK2 = leveled_cdb:cdb_lastkey(J2),
ok = leveled_cdb:cdb_close(J2),
Manifest = [{1, "../test/journal/journal_files/nursery_1", "pid1", LK1},
{3, "../test/journal/journal_files/nursery_3", "pid2", LK2}],
Manifest = [{1, "test/test_area/journal/journal_files/nursery_1", "pid1", LK1},
{3, "test/test_area/journal/journal_files/nursery_3", "pid2", LK2}],
ManifestBin = term_to_binary(Manifest),
{ok, MF1} = file:open(filename:join(ManifestFP, "1.man"),
[binary, raw, read, write]),
@ -1354,7 +1354,7 @@ clean_subdir(DirPath) ->
Files).
simple_inker_test() ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
build_dummy_journal(),
CDBopts = #cdb_options{max_size=300000, binary_mode=true},
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
@ -1371,7 +1371,7 @@ simple_inker_test() ->
clean_testdir(RootPath).
simple_inker_completeactivejournal_test() ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
build_dummy_journal(),
CDBopts = #cdb_options{max_size=300000, binary_mode=true},
JournalFP = filepath(RootPath, journal_dir),
@ -1402,7 +1402,7 @@ compact_journal_wastediscarded_test_() ->
{timeout, 60, fun() -> compact_journal_testto(undefined, false) end}.
compact_journal_testto(WRP, ExpectedFiles) ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
CDBopts = #cdb_options{max_size=300000},
RStrategy = [{?STD_TAG, recovr}],
InkOpts = #inker_options{root_path=RootPath,
@ -1478,7 +1478,7 @@ compact_journal_testto(WRP, ExpectedFiles) ->
clean_testdir(RootPath).
empty_manifest_test() ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
clean_testdir(RootPath),
CDBopts = #cdb_options{max_size=300000},
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,
@ -1532,7 +1532,7 @@ coverage_cheat_test() ->
{ok, _State1} = code_change(null, #state{}, null).
handle_down_test() ->
RootPath = "../test/journal",
RootPath = "test/test_area/journal",
build_dummy_journal(),
CDBopts = #cdb_options{max_size=300000, binary_mode=true},
{ok, Ink1} = ink_start(#inker_options{root_path=RootPath,

View file

@ -318,9 +318,10 @@ generate_randomkeys(Count, Acc, BucketLow, BRange) ->
merge_file_test() ->
ok = filelib:ensure_dir("test/test_area/ledger_files/"),
KL1_L1 = lists:sort(generate_randomkeys(8000, 0, 1000)),
{ok, PidL1_1, _, _} =
leveled_sst:sst_new("../test/",
leveled_sst:sst_new("test/test_area/ledger_files/",
"KL1_L1.sst",
1,
KL1_L1,
@ -328,7 +329,7 @@ merge_file_test() ->
#sst_options{}),
KL1_L2 = lists:sort(generate_randomkeys(8000, 0, 250)),
{ok, PidL2_1, _, _} =
leveled_sst:sst_new("../test/",
leveled_sst:sst_new("test/test_area/ledger_files/",
"KL1_L2.sst",
2,
KL1_L2,
@ -336,7 +337,7 @@ merge_file_test() ->
#sst_options{}),
KL2_L2 = lists:sort(generate_randomkeys(8000, 250, 250)),
{ok, PidL2_2, _, _} =
leveled_sst:sst_new("../test/",
leveled_sst:sst_new("test/test_area/ledger_files/",
"KL2_L2.sst",
2,
KL2_L2,
@ -344,7 +345,7 @@ merge_file_test() ->
#sst_options{press_method = lz4}),
KL3_L2 = lists:sort(generate_randomkeys(8000, 500, 250)),
{ok, PidL2_3, _, _} =
leveled_sst:sst_new("../test/",
leveled_sst:sst_new("test/test_area/ledger_files/",
"KL3_L2.sst",
2,
KL3_L2,
@ -352,13 +353,12 @@ merge_file_test() ->
#sst_options{press_method = lz4}),
KL4_L2 = lists:sort(generate_randomkeys(8000, 750, 250)),
{ok, PidL2_4, _, _} =
leveled_sst:sst_new("../test/",
leveled_sst:sst_new("test/test_area/ledger_files/",
"KL4_L2.sst",
2,
KL4_L2,
999999,
#sst_options{press_method = lz4}),
E1 = #manifest_entry{owner = PidL1_1,
filename = "./KL1_L1.sst",
end_key = lists:last(KL1_L1),
@ -386,11 +386,12 @@ merge_file_test() ->
Man3 = leveled_pmanifest:insert_manifest_entry(Man2, 1, 2, E4),
Man4 = leveled_pmanifest:insert_manifest_entry(Man3, 1, 2, E5),
Man5 = leveled_pmanifest:insert_manifest_entry(Man4, 2, 1, E1),
PointerList = lists:map(fun(ME) -> {next, ME, all} end,
[E2, E3, E4, E5]),
{Man6, _Dels} =
perform_merge(Man5, E1, PointerList, 1, "../test", 3, #sst_options{}),
perform_merge(Man5, E1, PointerList, 1,
"test/test_area/ledger_files/",
3, #sst_options{}),
?assertMatch(3, leveled_pmanifest:get_manifest_sqn(Man6)).

View file

@ -244,7 +244,7 @@
persisted_sqn = 0 :: integer(), % The highest SQN persisted
ledger_sqn = 0 :: integer(), % The highest SQN added to L0
root_path = "../test" :: string(),
root_path = "test" :: string(),
clerk :: pid() | undefined,
@ -1947,7 +1947,7 @@ add_missing_hash({K, {SQN, ST, MD}}) ->
archive_files_test() ->
RootPath = "../test/ledger",
RootPath = "test/test_area/ledger",
SSTPath = sst_rootpath(RootPath),
ok = filelib:ensure_dir(SSTPath),
ok = file:write_file(SSTPath ++ "/test1.sst", "hello_world"),
@ -1978,7 +1978,7 @@ shutdown_when_compact(Pid) ->
pcl_close(Pid).
simple_server_test() ->
RootPath = "../test/ledger",
RootPath = "test/test_area/ledger",
clean_testdir(RootPath),
{ok, PCL} =
pcl_start(#penciller_options{root_path=RootPath,
@ -2286,7 +2286,7 @@ foldwithimm_simple_test() ->
{{o, "Bucket1", "Key6", null}, 7}], AccB).
create_file_test() ->
{RP, Filename} = {"../test/", "new_file.sst"},
{RP, Filename} = {"test/test_area/", "new_file.sst"},
ok = file:write_file(filename:join(RP, Filename), term_to_binary("hello")),
KVL = lists:usort(generate_randomkeys({50000, 0})),
Tree = leveled_tree:from_orderedlist(KVL, ?CACHE_TYPE),
@ -2313,7 +2313,7 @@ create_file_test() ->
?assertMatch({o, _, _, _}, EndKey),
?assertMatch("./new_file.sst", SrcFN),
ok = leveled_sst:sst_clear(SP),
{ok, Bin} = file:read_file("../test/new_file.sst.discarded"),
{ok, Bin} = file:read_file("test/test_area/new_file.sst.discarded"),
?assertMatch("hello", binary_to_term(Bin)).
slow_fetch_test() ->
@ -2347,7 +2347,7 @@ coverage_cheat_test() ->
{ok, _State1} = code_change(null, #state{}, null).
handle_down_test() ->
RootPath = "../test/ledger",
RootPath = "test/test_area/ledger",
clean_testdir(RootPath),
{ok, PCLr} =
pcl_start(#penciller_options{root_path=RootPath,

View file

@ -991,8 +991,9 @@ random_select_test() ->
?assertMatch(true, lists:member(L1File, Level1)).
manifest_gc_test() ->
RP = "../test_gc",
RP = "test/test_area/",
ok = filelib:ensure_dir(RP),
ok = leveled_penciller:clean_testdir(RP),
ManifestT = initial_setup(multi_change),
ManifestL = tuple_to_list(ManifestT),
lists:foreach(fun(M) -> save_manifest(M, RP) end, ManifestL),
@ -1049,7 +1050,8 @@ keylookup_manifest_test() ->
?assertMatch("pid_z5", key_lookup(Man13, 2, LK1_4)).
ext_keylookup_manifest_test() ->
RP = "../test",
RP = "test/test_area",
ok = leveled_penciller:clean_testdir(RP),
{_Man0, _Man1, _Man2, _Man3, _Man4, _Man5, Man6} = initial_setup(),
save_manifest(Man6, RP),

View file

@ -2841,9 +2841,9 @@ merge_tester(NewFunS, NewFunM) ->
KVL3 = lists:ukeymerge(1, KVL1, KVL2),
SW0 = os:timestamp(),
{ok, P1, {FK1, LK1}, _Bloom1} =
NewFunS("../test/", "level1_src", 1, KVL1, 6000, native),
NewFunS("test/test_area/", "level1_src", 1, KVL1, 6000, native),
{ok, P2, {FK2, LK2}, _Bloom2} =
NewFunS("../test/", "level2_src", 2, KVL2, 3000, native),
NewFunS("test/test_area/", "level2_src", 2, KVL2, 3000, native),
ExpFK1 = element(1, lists:nth(1, KVL1)),
ExpLK1 = element(1, lists:last(KVL1)),
ExpFK2 = element(1, lists:nth(1, KVL2)),
@ -2855,7 +2855,7 @@ merge_tester(NewFunS, NewFunM) ->
ML1 = [{next, #manifest_entry{owner = P1}, FK1}],
ML2 = [{next, #manifest_entry{owner = P2}, FK2}],
NewR =
NewFunM("../test/", "level2_merge", ML1, ML2, false, 2, N * 2, native),
NewFunM("test/test_area/", "level2_merge", ML1, ML2, false, 2, N * 2, native),
{ok, P3, {{Rem1, Rem2}, FK3, LK3}, _Bloom3} = NewR,
?assertMatch([], Rem1),
?assertMatch([], Rem2),
@ -2878,16 +2878,16 @@ merge_tester(NewFunS, NewFunM) ->
ok = sst_close(P1),
ok = sst_close(P2),
ok = sst_close(P3),
ok = file:delete("../test/level1_src.sst"),
ok = file:delete("../test/level2_src.sst"),
ok = file:delete("../test/level2_merge.sst").
ok = file:delete("test/test_area/level1_src.sst"),
ok = file:delete("test/test_area/level2_src.sst"),
ok = file:delete("test/test_area/level2_merge.sst").
simple_persisted_range_test() ->
simple_persisted_range_tester(fun testsst_new/6).
simple_persisted_range_tester(SSTNewFun) ->
{RP, Filename} = {"../test/", "simple_test"},
{RP, Filename} = {"test/test_area/", "simple_test"},
KVList0 = generate_randomkeys(1, ?LOOK_SLOTSIZE * 16, 1, 20),
KVList1 = lists:ukeysort(1, KVList0),
[{FirstKey, _FV}|_Rest] = KVList1,
@ -2929,7 +2929,7 @@ simple_persisted_rangesegfilter_test() ->
simple_persisted_rangesegfilter_tester(fun testsst_new/6).
simple_persisted_rangesegfilter_tester(SSTNewFun) ->
{RP, Filename} = {"../test/", "range_segfilter_test"},
{RP, Filename} = {"test/test_area/", "range_segfilter_test"},
KVList0 = generate_randomkeys(1, ?LOOK_SLOTSIZE * 16, 1, 20),
KVList1 = lists:ukeysort(1, KVList0),
[{FirstKey, _FV}|_Rest] = KVList1,
@ -3021,7 +3021,7 @@ additional_range_test() ->
lists:seq(?NOLOOK_SLOTSIZE + Gap + 1,
2 * ?NOLOOK_SLOTSIZE + Gap)),
{ok, P1, {{Rem1, Rem2}, SK, EK}, _Bloom1} =
testsst_new("../test/", "range1_src", IK1, IK2, false, 1, 9999, native),
testsst_new("test/test_area/", "range1_src", IK1, IK2, false, 1, 9999, native),
?assertMatch([], Rem1),
?assertMatch([], Rem2),
?assertMatch(SK, element(1, lists:nth(1, IK1))),
@ -3076,7 +3076,7 @@ simple_persisted_slotsize_test() ->
simple_persisted_slotsize_tester(SSTNewFun) ->
{RP, Filename} = {"../test/", "simple_slotsize_test"},
{RP, Filename} = {"test/test_area/", "simple_slotsize_test"},
KVList0 = generate_randomkeys(1, ?LOOK_SLOTSIZE * 2, 1, 20),
KVList1 = lists:sublist(lists:ukeysort(1, KVList0),
?LOOK_SLOTSIZE),
@ -3098,7 +3098,7 @@ simple_persisted_test_bothformats() ->
simple_persisted_tester(fun testsst_new/6).
simple_persisted_tester(SSTNewFun) ->
{RP, Filename} = {"../test/", "simple_test"},
{RP, Filename} = {"test/test_area/", "simple_test"},
KVList0 = generate_randomkeys(1, ?LOOK_SLOTSIZE * 32, 1, 20),
KVList1 = lists:ukeysort(1, KVList0),
[{FirstKey, _FV}|_Rest] = KVList1,