From 4e6c22d7e67cb6ca93e545ae8e67162c953dd87b Mon Sep 17 00:00:00 2001 From: martinsumner Date: Sun, 26 Feb 2017 21:48:04 +0000 Subject: [PATCH] Dumb test Can't test for slow not_present outside of simple unit test ... will be very rare event --- src/leveled_penciller.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/leveled_penciller.erl b/src/leveled_penciller.erl index 312f866..ef3799c 100644 --- a/src/leveled_penciller.erl +++ b/src/leveled_penciller.erl @@ -797,8 +797,11 @@ timed_sst_get(PID, Key, Hash) -> SW = os:timestamp(), R = leveled_sst:sst_get(PID, Key, Hash), T0 = timer:now_diff(os:timestamp(), SW), + log_slowfetch(T0, R, PID, ?SLOW_FETCH). + +log_slowfetch(T0, R, PID, FetchTolerance) -> case {T0, R} of - {T, R} when T < ?SLOW_FETCH -> + {T, R} when T < FetchTolerance -> R; {T, not_present} -> leveled_log:log("PC016", [PID, T, not_present]), @@ -807,7 +810,6 @@ timed_sst_get(PID, Key, Hash) -> leveled_log:log("PC016", [PID, T, found]), R end. - compare_to_sqn(Obj, SQN) -> case Obj of @@ -1418,6 +1420,9 @@ create_file_test() -> {ok, Bin} = file:read_file("../test/new_file.sst.discarded"), ?assertMatch("hello", binary_to_term(Bin)). +slow_fetch_test() -> + ?assertMatch(not_present, log_slowfetch(2, not_present, "fake", 1)). + checkready(Pid) -> try leveled_sst:sst_checkready(Pid)