Skip to content
This repository

Add ?IMPLIES(length(Ops) > 1, ...) to avoid legit model ambiguity #80

Merged
merged 2 commits into from over 1 year ago

1 participant

Scott Lystig Fritchie
Scott Lystig Fritchie
Owner

... in cases where the op list is too short to make a reasonable &
correct guess of behavior.

Use eqc:testing_time/2 for test length & EUnit timeout at 2x
testing time.

slfritchie added some commits
Scott Lystig Fritchie slfritchie Add ?IMPLIES(length(Ops) > 1, ...) to avoid legit model ambiguity
in cases where the op list is too short to make a reasonable &
correct guess of behavior.

Use eqc:testing_time/2 for test length & EUnit timeout at 2x
testing time.
a275a09
Scott Lystig Fritchie slfritchie Don't always return 'true', and re-indent the catch clause b4e8910
Scott Lystig Fritchie
Owner

@gburd Opinions?

Scott Lystig Fritchie slfritchie merged commit b4e8910 into from
Engel A. Sanchez engelsanchez deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Mar 05, 2013
Scott Lystig Fritchie slfritchie Add ?IMPLIES(length(Ops) > 1, ...) to avoid legit model ambiguity
in cases where the op list is too short to make a reasonable &
correct guess of behavior.

Use eqc:testing_time/2 for test length & EUnit timeout at 2x
testing time.
a275a09
Scott Lystig Fritchie slfritchie Don't always return 'true', and re-indent the catch clause b4e8910
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 23 additions and 16 deletions. Show diff stats Hide diff stats

  1. +6 5 test/bitcask_qc.erl
  2. +17 11 test/bitcask_qc_expiry.erl
11 test/bitcask_qc.erl
@@ -31,14 +31,15 @@
31 31
32 32 -define(QC_OUT(P),
33 33 eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
  34 +-define(TEST_TIME, 30). % seconds
34 35
35 36 -record(m_fstats, {key_bytes=0, live_keys=0, live_bytes=0, total_keys=0, total_bytes=0}).
36 37
37 38 qc(P) ->
38   - qc(P, 100).
  39 + qc(P, ?TEST_TIME).
39 40
40   -qc(P, NumTests) ->
41   - ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
  41 +qc(P, TestTime) ->
  42 + ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
42 43
43 44 keys() ->
44 45 eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -263,7 +264,7 @@ prop_fold() ->
263 264
264 265
265 266 prop_merge_test_() ->
266   - {timeout, 300*60, fun() -> qc(prop_merge()) end}.
  267 + {timeout, ?TEST_TIME*2, fun() -> qc(prop_merge()) end}.
267 268
268 269 merge1_test() ->
269 270 ?assert(eqc:check(prop_merge(),
@@ -281,7 +282,7 @@ merge3_test() ->
281 282 1,1}])).
282 283
283 284 prop_fold_test_() ->
284   - {timeout, 300*60, fun() -> qc(prop_fold()) end}.
  285 + {timeout, ?TEST_TIME*2, fun() -> qc(prop_fold()) end}.
285 286
286 287
287 288 get_keydir(Ref) ->
28 test/bitcask_qc_expiry.erl
@@ -31,12 +31,13 @@
31 31
32 32 -define(QC_OUT(P),
33 33 eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
  34 +-define(TEST_TIME, 30). % seconds
34 35
35 36 qc(P) ->
36   - qc(P, 100).
  37 + qc(P, ?TEST_TIME).
37 38
38   -qc(P, NumTests) ->
39   - ?assert(eqc:quickcheck(?QC_OUT(eqc:numtests(NumTests, P)))).
  39 +qc(P, TestTime) ->
  40 + ?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(TestTime, P)))).
40 41
41 42 keys() ->
42 43 eqc_gen:non_empty(list(eqc_gen:non_empty(binary()))).
@@ -89,6 +90,7 @@ prop_expiry() ->
89 90 ?FORALL({Ops, Expiry, ExpiryGrace, Timestep, M1},
90 91 {eqc_gen:non_empty(list(ops(Keys, Values))),
91 92 choose(1,10), choose(1, 10), choose(5, 50), choose(5,128)},
  93 + ?IMPLIES(length(Ops) > 1,
92 94 begin
93 95 Dirname = "/tmp/bc.prop.expiry",
94 96 ?cmd("rm -rf " ++ Dirname),
@@ -130,24 +132,28 @@ prop_expiry() ->
130 132 %% Check that needs_merge has expected result
131 133 case Expired of
132 134 [] ->
133   - ?assertEqual(false, bitcask:needs_merge(Bref));
  135 + ?assertEqual(false, bitcask:needs_merge(Bref)),
  136 + true;
134 137 _ ->
135   - ?assertMatch({true, _}, bitcask:needs_merge(Bref))
  138 + ?assertMatch({true, _}, bitcask:needs_merge(Bref)),
  139 + true
136 140 end
137   - catch X:Y -> io:format(user, "exception: ~p ~p @ ~p\n", [X,Y, erlang:get_stacktrace()])
  141 + catch
  142 + X:Y ->
  143 + io:format(user, "exception: ~p ~p @ ~p\n",
  144 + [X,Y, erlang:get_stacktrace()])
138 145 after
139 146 bitcask:close(Bref)
140   - end,
141   - true
142   - end)).
  147 + end
  148 + end))).
143 149
144 150
145 151 prop_expiry_test_() ->
146   - {timeout, 300*60, fun() ->
  152 + {timeout, ?TEST_TIME*2, fun() ->
147 153 try
148 154 meck:new(bitcask_time, [passthrough]),
149 155 meck:expect(bitcask_time, tstamp, fun next_tstamp/0),
150   - qc(prop_expiry(), 500)
  156 + qc(prop_expiry())
151 157 after
152 158 meck:unload()
153 159 end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.