From eb83da2e3b8a2b1bfb29c029c65cc0d74bcfd036 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 18 Nov 2020 11:12:45 +0100 Subject: [PATCH 1/2] Load nksip in parallel with big timeouts Also revert commit 79f5ff0db100a77814e962a0e21b5d9464634e72. "Extend timeout to start modules, nksip is slow" --- big_tests/tests/dynamic_modules.erl | 2 +- big_tests/tests/jingle_SUITE.erl | 51 +++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/big_tests/tests/dynamic_modules.erl b/big_tests/tests/dynamic_modules.erl index f94794f729d..a6167cf477c 100644 --- a/big_tests/tests/dynamic_modules.erl +++ b/big_tests/tests/dynamic_modules.erl @@ -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 diff --git a/big_tests/tests/jingle_SUITE.erl b/big_tests/tests/jingle_SUITE.erl index 574ab2937eb..448763ea7a6 100644 --- a/big_tests/tests/jingle_SUITE.erl +++ b/big_tests/tests/jingle_SUITE.erl @@ -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]), @@ -78,6 +69,46 @@ init_per_suite(Config) -> {skip, build_was_not_configured_with_jingle_sip} end. +start_nksip_in_mim_nodes() -> + Port = 12345, + Host = ct:get_config({hosts, mim, domain}), + RPCSpec1 = mim(), + RPCSpec2 = mim2(), + Timeout = timer:seconds(60), + + Pid1 = proc_lib:spawn_link( + fun() -> + {ok, _} = rpc(RPCSpec1#{timeout => Timeout}, gen_mod, start_module, + [ + Host, mod_jingle_sip, + [{proxy_host, "localhost"}, + {proxy_port, Port}, + {username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}] + ]) + end), + Pid2 = proc_lib:spawn_link( + fun() -> + {ok, _} = rpc(RPCSpec2#{timeout => Timeout}, gen_mod, start_module, + [ + Host, mod_jingle_sip, + [{proxy_host, "localhost"}, + {proxy_port, Port}, + {listen_port, 12346}, + {username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}] + ]) + end), + %% then + wait_for_process_to_stop(Pid1, Timeout), + wait_for_process_to_stop(Pid2, Timeout). + +wait_for_process_to_stop(Pid, Timeout) -> + erlang:monitor(process, Pid), + receive + {'DOWN', _, process, Pid, _} -> ok + after Timeout -> + ct:fail(wait_for_process_to_stop_timeout) + end. + end_per_suite(Config) -> escalus_fresh:clean(), Host = ct:get_config({hosts, mim, domain}), From 5f8b2324f6644c68b71ae185f297d2be9fc29e31 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 20 Nov 2020 14:27:23 +0100 Subject: [PATCH 2/2] Apply code review, simplifying code --- big_tests/tests/jingle_SUITE.erl | 55 +++++++++++++------------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/big_tests/tests/jingle_SUITE.erl b/big_tests/tests/jingle_SUITE.erl index 448763ea7a6..9262496fe4a 100644 --- a/big_tests/tests/jingle_SUITE.erl +++ b/big_tests/tests/jingle_SUITE.erl @@ -70,45 +70,34 @@ init_per_suite(Config) -> end. start_nksip_in_mim_nodes() -> - Port = 12345, - Host = ct:get_config({hosts, mim, domain}), - RPCSpec1 = mim(), - RPCSpec2 = mim2(), - Timeout = timer:seconds(60), - - Pid1 = proc_lib:spawn_link( - fun() -> - {ok, _} = rpc(RPCSpec1#{timeout => Timeout}, gen_mod, start_module, - [ - Host, mod_jingle_sip, - [{proxy_host, "localhost"}, - {proxy_port, Port}, - {username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}] - ]) - end), - Pid2 = proc_lib:spawn_link( - fun() -> - {ok, _} = rpc(RPCSpec2#{timeout => Timeout}, gen_mod, start_module, - [ - Host, mod_jingle_sip, - [{proxy_host, "localhost"}, - {proxy_port, Port}, - {listen_port, 12346}, - {username_to_phone,[{<<"2000006168">>, <<"+919177074440">>}]}] - ]) - end), - %% then - wait_for_process_to_stop(Pid1, Timeout), - wait_for_process_to_stop(Pid2, Timeout). - -wait_for_process_to_stop(Pid, Timeout) -> + 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 Timeout -> + 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}),