Skip to content

Commit

Permalink
Merge pull request #3280 from esl/ct/dynamic_domains-metrics
Browse files Browse the repository at this point in the history
Add metrics_api_SUITE to dynamic_domains
  • Loading branch information
Premwoik authored Sep 20, 2021
2 parents 28bf705 + c96af86 commit 57bf9ae
Show file tree
Hide file tree
Showing 41 changed files with 170 additions and 191 deletions.
6 changes: 6 additions & 0 deletions big_tests/dynamic_domains.config
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@
{host, <<"localhost">>},
{password, <<"distributionftw">>},
{port, 5232}]},
{clusterbuddy, [
{username, <<"clusterbuddy">>},
{server, <<"domain.example.com">>},
{host, <<"localhost">>},
{password, <<"wasssssssup">>},
{port, 5232}]},
{alice3, [ %% used in dynamic_domains_SUITE
{username, <<"alice">>},
{server, <<"example.com">>},
Expand Down
2 changes: 2 additions & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@

{suites, "tests", metrics_session_SUITE}.

{suites, "tests", metrics_api_SUITE}.

{suites, "tests", mod_blocking_SUITE}.

{suites, "tests", mod_http_upload_SUITE}.
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
rpc/4]).

-import(mongoose_helper, [wait_for_user/3]).

-import(domain_helper, [domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
%%--------------------------------------------------------------------
Expand Down Expand Up @@ -461,6 +464,3 @@ disable_watcher(Config) ->

host_type() ->
domain_helper:host_type(mim).

domain() ->
ct:get_config({hosts, mim, domain}).
5 changes: 1 addition & 4 deletions big_tests/tests/adhoc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").

-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -215,6 +215,3 @@ ping(Config) ->
escalus:assert(is_adhoc_response, [<<"ping">>, <<"completed">>],
AdHocResp)
end).

domain() ->
ct:get_config({hosts, mim, domain}).
5 changes: 1 addition & 4 deletions big_tests/tests/amp_big_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
require_rpc_nodes/1,
rpc/4]).
-import(muc_light_helper, [lbin/1]).
-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

suite() ->
require_rpc_nodes([mim]) ++ escalus:suite().
Expand Down Expand Up @@ -1000,6 +1000,3 @@ offline_modules(on) ->
offline_modules(off) ->
[{mod_offline, stopped},
{mod_offline_stub, []}].

domain() ->
ct:get_config({hosts, mim, domain}).
23 changes: 10 additions & 13 deletions big_tests/tests/bosh_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-import(distributed_helper, [mim/0,
require_rpc_nodes/1,
rpc/4]).
-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -161,7 +161,7 @@ create_and_terminate_session(Config) ->
%% Assert there are no BOSH sessions on the server.
[] = get_bosh_sessions(),

Domain = ct:get_config({hosts, mim, domain}),
Domain = domain(),
Body = escalus_bosh:session_creation_body(get_bosh_rid(Conn), Domain),
ok = bosh_send_raw(Conn, Body),
escalus_connection:get_stanza(Conn, session_creation_response),
Expand Down Expand Up @@ -373,7 +373,7 @@ cant_send_invalid_rid(Config) ->
%% completes. This will leave the following message in the log:
%%
%% mod_bosh:forward_body:265 session not found!

%% NOTICE 3
%% We enable quickfail mode, because sometimes request with invalid RID
%% arrives before empty body req. with valid RID, so server returns an error
Expand Down Expand Up @@ -524,7 +524,7 @@ interrupt_long_poll_is_activity(ConfigIn) ->
%% Wait until after the inactivity timeout (which should be less than
%% the BOSH wait timeout).
timer:sleep(2 * timer:seconds(?INACTIVITY)),

%% No disconnection should have occurred.
escalus_assert:has_no_stanzas(Carol),
true = is_session_alive(Sid),
Expand Down Expand Up @@ -879,35 +879,32 @@ wait_for_session_close(Sid, LeftTime) ->
mongoose_helper:wait_until(fun() -> is_session_alive(Sid) end, false,
#{
time_left => timer:seconds(10),
time_sleep => LeftTime,
time_sleep => LeftTime,
name => is_session_alive
}).

wait_for_handler(Pid, Count) ->
mongoose_helper:wait_until(fun() -> length(get_handlers(Pid)) end, Count,
#{
#{
time_left => timer:seconds(10),
time_sleep => timer:seconds(1),
name => get_handlers
}).


wait_for_handler(Pid, Count, LeftTime) ->
mongoose_helper:wait_until(fun() -> length(get_handlers(Pid)) end, Count,
#{
mongoose_helper:wait_until(fun() -> length(get_handlers(Pid)) end, Count,
#{
time_left => LeftTime,
time_sleep => timer:seconds(1),
name => get_handlers
}).

wait_until_user_has_no_stanzas(User) ->
mongoose_helper:wait_until(fun() ->
escalus_assert:has_no_stanzas(User)
mongoose_helper:wait_until(fun() ->
escalus_assert:has_no_stanzas(User)
end, ok, #{left_time => 2 * timer:seconds(?INACTIVITY)}).

domain() ->
ct:get_config({hosts, mim, domain}).

wait_for_zero_bosh_sessions() ->
mongoose_helper:wait_until(fun() ->
length(get_bosh_sessions())
Expand Down
3 changes: 2 additions & 1 deletion big_tests/tests/carboncopy_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
-define(BODY, <<"And pious action">>).

-import(mongoose_helper, [enable_carbons/1, disable_carbons/1]).
-import(domain_helper, [domain/0]).

all() ->
[{group, all}].
Expand Down Expand Up @@ -56,7 +57,7 @@ discovering_support(Config) ->
escalus:fresh_story(
Config, [{alice, 1}],
fun(Alice) ->
IqGet = escalus_stanza:disco_info(ct:get_config({hosts, mim, domain})),
IqGet = escalus_stanza:disco_info(domain()),
escalus_client:send(Alice, IqGet),
Result = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_iq_result, [IqGet], Result),
Expand Down
5 changes: 3 additions & 2 deletions big_tests/tests/connect_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
require_rpc_nodes/1,
rpc/4]).

-import(domain_helper, [domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
%%--------------------------------------------------------------------
Expand Down Expand Up @@ -685,8 +687,7 @@ close_connection_if_protocol_violation_after_binding(Config) ->
close_connection_if_protocol_violation(Config, Steps) ->
AliceSpec = escalus_fresh:create_fresh_user(Config, alice),
{ok, Alice, _Features} = escalus_connection:start(AliceSpec, Steps),
escalus:send(Alice, escalus_stanza:stream_start(ct:get_config({hosts, mim, domain}),
?NS_JABBER_CLIENT)),
escalus:send(Alice, escalus_stanza:stream_start(domain(), ?NS_JABBER_CLIENT)),
escalus:assert(is_stream_error, [<<"policy-violation">>, <<>>],
escalus_connection:get_stanza(Alice, no_stream_error_stanza_received)),
escalus:assert(is_stream_end,
Expand Down
5 changes: 1 addition & 4 deletions big_tests/tests/disco_and_caps_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
-include_lib("eunit/include/eunit.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").

-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

all() ->
[{group, disco_with_caps},
Expand Down Expand Up @@ -32,9 +32,6 @@ extra_feature_test_cases() ->
[user_can_query_extra_domains,
user_can_query_server_info].

domain() ->
ct:get_config({hosts, mim, domain}).

init_per_suite(C) ->
C.

Expand Down
8 changes: 8 additions & 0 deletions big_tests/tests/domain_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
host_types/1,
host_type/0,
host_type/1,
domain/0,
domain/1,
secondary_host_type/0,
secondary_host_type/1]).

Expand All @@ -23,9 +25,15 @@ host_types(NodeKey) ->
host_type() ->
host_type(mim).

domain() ->
domain(mim).

host_type(NodeKey) ->
get_or_fail({hosts, NodeKey, host_type}).

domain(NodeKey) ->
get_or_fail({hosts, NodeKey, domain}).

secondary_host_type() ->
secondary_host_type(mim).

Expand Down
5 changes: 1 addition & 4 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
private_removal/1]).

-import(distributed_helper, [mim/0, rpc/4, subhost_pattern/1]).
-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

-include("mam_helper.hrl").
-include_lib("escalus/include/escalus.hrl").
Expand All @@ -42,9 +42,6 @@ groups() ->
{private_removal, [], [private_removal]}
].

domain() ->
ct:get_config({hosts, mim, domain}).

%%%===================================================================
%%% Overall setup/teardown
%%%===================================================================
Expand Down
5 changes: 2 additions & 3 deletions big_tests/tests/extdisco_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
-import(distributed_helper, [mim/0,
rpc/4]).

-import(domain_helper, [domain/0]).

-define(NS_EXTDISCO, <<"urn:xmpp:extdisco:2">>).

-compile([export_all]).
Expand Down Expand Up @@ -312,9 +314,6 @@ turn_service() ->
{username, "username"},
{password, "secret"}].

domain() ->
ct:get_config({hosts, mim, domain}).

set_external_services(Opts, Config) ->
Module = [{mod_extdisco, Opts}],
ok = dynamic_modules:ensure_modules(domain(), Module),
Expand Down
12 changes: 7 additions & 5 deletions big_tests/tests/jingle_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
-import(jingle_helper, [content/1,
content_group/1]).

-import(domain_helper, [domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
%%--------------------------------------------------------------------
Expand Down Expand Up @@ -84,12 +86,12 @@ wait_for_process_to_stop(Pid) ->
end.

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

end_per_suite(Config) ->
escalus_fresh:clean(),
Host = ct:get_config({hosts, mim, domain}),
dynamic_modules:stop(mim(), Host, mod_jingle_sip),
dynamic_modules:stop(mim2(), Host, mod_jingle_sip),
Domain = domain(),
dynamic_modules:stop(mim(), Domain, mod_jingle_sip),
dynamic_modules:stop(mim2(), Domain, mod_jingle_sip),
distributed_helper:remove_node_from_cluster(mim2(), Config),
escalus:end_per_suite(Config).

Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/login_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
require_rpc_nodes/1,
rpc/4]).

-import(domain_helper, [host_type/0]).
-import(domain_helper, [host_type/0, domain/0]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -460,7 +460,7 @@ unset_acl_for_blocking(Spec) ->

modify_acl_for_blocking(Method, Spec) ->
ct:print("Spec: ~p", [Spec]),
Domain = ct:get_config({hosts, mim, domain}),
Domain = domain(),
User = proplists:get_value(username, Spec),
Lower = escalus_utils:jid_to_lower(User),
rpc(mim(), acl, Method, [Domain, blocked, {user, Lower}]).
Expand Down
6 changes: 4 additions & 2 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@
when_archive_query_is_sent/3,
then_archive_response_is/3]).

-import(domain_helper, [domain/0]).

-include("mam_helper.hrl").
-include_lib("escalus/include/escalus.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").
Expand Down Expand Up @@ -349,7 +351,7 @@ basic_groups() ->
{chat_markers, [parallel],
[{mam04, [parallel], chat_markers_cases()}]},
{disabled_retraction, [],
[{mam06, [parallel], disabled_retract_cases() ++
[{mam06, [parallel], disabled_retract_cases() ++
[mam_service_discovery]}]},
{muc_disabled_retraction, [],
[{muc06, [parallel], disabled_muc_retract_cases() ++
Expand Down Expand Up @@ -2968,7 +2970,7 @@ mam_service_discovery(Config) ->
muc_service_discovery(Config) ->
_P = ?config(props, Config),
F = fun(Alice) ->
Domain = ct:get_config({hosts, mim, domain}),
Domain = domain(),
Server = escalus_client:server(Alice),
escalus:send(Alice, escalus_stanza:service_discovery(Server)),
Stanza = escalus:wait_for_stanza(Alice),
Expand Down
Loading

0 comments on commit 57bf9ae

Please sign in to comment.