Skip to content
This repository
Browse code

Merge branch 'rz-fix-core-vnode-eqc'

  • Loading branch information...
commit 46ace520a26447bb4264cb7a035ab09582bffb0f 2 parents c2cea55 + c457620
Jon Meredith authored June 25, 2012

Showing 1 changed file with 25 additions and 6 deletions. Show diff stats Hide diff stats

  1. 31  test/core_vnode_eqc.erl
31  test/core_vnode_eqc.erl
@@ -30,6 +30,12 @@
30 30
 -include_lib("riak_core_vnode.hrl").
31 31
 -compile([export_all]).
32 32
 
  33
+-define(POST_COND(PC, ErrTuple),
  34
+        case PC of
  35
+            true -> true;
  36
+            false -> ErrTuple
  37
+        end).
  38
+
33 39
 -define(QC_OUT(P),
34 40
         eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).
35 41
 
@@ -56,7 +62,10 @@ simple_test_() ->
56 62
 setup_simple() ->
57 63
     Vars = [{ring_creation_size, 8},
58 64
             {ring_state_dir, "<nostore>"},
59  
-            {cluster_name, "test"}],
  65
+            {cluster_name, "test"},
  66
+            %% Don't allow rolling start of vnodes as it will cause a
  67
+            %% race condition with `all_nodes'.
  68
+            {vnode_rolling_start, 0}],
60 69
     OldVars = [begin
61 70
                    Old = app_helper:get_env(riak_core, AppKey),
62 71
                    ok = application:set_env(riak_core, AppKey, Val),
@@ -224,25 +233,35 @@ precondition(_From,_To,_S,_C) ->
224 233
 
225 234
 postcondition(_From,_To,_S,
226 235
               {call,mock_vnode,get_index,[{Index,_Node}]},{ok,ReplyIndex}) ->
227  
-    Index =:= ReplyIndex;
  236
+    ?POST_COND(Index =:= ReplyIndex, {get_index, Index, ReplyIndex});
  237
+
228 238
 postcondition(_From,_To,#qcst{crash_reasons=CRs},
229 239
               {call,mock_vnode,get_crash_reason,[{Index,_Node}]},{ok, Reason}) ->
230 240
     %% there is the potential for a race here if get_crash_reason is called
231 241
     %% before the EXIT signal is sent to the vnode, but it didn't appear 
232 242
     %% even with 1k tests - just a note in case a heisenbug rears its head
233 243
     %% on some future, less deterministic day.
234  
-    orddict:fetch(Index, CRs) =:= Reason;
  244
+    Expected = orddict:fetch(Index, CRs),
  245
+    ?POST_COND(Expected =:= Reason, {get_crash_reason, Expected, Reason});
  246
+
235 247
 postcondition(_From,_To,#qcst{counters=Counters},
236 248
               {call,mock_vnode,get_counter,[{Index,_Node}]},{ok,ReplyCount}) ->
237  
-    orddict:fetch(Index, Counters) =:= ReplyCount;
  249
+    Expected = orddict:fetch(Index, Counters),
  250
+    ?POST_COND(Expected=:= ReplyCount, {get_counter, Expected, ReplyCount});
  251
+
238 252
 postcondition(_From,_To,_S,
239 253
               {call,_Mod,Func,[]},Result)
240 254
   when Func =:= neverreply; Func =:= returnreply; Func =:= latereply ->
241  
-    Result =:= ok;
  255
+    Expected = ok,
  256
+    ?POST_COND(Expected == Result, {Func, Expected, Result});
  257
+
242 258
 postcondition(_From,_To,_S,
243 259
               {call,riak_core_vnode_master,all_nodes,[mock_vnode]},Result) ->
244 260
     Pids = [Pid || {_,Pid,_,_} <- supervisor:which_children(riak_core_vnode_sup)],
245  
-    lists:sort(Result) =:= lists:sort(Pids);
  261
+    Expected = lists:sort(Pids),
  262
+    Result2 = lists:sort(Result),
  263
+    ?POST_COND(Expected == Result2, {all_nodes, Expected, Result2});
  264
+
246 265
 postcondition(_From,_To,_S,_C,_R) ->
247 266
     true.
248 267
 

0 notes on commit 46ace52

Please sign in to comment.
Something went wrong with that request. Please try again.