Skip to content

Commit

Permalink
Test config metrics reported from mod_event_pusher
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Mar 25, 2022
1 parent 04cf562 commit dd4a097
Showing 1 changed file with 16 additions and 47 deletions.
63 changes: 16 additions & 47 deletions big_tests/tests/service_mongoose_system_metrics_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-module(service_mongoose_system_metrics_SUITE).

-compile([export_all, nowarn_export_all]).

-include_lib("common_test/include/ct.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(SERVER_URL, "http://localhost:8765").
Expand All @@ -18,44 +19,6 @@
ev = "",
el = "" }).

%% API
-export([
all/0,
suite/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
]).

-export([
system_metrics_are_not_reported_when_not_allowed/1,
periodic_report_available/1,
all_clustered_mongooses_report_the_same_client_id/1,
system_metrics_are_reported_to_google_analytics_when_mim_starts/1,
system_metrics_are_reported_to_configurable_google_analytics/1,
system_metrics_are_reported_to_a_json_file/1,
module_backend_is_reported/1,
mongoose_version_is_reported/1,
cluster_uptime_is_reported/1,
xmpp_components_are_reported/1,
api_are_reported/1,
transport_mechanisms_are_reported/1,
outgoing_pools_are_reported/1,
xmpp_stanzas_counts_are_reported/1,
config_type_is_reported/1
]).

-export([
just_removed_from_config_logs_question/1,
in_config_unmodified_logs_request_for_agreement/1,
in_config_with_explicit_no_report_goes_off_silently/1,
in_config_with_explicit_reporting_goes_on_silently/1
]).

-import(distributed_helper, [mim/0, mim2/0, mim3/0,
require_rpc_nodes/1
]).
Expand All @@ -66,6 +29,7 @@
common/1]).

-import(domain_helper, [host_type/0]).
-import(config_parser_helper, [default_mod_config/1, default_config/1]).

suite() ->
require_rpc_nodes([mim]).
Expand All @@ -78,7 +42,7 @@ all() ->
system_metrics_are_reported_to_google_analytics_when_mim_starts,
system_metrics_are_reported_to_configurable_google_analytics,
system_metrics_are_reported_to_a_json_file,
module_backend_is_reported,
module_backends_are_reported,
mongoose_version_is_reported,
cluster_uptime_is_reported,
xmpp_components_are_reported,
Expand Down Expand Up @@ -160,10 +124,9 @@ init_per_testcase(xmpp_components_are_reported, Config) ->
Config1 = get_components(common(Config), Config),
enable_system_metrics(mim()),
Config1;
init_per_testcase(module_backend_is_reported, Config) ->
init_per_testcase(module_backends_are_reported, Config) ->
create_events_collection(),
DefModVCardConfig = config_parser_helper:default_mod_config(mod_vcard),
dynamic_modules:ensure_modules(host_type(), [{mod_vcard, DefModVCardConfig}]),
dynamic_modules:ensure_modules(host_type(), modules_to_report()),
enable_system_metrics(mim()),
Config;
init_per_testcase(xmpp_stanzas_counts_are_reported = CN, Config) ->
Expand Down Expand Up @@ -241,9 +204,15 @@ system_metrics_are_reported_to_a_json_file(_Config) ->
{ok, File} = distributed_helper:rpc(mim(), file, read_file, [ReportFilePath]),
jiffy:decode(File).

module_backend_is_reported(_Config) ->
module_backends_are_reported(_Config) ->
mongoose_helper:wait_until(fun modules_are_reported/0, true),
mongoose_helper:wait_until(fun mod_vcard_backend_is_reported/0, true).
mongoose_helper:wait_until(fun() -> module_backend_is_reported(mod_vcard) end, true),
mongoose_helper:wait_until(fun() -> module_backend_is_reported(mod_event_pusher) end, true),
mongoose_helper:wait_until(fun() -> module_backend_is_reported(mod_event_pusher_push) end, true).

modules_to_report() ->
[{mod_vcard, default_mod_config(mod_vcard)},
{mod_event_pusher, #{push => default_config([modules, mod_event_pusher, push])}}].

mongoose_version_is_reported(_Config) ->
mongoose_helper:wait_until(fun mongoose_version_is_reported/0, true).
Expand Down Expand Up @@ -433,8 +402,8 @@ feature_is_reported(EventCategory, EventAction) ->
feature_is_reported(EventCategory, EventAction, EventLabel) ->
length(match_events(EventCategory, EventAction, EventLabel)) > 0.

mod_vcard_backend_is_reported() ->
feature_is_reported(<<"mod_vcard">>, <<"backend">>).
module_backend_is_reported(Module) ->
feature_is_reported(atom_to_binary(Module), <<"backend">>).

mongoose_version_is_reported() ->
feature_is_reported(<<"cluster">>, <<"mim_version">>).
Expand Down

0 comments on commit dd4a097

Please sign in to comment.