Permalink
Browse files

Merge branch 'slf-bitcask_qc_expiry-intermittent-failures'

  • Loading branch information...
2 parents f6736fe + b4e8910 commit 342958ce84bf7331a24b09346053fdce642fa47c @slfritchie slfritchie committed Mar 28, 2013
Showing with 23 additions and 16 deletions.
  1. +6 −5 test/bitcask_qc.erl
  2. +17 −11 test/bitcask_qc_expiry.erl
View
@@ -31,14 +31,15 @@
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
+-define(TEST_TIME, 30). % seconds
-record(m_fstats, {key_bytes=0, live_keys=0, live_bytes=0, total_keys=0, total_bytes=0}).
qc(P) ->
- qc(P, 100).
+ qc(P, ?TEST_TIME).
-qc(P, NumTests) ->
- ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
+qc(P, TestTime) ->
+ ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
keys() ->
eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -263,7 +264,7 @@ prop_fold() ->
prop_merge_test_() ->
- {timeout, 300*60, fun() -> qc(prop_merge()) end}.
+ {timeout, ?TEST_TIME*2, fun() -> qc(prop_merge()) end}.
merge1_test() ->
?assert(eqc:check(prop_merge(),
@@ -281,7 +282,7 @@ merge3_test() ->
1,1}])).
prop_fold_test_() ->
- {timeout, 300*60, fun() -> qc(prop_fold()) end}.
+ {timeout, ?TEST_TIME*2, fun() -> qc(prop_fold()) end}.
get_keydir(Ref) ->
@@ -31,12 +31,13 @@
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
+-define(TEST_TIME, 30). % seconds
qc(P) ->
- qc(P, 100).
+ qc(P, ?TEST_TIME).
-qc(P, NumTests) ->
- ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
+qc(P, TestTime) ->
+ ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
keys() ->
eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -89,6 +90,7 @@ prop_expiry() ->
?FORALL({Ops, Expiry, ExpiryGrace, Timestep, M1},
{eqc_gen:non_empty(list(ops(Keys, Values))),
choose(1,10), choose(1, 10), choose(5, 50), choose(5,128)},
+ ?IMPLIES(length(Ops) > 1,
begin
Dirname = "/tmp/bc.prop.expiry",
?cmd("rm -rf " ++ Dirname),
@@ -130,24 +132,28 @@ prop_expiry() ->
%% Check that needs_merge has expected result
case Expired of
[] ->
- ?assertEqual(false, bitcask:needs_merge(Bref));
+ ?assertEqual(false, bitcask:needs_merge(Bref)),
+ true;
_ ->
- ?assertMatch({true, _}, bitcask:needs_merge(Bref))
+ ?assertMatch({true, _}, bitcask:needs_merge(Bref)),
+ true
end
- catch X:Y -> io:format(user, "exception: ~p ~p @ ~p\n", [X,Y, erlang:get_stacktrace()])
+ catch
+ X:Y ->
+ io:format(user, "exception: ~p ~p @ ~p\n",
+ [X,Y, erlang:get_stacktrace()])
after
bitcask:close(Bref)
- end,
- true
- end)).
+ end
+ end))).
prop_expiry_test_() ->
- {timeout, 300*60, fun() ->
+ {timeout, ?TEST_TIME*2, fun() ->
try
meck:new(bitcask_time, [passthrough]),
meck:expect(bitcask_time, tstamp, fun next_tstamp/0),
- qc(prop_expiry(), 500)
+ qc(prop_expiry())
after
meck:unload()
end

0 comments on commit 342958c

Please sign in to comment.