From dd4a0978cefad3266742207567c27e2226be7210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Fri, 25 Mar 2022 16:13:27 +0100 Subject: [PATCH] Test config metrics reported from mod_event_pusher --- .../service_mongoose_system_metrics_SUITE.erl | 63 +++++-------------- 1 file changed, 16 insertions(+), 47 deletions(-) diff --git a/big_tests/tests/service_mongoose_system_metrics_SUITE.erl b/big_tests/tests/service_mongoose_system_metrics_SUITE.erl index 64f384cf3c8..0a8dafaa3fb 100644 --- a/big_tests/tests/service_mongoose_system_metrics_SUITE.erl +++ b/big_tests/tests/service_mongoose_system_metrics_SUITE.erl @@ -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"). @@ -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 ]). @@ -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]). @@ -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, @@ -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) -> @@ -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). @@ -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">>).