Skip to content

Commit

Permalink
[megaco|test] Made the mib sub-suite its own test suite
Browse files Browse the repository at this point in the history
Moved the mib sub-suite out of the "main" test suite
into its own test suite.

OTP-16158
  • Loading branch information
bmk committed Dec 10, 2019
1 parent 88d9748 commit 3a85ae0
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 41 deletions.
5 changes: 0 additions & 5 deletions lib/megaco/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,6 @@ trans: make
-s megaco_test_lib t megaco_trans_test \
$(MAYBE_ESTOP)

mib: make
$(MERL) $(ARGS) -sname megaco_mib $(ERL_PATH) \
-s megaco_test_lib t megaco_mib_test \
$(MAYBE_ESTOP)

mreq: make
$(MERL) $(ARGS) -sname megaco_mreq $(ERL_PATH) \
-s megaco_test_lib t megaco_mreq_test \
Expand Down
2 changes: 0 additions & 2 deletions lib/megaco/test/megaco_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ suite() -> [{ct_hooks, [{ts_install_cth, [{nodenames,1}]}]}].
all() ->
[
{group, codec},
{group, mib},
{group, trans},
{group, actions},
{group, load},
Expand All @@ -79,7 +78,6 @@ all() ->
groups() ->
[
{codec, [], [{megaco_codec_test, all}]},
{mib, [], [{megaco_mib_test, all}]},
{trans, [], [{megaco_trans_test, all}]},
{actions, [], [{megaco_actions_test, all}]},
{load, [], [{megaco_load_test, all}]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@
%%----------------------------------------------------------------------
%% Purpose: Verify the application specifics of the Megaco application
%%----------------------------------------------------------------------
-module(megaco_mib_test).

-export([
t/0, t/1,
-module(megaco_mib_SUITE).

all/0,
groups/0,
init_per_testcase/2,
end_per_testcase/2,
init_per_group/2,
end_per_group/2,
-export([
suite/0, all/0, groups/0,
init_per_suite/1, end_per_suite/1,
init_per_group/2, end_per_group/2,
init_per_testcase/2, end_per_testcase/2,

plain/1,
connect/1,
Expand All @@ -51,9 +48,9 @@
handle_trans_ack/5
]).

-include("megaco_test_lib.hrl").
-include_lib("megaco/include/megaco.hrl").
-include_lib("megaco/include/megaco_message_v1.hrl").
-include("megaco_test_lib.hrl").

-define(TEST_VERBOSITY, info). % silence | info | debug
-define(MGC_VERBOSITY, info).
Expand All @@ -73,14 +70,98 @@
state = initiated,
load_counter = 0}).

t() -> megaco_test_lib:t(?MODULE).
t(Case) -> megaco_test_lib:t({?MODULE, Case}).

%%======================================================================
%% Common Test interface functions
%%======================================================================

suite() ->
[{ct_hooks, [ts_install_cth]}].

all() ->
[
plain,
connect,
traffic
].

groups() ->
[].



%%
%% -----
%%

init_per_suite(suite) ->
[];
init_per_suite(doc) ->
[];
init_per_suite(Config0) when is_list(Config0) ->

?ANNOUNCE_SUITE_INIT(),

p("init_per_suite -> entry with"
"~n Config: ~p"
"~n Nodes: ~p", [Config0, erlang:nodes()]),

case ?LIB:init_per_suite(Config0) of
{skip, _} = SKIP ->
SKIP;

Config1 when is_list(Config1) ->

%% We need a (local) monitor on this node also
megaco_test_sys_monitor:start(),

p("init_per_suite -> end when"
"~n Config: ~p"
"~n Nodes: ~p", [Config1, erlang:nodes()]),

Config1
end.

end_per_suite(suite) -> [];
end_per_suite(doc) -> [];
end_per_suite(Config0) when is_list(Config0) ->

p("end_per_suite -> entry with"
"~n Config: ~p"
"~n Nodes: ~p", [Config0, erlang:nodes()]),

megaco_test_sys_monitor:stop(),
Config1 = ?LIB:end_per_suite(Config0),

p("end_per_suite -> end when"
"~n Nodes: ~p", [erlang:nodes()]),

Config1.


%%
%% -----
%%

init_per_group(_GroupName, Config) ->
Config.

end_per_group(_GroupName, Config) ->
Config.



%%
%% -----
%%

%% Test server callbacks
init_per_testcase(Case, Config) ->
progress("init_per_testcase -> ~w", [Case]),
process_flag(trap_exit, true),

progress("init_per_testcase -> ~w", [Case]),

megaco_test_global_sys_monitor:reset_events(),

case Case of
traffic ->
Conf0 = lists:keydelete(tc_timeout, 1, Config),
Expand All @@ -91,24 +172,14 @@ init_per_testcase(Case, Config) ->
end.

end_per_testcase(Case, Config) ->
progress("end_per_testcase -> ~w", [Case]),
process_flag(trap_exit, false),
megaco_test_lib:end_per_testcase(Case, Config).

progress("end_per_testcase -> ~w", [Case]),

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p("system events during test: "
"~n ~p", [megaco_test_global_sys_monitor:events()]),

all() ->
[plain, connect, traffic].

groups() ->
[].

init_per_group(_GroupName, Config) ->
Config.

end_per_group(_GroupName, Config) ->
Config.
megaco_test_lib:end_per_testcase(Case, Config).



Expand Down Expand Up @@ -232,8 +303,7 @@ connect(Config) when is_list(Config) ->
"~n MgcNode: ~p"
"~n Mg1Node: ~p"
"~n Mg2Node: ~p", [MgcNode, Mg1Node, Mg2Node]),
ok = megaco_test_lib:start_nodes([MgcNode, Mg1Node, Mg2Node],
?FILE, ?LINE),
ok = ?START_NODES([MgcNode, Mg1Node, Mg2Node]),

%% Start the MGC and MGs
ET = [{text,tcp}, {text,udp}, {binary,tcp}, {binary,udp}],
Expand Down Expand Up @@ -343,9 +413,7 @@ traffic(Config) when is_list(Config) ->
"~n Mg3Node: ~p"
"~n Mg4Node: ~p",
[MgcNode, Mg1Node, Mg2Node, Mg3Node, Mg4Node]),
ok = megaco_test_lib:start_nodes([MgcNode,
Mg1Node, Mg2Node, Mg3Node, Mg4Node],
?FILE, ?LINE),
ok = ?START_NODES([MgcNode, Mg1Node, Mg2Node, Mg3Node, Mg4Node]),

%% Start the MGC and MGs
i("traffic -> start the MGC"),
Expand Down Expand Up @@ -1682,6 +1750,22 @@ which_local_addr2([_|T]) ->

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% p(F) ->
%% p(F, []).

p(F, A) ->
p(get(sname), F, A).

p(S, F, A) when is_list(S) ->
io:format("*** [~s] ~p ~s ***"
"~n " ++ F ++ "~n",
[?FTS(), self(), S | A]);
p(_S, F, A) ->
io:format("*** [~s] ~p *** "
"~n " ++ F ++ "~n",
[?FTS(), self() | A]).


i(F) ->
i(F, []).

Expand Down
2 changes: 1 addition & 1 deletion lib/megaco/test/modules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ TEST_UTIL_MODULES = \
megaco_load_test \
megaco_mess_user_test \
megaco_mess_otp8212_test \
megaco_mib_test \
megaco_mreq_test \
megaco_pending_limit_test \
megaco_profile \
Expand Down Expand Up @@ -76,6 +75,7 @@ SUITE_MODULES = \
megaco_examples_SUITE \
megaco_flex_SUITE \
megaco_mess_SUITE \
megaco_mib_SUITE \
megaco_sdp_SUITE \
megaco_tcp_SUITE \
megaco_udp_SUITE
Expand Down

0 comments on commit 3a85ae0

Please sign in to comment.