aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/test/mnesia_examples_test.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2013-02-28 13:23:18 +0100
committerDan Gudmundsson <[email protected]>2013-02-28 14:46:41 +0100
commit2be428f334536eab8768a130d309bf063b3f2aa4 (patch)
tree60e30b26f7da3b7a775a878a9a664ade8950ddc8 /lib/mnesia/test/mnesia_examples_test.erl
parent4a69eb28601d9f1e2e1b129a84f13eeb4aabe89d (diff)
downloadotp-2be428f334536eab8768a130d309bf063b3f2aa4.tar.gz
otp-2be428f334536eab8768a130d309bf063b3f2aa4.tar.bz2
otp-2be428f334536eab8768a130d309bf063b3f2aa4.zip
mnesia: Decrease test times
Diffstat (limited to 'lib/mnesia/test/mnesia_examples_test.erl')
-rw-r--r--lib/mnesia/test/mnesia_examples_test.erl77
1 files changed, 42 insertions, 35 deletions
diff --git a/lib/mnesia/test/mnesia_examples_test.erl b/lib/mnesia/test/mnesia_examples_test.erl
index 373d47a05a..219f358fdb 100644
--- a/lib/mnesia/test/mnesia_examples_test.erl
+++ b/lib/mnesia/test/mnesia_examples_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -34,32 +34,6 @@ end_per_testcase(Func, Conf) ->
delete_schema],
N, Config, ?FILE, ?LINE)).
-opt_net_load(ExampleMod) ->
- opt_net_load([node() | nodes()], ExampleMod, ok).
-
-opt_net_load([Node | Nodes], ExampleMod, Res) ->
- case rpc:call(Node, ?MODULE, opt_load, [ExampleMod]) of
- {module, ExampleMod} ->
- opt_net_load(Nodes, ExampleMod, Res);
- {error, Reason} ->
- Error = {opt_net_load, ExampleMod, Node, Reason},
- opt_net_load(Nodes, ExampleMod, {error, Error});
- {badrpc, Reason} ->
- Error = {opt_net_load, ExampleMod, Node, Reason},
- opt_net_load(Nodes, ExampleMod, {error, Error})
- end;
-opt_net_load([], _ExampleMod, Res) ->
- Res.
-
-opt_load(Mod) ->
- case code:is_loaded(Mod) of
- {file, _} ->
- {module, Mod};
- false ->
- Abs = filename:join([code:lib_dir(mnesia), examples, Mod]),
- code:load_abs(Abs)
- end.
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
all() ->
[bup, company, meter, {group, tpcb}].
@@ -95,49 +69,49 @@ replica_test(suite) -> [];
replica_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(replica_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(replica_test, ram_copies))).
sticky_replica_test(suite) -> [];
sticky_replica_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(sticky_replica_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(sticky_replica_test, ram_copies))).
dist_test(suite) -> [];
dist_test(Config) when is_list(Config) ->
?init(3, [{tc_timeout, timer:minutes(10)} | Config]),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(dist_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(dist_test, ram_copies))).
conflict_test(suite) -> [];
conflict_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(conflict_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(conflict_test, ram_copies))).
frag_test(suite) -> [];
frag_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(frag_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(frag_test, ram_copies))).
frag2_test(suite) -> [];
frag2_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(frag2_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(frag2_test, ram_copies))).
remote_test(suite) -> [];
remote_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(remote_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(remote_test, ram_copies))).
remote_frag2_test(suite) -> [];
remote_frag2_test(Config) when is_list(Config) ->
?init(3, Config),
opt_net_load(mnesia_tpcb),
- ?match({ok, _}, mnesia_tpcb:start(mnesia_tpcb:config(remote_frag2_test, ram_copies))).
+ ?match({ok, _}, mnesia_tpcb:start(config(remote_frag2_test, ram_copies))).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
meter(doc) ->
@@ -149,4 +123,37 @@ meter(Config) when is_list(Config) ->
opt_net_load(mnesia_meter),
?match(ok, mnesia_meter:go(ram_copies, [N])).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+config(Test, Type) ->
+ Config0 = mnesia_tpcb:config(Test, Type),
+ %% Cut the times, the idea is to test the example and configuration
+ %% not running the test a long time
+ Config1 = lists:keyreplace(stop_after, 1, Config0, {stop_after, 6000}),
+ lists:keyreplace(report_interval, 1, Config1, {report_interval, 1000}).
+
+opt_net_load(ExampleMod) ->
+ opt_net_load([node() | nodes()], ExampleMod, ok).
+
+opt_net_load([Node | Nodes], ExampleMod, Res) ->
+ case rpc:call(Node, ?MODULE, opt_load, [ExampleMod]) of
+ {module, ExampleMod} ->
+ opt_net_load(Nodes, ExampleMod, Res);
+ {error, Reason} ->
+ Error = {opt_net_load, ExampleMod, Node, Reason},
+ opt_net_load(Nodes, ExampleMod, {error, Error});
+ {badrpc, Reason} ->
+ Error = {opt_net_load, ExampleMod, Node, Reason},
+ opt_net_load(Nodes, ExampleMod, {error, Error})
+ end;
+opt_net_load([], _ExampleMod, Res) ->
+ Res.
+opt_load(Mod) ->
+ case code:is_loaded(Mod) of
+ {file, _} ->
+ {module, Mod};
+ false ->
+ Abs = filename:join([code:lib_dir(mnesia), examples, Mod]),
+ code:load_abs(Abs)
+ end.