Skip to content

Commit

Permalink
Merge pull request #2947 from esl/ci/fix_nksip_timeouts
Browse files Browse the repository at this point in the history
Load nksip in parallel with big timeouts
  • Loading branch information
chrzaszcz committed Nov 23, 2020
2 parents 20e284d + 5f8b232 commit 2be82de
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion big_tests/tests/dynamic_modules.erl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ start(#{node := Node}, Domain, Mod, Args) ->
start(Node, Domain, Mod, Args);
start(Node, Domain, Mod, Args) ->
Cookie = escalus_ct:get_config(ejabberd_cookie),
case escalus_rpc:call(Node, gen_mod, start_module, [Domain, Mod, Args], 15000, Cookie) of
case escalus_rpc:call(Node, gen_mod, start_module, [Domain, Mod, Args], 5000, Cookie) of
{badrpc, Reason} ->
ct:fail("Cannot start module ~p reason ~p", [Mod, Reason]);
R -> R
Expand Down
40 changes: 30 additions & 10 deletions big_tests/tests/jingle_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,8 @@ suite() ->
init_per_suite(Config) ->
case rpc(mim(), application, get_application, [nksip]) of
{ok, nksip} ->
Port = 12345,
Host = ct:get_config({hosts, mim, domain}),
distributed_helper:add_node_to_cluster(mim2(), Config),
dynamic_modules:start(mim(), Host, mod_jingle_sip, [{proxy_host, "localhost"},
{proxy_port, Port},
{username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}]),
dynamic_modules:start(mim2(), Host, mod_jingle_sip, [{proxy_host, "localhost"},
{proxy_port, Port},
{listen_port, 12346},
{username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}]),

start_nksip_in_mim_nodes(),
application:ensure_all_started(esip),
spawn(fun() -> ets:new(jingle_sip_translator, [public, named_table]),
ets:new(jingle_sip_translator_bindings, [public, named_table]),
Expand All @@ -78,6 +69,35 @@ init_per_suite(Config) ->
{skip, build_was_not_configured_with_jingle_sip}
end.

start_nksip_in_mim_nodes() ->
Pid1 = start_nskip_in_parallel(mim(), []),
Pid2 = start_nskip_in_parallel(mim2(), [{listen_port, 12346}]),
wait_for_process_to_stop(Pid1),
wait_for_process_to_stop(Pid2).

wait_for_process_to_stop(Pid) ->
erlang:monitor(process, Pid),
receive
{'DOWN', _, process, Pid, _} -> ok
after timer:seconds(60) ->
ct:fail(wait_for_process_to_stop_timeout)
end.

start_nskip_in_parallel(RPCSpec, ExtraOpts) ->
Host = ct:get_config({hosts, mim, domain}),
proc_lib:spawn_link(
fun() ->
{ok, _} = rpc(RPCSpec#{timeout => timer:seconds(60)}, gen_mod, start_module,
[
Host, mod_jingle_sip,
[{proxy_host, "localhost"},
{proxy_port, 12345},
{username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}
| ExtraOpts]
])
end).


end_per_suite(Config) ->
escalus_fresh:clean(),
Host = ct:get_config({hosts, mim, domain}),
Expand Down

0 comments on commit 2be82de

Please sign in to comment.