Permalink
Browse files

Adding parallel property-based tests

Sadly the parallel tests require to lower the number of resources
to one given the non-determinism of the default behaviour appears
to conflict with the interleaving attempts of PropEr.

Mocking the dispatch_id function of dispcount_watcher appeared
to have little effect. The test is a best-effort for now;
better than nothing, although not perfect.
  • Loading branch information...
1 parent b9cd1bd commit a4e50766ccb09757999871f7b9cf631b5e610e46 @ferd committed Apr 2, 2012
Showing with 24 additions and 4 deletions.
  1. +2 −3 rebar.config
  2. +22 −1 test/dispcount_prop.erl
View
@@ -12,7 +12,7 @@
%% Erlang compiler options
{erl_first_files, ["dispcount"]}.
-{erl_opts, [debug_info, {i, "include"}, {d,'DEBUG'}]}.
+{erl_opts, [debug_info, {i, "include"}]}.
%% == Common Test ==
@@ -29,6 +29,5 @@
%% an application name, a version and the SCM details on how to fetch it (SCM
%% type, location and revision). Rebar currently supports git, hg, bzr and svn.
{deps, [
- {proper, "1.0", {git, "https://github.com/manopapad/proper.git", "master"}},
- {meck, "0.7.1", {git, "https://github.com/eproxus/meck.git", "master"}}
+ {proper, "1.0", {git, "https://github.com/manopapad/proper.git", "master"}}
]}.
View
@@ -68,13 +68,34 @@ prop_nocrash() ->
{?NAME, [Tid]},
[{restart,permanent},{shutdown,4000},
{maxr,10},{maxt,60},{resources,10}]),
- {H,S,R} = run_commands(?MODULE, Cmds),
+ {H,_S,R} = run_commands(?MODULE, Cmds),
ets:delete(Tid),
?WHENFAIL(io:format("History: ~p~n",[{Cmds,H}]),
aggregate(command_names(Cmds),
R =:= ok))
end).
+prop_parallel_nocrash() ->
+ ?FORALL(Cmds, parallel_commands(?MODULE, #state{}),
+ begin
+ %% the ETS table works with the dispcount dispatcher
+ %% in this test to assign increasing IDs to each dispatch_watcher
+ %% instance.
+ Tid = ets:new(ids, [public,set]),
+ ets:insert(Tid, {id,0}),
+ application:stop(dispcount),
+ application:start(dispcount),
+ ok = ?SERVER:start_dispatch(?NAME,
+ {?NAME, [Tid]},
+ [{restart,permanent},{shutdown,4000},
+ {maxr,10},{maxt,60},{resources,1}]),
+ {H,P,R} = run_parallel_commands(?MODULE, Cmds),
+ ets:delete(Tid),
+ ?WHENFAIL(io:format("Cmds:~p~nP:~p~nH:~p~nR:~p~n",[Cmds,P,H,R]),
+ R =:= ok)
+ end).
+
+
%% Simple wrapper to work around limitations of statem stuff.
%% busy_checkin is basically a hack to circumvent the idea that the
%% previous result was a busy thing and we discard it through this function

0 comments on commit a4e5076

Please sign in to comment.