2016-10-03 23:34:28 +01:00
|
|
|
-module(basic_SUITE).
|
|
|
|
-include_lib("common_test/include/ct.hrl").
|
2016-10-17 14:24:32 +01:00
|
|
|
-include("include/leveled.hrl").
|
2016-10-03 23:34:28 +01:00
|
|
|
-export([all/0]).
|
2016-10-16 15:41:09 +01:00
|
|
|
-export([simple_put_fetch_head_delete/1,
|
2016-10-05 09:54:53 +01:00
|
|
|
many_put_fetch_head/1,
|
|
|
|
journal_compaction/1,
|
2016-10-13 17:51:47 +01:00
|
|
|
fetchput_snapshot/1,
|
2016-10-16 15:41:09 +01:00
|
|
|
load_and_count/1,
|
2016-10-18 01:59:03 +01:00
|
|
|
load_and_count_withdelete/1
|
|
|
|
]).
|
2016-10-03 23:34:28 +01:00
|
|
|
|
2016-10-16 15:41:09 +01:00
|
|
|
all() -> [simple_put_fetch_head_delete,
|
2016-10-12 17:35:32 +01:00
|
|
|
many_put_fetch_head,
|
|
|
|
journal_compaction,
|
2016-10-13 17:51:47 +01:00
|
|
|
fetchput_snapshot,
|
2016-10-16 15:41:09 +01:00
|
|
|
load_and_count,
|
|
|
|
load_and_count_withdelete
|
2016-10-14 22:58:01 +01:00
|
|
|
].
|
2016-10-03 23:34:28 +01:00
|
|
|
|
2016-10-05 18:28:31 +01:00
|
|
|
|
2016-10-16 15:41:09 +01:00
|
|
|
simple_put_fetch_head_delete(_Config) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-03 23:34:28 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-03 23:34:28 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
|
|
|
testutil:check_formissingobject(Bookie1, "Bucket1", "Key2"),
|
2016-10-03 23:34:28 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
|
|
|
StartOpts2 = #bookie_options{root_path=RootPath,
|
|
|
|
max_journalsize=3000000},
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
|
|
|
ObjList1 = testutil:generate_objects(5000, 2),
|
2016-10-03 23:34:28 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie2, Obj, Spc) end,
|
|
|
|
ObjList1),
|
|
|
|
ChkList1 = lists:sublist(lists:sort(ObjList1), 100),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, ChkList1),
|
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
|
|
|
testutil:check_formissingobject(Bookie2, "Bucket1", "Key2"),
|
2016-10-14 22:58:01 +01:00
|
|
|
ok = leveled_bookie:book_put(Bookie2, "Bucket1", "Key2", "Value2",
|
|
|
|
[{add, "Index1", "Term1"}]),
|
|
|
|
{ok, "Value2"} = leveled_bookie:book_get(Bookie2, "Bucket1", "Key2"),
|
|
|
|
{ok, {62888926, 43}} = leveled_bookie:book_head(Bookie2,
|
|
|
|
"Bucket1",
|
|
|
|
"Key2"),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_formissingobject(Bookie2, "Bucket1", "Key2"),
|
2016-10-14 22:58:01 +01:00
|
|
|
ok = leveled_bookie:book_put(Bookie2, "Bucket1", "Key2", <<"Value2">>,
|
|
|
|
[{remove, "Index1", "Term1"},
|
|
|
|
{add, "Index1", <<"Term2">>}]),
|
|
|
|
{ok, <<"Value2">>} = leveled_bookie:book_get(Bookie2, "Bucket1", "Key2"),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
2016-10-14 22:58:01 +01:00
|
|
|
{ok, Bookie3} = leveled_bookie:book_start(StartOpts2),
|
|
|
|
{ok, <<"Value2">>} = leveled_bookie:book_get(Bookie3, "Bucket1", "Key2"),
|
2016-10-16 15:41:09 +01:00
|
|
|
ok = leveled_bookie:book_delete(Bookie3, "Bucket1", "Key2",
|
|
|
|
[{remove, "Index1", "Term1"}]),
|
|
|
|
not_found = leveled_bookie:book_get(Bookie3, "Bucket1", "Key2"),
|
2016-10-14 22:58:01 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie3),
|
2016-10-16 15:41:09 +01:00
|
|
|
{ok, Bookie4} = leveled_bookie:book_start(StartOpts2),
|
|
|
|
not_found = leveled_bookie:book_get(Bookie4, "Bucket1", "Key2"),
|
|
|
|
ok = leveled_bookie:book_close(Bookie4),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:reset_filestructure().
|
2016-10-05 09:54:53 +01:00
|
|
|
|
|
|
|
many_put_fetch_head(_Config) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-05 09:54:53 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
|
|
|
StartOpts2 = #bookie_options{root_path=RootPath,
|
|
|
|
max_journalsize=1000000000},
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
2016-10-05 09:54:53 +01:00
|
|
|
GenList = [2, 20002, 40002, 60002, 80002,
|
|
|
|
100002, 120002, 140002, 160002, 180002],
|
2016-10-18 01:59:03 +01:00
|
|
|
CLs = testutil:load_objects(20000, GenList, Bookie2, TestObject,
|
|
|
|
fun testutil:generate_smallobjects/2),
|
2016-10-05 09:54:53 +01:00
|
|
|
CL1A = lists:nth(1, CLs),
|
|
|
|
ChkListFixed = lists:nth(length(CLs), CLs),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, CL1A),
|
|
|
|
ObjList2A = testutil:generate_objects(5000, 2),
|
2016-10-05 09:54:53 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie2, Obj, Spc) end,
|
|
|
|
ObjList2A),
|
|
|
|
ChkList2A = lists:sublist(lists:sort(ObjList2A), 1000),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, ChkList2A),
|
|
|
|
testutil:check_forlist(Bookie2, ChkListFixed),
|
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
|
|
|
testutil:check_forlist(Bookie2, ChkList2A),
|
|
|
|
testutil:check_forlist(Bookie2, ChkListFixed),
|
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
|
|
|
{ok, Bookie3} = leveled_bookie:book_start(StartOpts2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie3, ChkList2A),
|
|
|
|
testutil:check_forobject(Bookie3, TestObject),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie3),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:reset_filestructure().
|
2016-10-05 09:54:53 +01:00
|
|
|
|
2016-10-03 23:34:28 +01:00
|
|
|
journal_compaction(_Config) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-03 23:34:28 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath,
|
|
|
|
max_journalsize=4000000},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-03 23:34:28 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
|
|
|
ObjList1 = testutil:generate_objects(5000, 2),
|
2016-10-03 23:34:28 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie1, Obj, Spc) end,
|
|
|
|
ObjList1),
|
2016-10-05 18:28:31 +01:00
|
|
|
ChkList1 = lists:sublist(lists:sort(ObjList1), 1000),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList1),
|
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-05 18:28:31 +01:00
|
|
|
{B2, K2, V2, Spec2, MD} = {"Bucket1",
|
|
|
|
"Key1",
|
|
|
|
"Value1",
|
|
|
|
[],
|
|
|
|
{"MDK1", "MDV1"}},
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject2, TestSpec2} = testutil:generate_testobject(B2, K2,
|
|
|
|
V2, Spec2, MD),
|
2016-10-05 18:28:31 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject2, TestSpec2),
|
|
|
|
ok = leveled_bookie:book_compactjournal(Bookie1, 30000),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList1),
|
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
|
|
|
testutil:check_forobject(Bookie1, TestObject2),
|
2016-10-05 18:28:31 +01:00
|
|
|
timer:sleep(5000), % Allow for compaction to complete
|
|
|
|
io:format("Has journal completed?~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList1),
|
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
|
|
|
testutil:check_forobject(Bookie1, TestObject2),
|
2016-10-03 23:34:28 +01:00
|
|
|
%% Now replace all the objects
|
2016-10-18 01:59:03 +01:00
|
|
|
ObjList2 = testutil:generate_objects(5000, 2),
|
2016-10-03 23:34:28 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie1, Obj, Spc) end,
|
|
|
|
ObjList2),
|
|
|
|
ok = leveled_bookie:book_compactjournal(Bookie1, 30000),
|
|
|
|
ChkList3 = lists:sublist(lists:sort(ObjList2), 500),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList3),
|
2016-10-03 23:34:28 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
|
|
|
% Restart
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie2, TestObject),
|
|
|
|
testutil:check_forlist(Bookie2, ChkList3),
|
2016-10-03 23:34:28 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:reset_filestructure().
|
2016-10-03 23:34:28 +01:00
|
|
|
|
|
|
|
|
2016-10-07 10:04:48 +01:00
|
|
|
fetchput_snapshot(_Config) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-05 09:54:53 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath, max_journalsize=3000000},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
ObjList1 = testutil:generate_objects(5000, 2),
|
2016-10-05 09:54:53 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie1, Obj, Spc) end,
|
|
|
|
ObjList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
SnapOpts1 = #bookie_options{snapshot_bookie=Bookie1},
|
|
|
|
{ok, SnapBookie1} = leveled_bookie:book_start(SnapOpts1),
|
2016-10-05 09:54:53 +01:00
|
|
|
ChkList1 = lists:sublist(lists:sort(ObjList1), 100),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList1),
|
|
|
|
testutil:check_forlist(SnapBookie1, ChkList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
ok = leveled_bookie:book_close(SnapBookie1),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie1, ChkList1),
|
2016-10-05 09:54:53 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Closed initial bookies~n"),
|
|
|
|
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts1),
|
|
|
|
SnapOpts2 = #bookie_options{snapshot_bookie=Bookie2},
|
|
|
|
{ok, SnapBookie2} = leveled_bookie:book_start(SnapOpts2),
|
|
|
|
io:format("Bookies restarted~n"),
|
|
|
|
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, ChkList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Check active bookie still contains original data~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(SnapBookie2, ChkList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Check snapshot still contains original data~n"),
|
|
|
|
|
|
|
|
|
2016-10-18 01:59:03 +01:00
|
|
|
ObjList2 = testutil:generate_objects(5000, 2),
|
2016-10-07 10:04:48 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie2, Obj, Spc) end,
|
|
|
|
ObjList2),
|
|
|
|
io:format("Replacement objects put~n"),
|
|
|
|
|
|
|
|
ChkList2 = lists:sublist(lists:sort(ObjList2), 100),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, ChkList2),
|
|
|
|
testutil:check_forlist(SnapBookie2, ChkList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Checked for replacement objects in active bookie" ++
|
|
|
|
", old objects in snapshot~n"),
|
|
|
|
|
|
|
|
{ok, FNsA} = file:list_dir(RootPath ++ "/ledger/ledger_files"),
|
2016-10-18 01:59:03 +01:00
|
|
|
ObjList3 = testutil:generate_objects(15000, 5002),
|
2016-10-07 10:04:48 +01:00
|
|
|
lists:foreach(fun({_RN, Obj, Spc}) ->
|
|
|
|
leveled_bookie:book_riakput(Bookie2, Obj, Spc) end,
|
|
|
|
ObjList3),
|
|
|
|
ChkList3 = lists:sublist(lists:sort(ObjList3), 100),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, ChkList3),
|
|
|
|
testutil:check_formissinglist(SnapBookie2, ChkList3),
|
2016-10-07 10:04:48 +01:00
|
|
|
GenList = [20002, 40002, 60002, 80002, 100002, 120002],
|
2016-10-18 01:59:03 +01:00
|
|
|
CLs2 = testutil:load_objects(20000, GenList, Bookie2, TestObject,
|
|
|
|
fun testutil:generate_smallobjects/2),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Loaded significant numbers of new objects~n"),
|
|
|
|
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, lists:nth(length(CLs2), CLs2)),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Checked active bookie has new objects~n"),
|
|
|
|
|
|
|
|
{ok, SnapBookie3} = leveled_bookie:book_start(SnapOpts2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(SnapBookie3, lists:nth(length(CLs2), CLs2)),
|
|
|
|
testutil:check_formissinglist(SnapBookie2, ChkList3),
|
|
|
|
testutil:check_formissinglist(SnapBookie2, lists:nth(length(CLs2), CLs2)),
|
|
|
|
testutil:check_forlist(SnapBookie3, ChkList2),
|
|
|
|
testutil:check_forlist(SnapBookie2, ChkList1),
|
2016-10-07 10:04:48 +01:00
|
|
|
io:format("Started new snapshot and check for new objects~n"),
|
|
|
|
|
2016-10-18 01:59:03 +01:00
|
|
|
CLs3 = testutil:load_objects(20000, GenList, Bookie2, TestObject,
|
|
|
|
fun testutil:generate_smallobjects/2),
|
|
|
|
testutil:check_forlist(Bookie2, lists:nth(length(CLs3), CLs3)),
|
|
|
|
testutil:check_forlist(Bookie2, lists:nth(1, CLs3)),
|
2016-10-07 10:04:48 +01:00
|
|
|
{ok, FNsB} = file:list_dir(RootPath ++ "/ledger/ledger_files"),
|
|
|
|
ok = leveled_bookie:book_close(SnapBookie2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, lists:nth(length(CLs3), CLs3)),
|
2016-10-07 10:04:48 +01:00
|
|
|
ok = leveled_bookie:book_close(SnapBookie3),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forlist(Bookie2, lists:nth(length(CLs3), CLs3)),
|
|
|
|
testutil:check_forlist(Bookie2, lists:nth(1, CLs3)),
|
2016-10-07 10:04:48 +01:00
|
|
|
timer:sleep(90000),
|
|
|
|
{ok, FNsC} = file:list_dir(RootPath ++ "/ledger/ledger_files"),
|
|
|
|
true = length(FNsB) > length(FNsA),
|
|
|
|
true = length(FNsB) > length(FNsC),
|
2016-10-12 17:12:49 +01:00
|
|
|
|
2016-10-18 01:59:03 +01:00
|
|
|
{B1Size, B1Count} = testutil:check_bucket_stats(Bookie2, "Bucket1"),
|
2016-10-12 17:12:49 +01:00
|
|
|
true = B1Size > 0,
|
|
|
|
true = B1Count == 1,
|
2016-10-18 01:59:03 +01:00
|
|
|
{B1Size, B1Count} = testutil:check_bucket_stats(Bookie2, "Bucket1"),
|
|
|
|
{BSize, BCount} = testutil:check_bucket_stats(Bookie2, "Bucket"),
|
2016-10-12 17:12:49 +01:00
|
|
|
true = BSize > 0,
|
|
|
|
true = BCount == 140000,
|
|
|
|
|
2016-10-07 10:04:48 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:reset_filestructure().
|
2016-10-05 09:54:53 +01:00
|
|
|
|
|
|
|
|
2016-10-13 17:51:47 +01:00
|
|
|
load_and_count(_Config) ->
|
|
|
|
% Use artificially small files, and the load keys, counting they're all
|
|
|
|
% present
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-13 17:51:47 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath, max_journalsize=50000000},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-13 17:51:47 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-13 17:51:47 +01:00
|
|
|
io:format("Loading initial small objects~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
G1 = fun testutil:generate_smallobjects/2,
|
2016-10-13 17:51:47 +01:00
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
TestObject,
|
|
|
|
G1),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-13 17:51:47 +01:00
|
|
|
if
|
|
|
|
Acc + 5000 == Count ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
0,
|
|
|
|
lists:seq(1, 20)),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-13 17:51:47 +01:00
|
|
|
io:format("Loading larger compressible objects~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
G2 = fun testutil:generate_compressibleobjects/2,
|
2016-10-13 17:51:47 +01:00
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
TestObject,
|
|
|
|
G2),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-13 17:51:47 +01:00
|
|
|
if
|
|
|
|
Acc + 5000 == Count ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
100000,
|
|
|
|
lists:seq(1, 20)),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-13 17:51:47 +01:00
|
|
|
io:format("Replacing small objects~n"),
|
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
TestObject,
|
|
|
|
G1),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-13 17:51:47 +01:00
|
|
|
if
|
|
|
|
Count == 200000 ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
0,
|
|
|
|
lists:seq(1, 20)),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-13 17:51:47 +01:00
|
|
|
io:format("Loading more small objects~n"),
|
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
TestObject,
|
|
|
|
G2),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-13 17:51:47 +01:00
|
|
|
if
|
|
|
|
Acc + 5000 == Count ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
200000,
|
|
|
|
lists:seq(1, 20)),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-13 17:51:47 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{_, 300000} = testutil:check_bucket_stats(Bookie2, "Bucket"),
|
2016-10-13 17:51:47 +01:00
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:reset_filestructure().
|
2016-10-13 17:51:47 +01:00
|
|
|
|
2016-10-16 15:41:09 +01:00
|
|
|
load_and_count_withdelete(_Config) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
RootPath = testutil:reset_filestructure(),
|
2016-10-16 15:41:09 +01:00
|
|
|
StartOpts1 = #bookie_options{root_path=RootPath, max_journalsize=50000000},
|
|
|
|
{ok, Bookie1} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
{TestObject, TestSpec} = testutil:generate_testobject(),
|
2016-10-16 15:41:09 +01:00
|
|
|
ok = leveled_bookie:book_riakput(Bookie1, TestObject, TestSpec),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-16 15:41:09 +01:00
|
|
|
io:format("Loading initial small objects~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
G1 = fun testutil:generate_smallobjects/2,
|
2016-10-16 15:41:09 +01:00
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
TestObject,
|
|
|
|
G1),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-16 15:41:09 +01:00
|
|
|
if
|
|
|
|
Acc + 5000 == Count ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
0,
|
|
|
|
lists:seq(1, 20)),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_forobject(Bookie1, TestObject),
|
2016-10-16 15:41:09 +01:00
|
|
|
{BucketD, KeyD} = leveled_codec:riakto_keydetails(TestObject),
|
2016-10-18 01:59:03 +01:00
|
|
|
{_, 1} = testutil:check_bucket_stats(Bookie1, BucketD),
|
2016-10-16 15:41:09 +01:00
|
|
|
ok = leveled_bookie:book_riakdelete(Bookie1, BucketD, KeyD, []),
|
|
|
|
not_found = leveled_bookie:book_riakget(Bookie1, BucketD, KeyD),
|
2016-10-18 01:59:03 +01:00
|
|
|
{_, 0} = testutil:check_bucket_stats(Bookie1, BucketD),
|
2016-10-16 15:41:09 +01:00
|
|
|
io:format("Loading larger compressible objects~n"),
|
2016-10-18 01:59:03 +01:00
|
|
|
G2 = fun testutil:generate_compressibleobjects/2,
|
2016-10-16 15:41:09 +01:00
|
|
|
lists:foldl(fun(_X, Acc) ->
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:load_objects(5000,
|
|
|
|
[Acc + 2],
|
|
|
|
Bookie1,
|
|
|
|
no_check,
|
|
|
|
G2),
|
|
|
|
{_S, Count} = testutil:check_bucket_stats(Bookie1,
|
|
|
|
"Bucket"),
|
2016-10-16 15:41:09 +01:00
|
|
|
if
|
|
|
|
Acc + 5000 == Count ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
Acc + 5000 end,
|
|
|
|
100000,
|
|
|
|
lists:seq(1, 20)),
|
|
|
|
not_found = leveled_bookie:book_riakget(Bookie1, BucketD, KeyD),
|
|
|
|
ok = leveled_bookie:book_close(Bookie1),
|
|
|
|
{ok, Bookie2} = leveled_bookie:book_start(StartOpts1),
|
2016-10-18 01:59:03 +01:00
|
|
|
testutil:check_formissingobject(Bookie2, BucketD, KeyD),
|
|
|
|
{_BSize, 0} = testutil:check_bucket_stats(Bookie2, BucketD),
|
|
|
|
ok = leveled_bookie:book_close(Bookie2),
|
|
|
|
testutil:reset_filestructure().
|
2016-10-03 23:34:28 +01:00
|
|
|
|