-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instrument/dynamic handlers #4247
Conversation
elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 429b944 small_tests_25 / small_tests / 429b944 small_tests_26 / small_tests / 429b944 small_tests_26_arm64 / small_tests / 429b944 ldap_mnesia_26 / ldap_mnesia / 429b944 dynamic_domains_mysql_redis_26 / mysql_redis / 429b944 dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 429b944 internal_mnesia_26 / internal_mnesia / 429b944 ldap_mnesia_25 / ldap_mnesia / 429b944 dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 429b944 pgsql_cets_26 / pgsql_cets / 429b944 dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 429b944 mysql_redis_26 / mysql_redis / 429b944 pgsql_mnesia_25 / pgsql_mnesia / 429b944 pgsql_mnesia_26 / pgsql_mnesia / 429b944 mssql_mnesia_26 / odbc_mssql_mnesia / 429b944 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/instrument #4247 +/- ##
======================================================
+ Coverage 84.43% 84.46% +0.02%
======================================================
Files 556 556
Lines 33633 33660 +27
======================================================
+ Hits 28398 28430 +32
+ Misses 5235 5230 -5 ☔ View full report in Codecov by Sentry. |
429b944
to
adfa206
Compare
elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / adfa206 small_tests_25 / small_tests / adfa206 small_tests_26 / small_tests / adfa206 small_tests_26_arm64 / small_tests / adfa206 ldap_mnesia_25 / ldap_mnesia / adfa206 dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / adfa206 ldap_mnesia_26 / ldap_mnesia / adfa206 dynamic_domains_mysql_redis_26 / mysql_redis / adfa206 internal_mnesia_26 / internal_mnesia / adfa206 dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / adfa206 pgsql_cets_26 / pgsql_cets / adfa206 dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / adfa206 pgsql_mnesia_25 / pgsql_mnesia / adfa206 mysql_redis_26 / mysql_redis / adfa206 pgsql_mnesia_26 / pgsql_mnesia / adfa206 mssql_mnesia_26 / odbc_mssql_mnesia / adfa206 muc_SUITE:register:user_submits_registration_form{error,
{{assertion_failed,assert,is_iq_result,
[{xmlel,<<"iq">>,
[{<<"type">>,<<"set">>},
{<<"id">>,<<"c9f0f14a3e003e1700aee0b2d43fda80">>},
{<<"to">>,<<"muc.localhost">>}],
[{xmlel,<<"query">>,
[{<<"xmlns">>,<<"jabber:iq:register">>}],
[{xmlel,<<"x">>,
[{<<"xmlns">>,<<"jabber:x:data">>},
{<<"type">>,<<"submit">>}],
[{xmlel,<<"field">>,
[{<<"type">>,<<"hidden">>},
{<<"var">>,<<"FORM_TYPE">>}],
[{xmlel,<<"value">>,[],
[{xmlcdata,<<"jabber:iq:register">>}]}]},
{xmlel,<<"field">>,
[{<<"type">>,<<"text-single">>},
{<<"var">>,<<"nick">>}],
[{xmlel,<<"value">>,[],
[{xmlcdata,
<<"thirdwitchroom-4a47d0bae2">>}]}]}]}]}]}],
{xmlel,<<"iq">>,
[{<<"from">>,<<"muc.localhost">>},
{<<"to">>,
<<"alice_user_submits_registration_form_3019@localhost/res1">>},
{<<"type">>,<<"error">>},
{<<"id">>,<<"c9f0f14a3e003e1700aee0b2d43fda80">>}],
[{xmlel,<<"query">>,
[{<<"xmlns">>,<<"jabber:iq:register">>}],
[{xmlel,<<"x">>,
[{<<"xmlns">>,<<"jabber:x:data">>},
{<<"type">>,<<"submit">>}],
[{xmlel,<<"field">>,
[{<<"type">>,<<"hidden">>},
{<<"var">>,<<"FORM_TYPE">>}],
[{xmlel,<<"value">>,[],
... muc_SUITE:register:user_changes_nick{error,
{thrown,
{timeout,
[{escalus_connection,receive_stanza,2,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,303}]},
{muc_SUITE,'-user_changes_nick/1-fun-0-',1,
[{file,
"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
{line,2804}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1302}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1234}]}]}}} muc_SUITE:register:user_unregisters_nick{error,
{thrown,
{timeout,
[{escalus_connection,receive_stanza,2,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,303}]},
{muc_SUITE,'-user_unregisters_nick/1-fun-0-',1,
[{file,
"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
{line,2817}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1302}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1234}]}]}}} muc_SUITE:register:user_unregisters_nick_twice{error,
{thrown,
{timeout,
[{escalus_connection,receive_stanza,2,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_connection.erl"},
{line,303}]},
{muc_SUITE,'-user_unregisters_nick_twice/1-fun-0-',1,
[{file,
"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
{line,2824}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1302}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1234}]}]}}} |
Calling intrument_helper:add(my_handler, Opts) results in: - Setting #{my_handler => Opts} in the 'instrumentation' section of mongoose_config. - Adding mongoose_instrument_my_handler module to handlers. - Setting up the new handler for already registered events. Calling instrument_helper:remove(my_handler) does the opposite. This functionality is intended for use in tests.
Benefits: - There is no meck involved, so no dynamic code modification - Testing results instead of execution of a specific function (which might change)
adfa206
to
3444fe9
Compare
elasticsearch_and_cassandra_26 / elasticsearch_and_cassandra_mnesia / 3444fe9 small_tests_25 / small_tests / 3444fe9 small_tests_26 / small_tests / 3444fe9 small_tests_26_arm64 / small_tests / 3444fe9 ldap_mnesia_25 / ldap_mnesia / 3444fe9 ldap_mnesia_26 / ldap_mnesia / 3444fe9 dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 3444fe9 dynamic_domains_pgsql_mnesia_26 / pgsql_mnesia / 3444fe9 internal_mnesia_26 / internal_mnesia / 3444fe9 dynamic_domains_mssql_mnesia_26 / odbc_mssql_mnesia / 3444fe9 dynamic_domains_mysql_redis_26 / mysql_redis / 3444fe9 pgsql_mnesia_25 / pgsql_mnesia / 3444fe9 mysql_redis_26 / mysql_redis / 3444fe9 pgsql_cets_26 / pgsql_cets / 3444fe9 pgsql_mnesia_26 / pgsql_mnesia / 3444fe9 mssql_mnesia_26 / odbc_mssql_mnesia / 3444fe9 graphql_muc_light_SUITE:domain_admin:domain_admin_muc_light:end_per_group{error,
{{unregistering_failed,
{amount,1},
{unregistered_items,
[{{<<"_admin_create_room_with_unprepped_domain_1099">>,
[{escalus_event_mgr,<0.25944.0>},
{tc_name,admin_create_room_with_unprepped_domain},
{escalus_cleaner,<0.25943.0>},
{watchdog,<0.25942.0>},
{muc_light_host,<<"muclight.localhost">>},
{secondary_muc_light_host,<<"muclight.localhost.bis">>},
{protocol,http},
{domain_admin,{<<"admin@localhost">>,<<"afc751f6e60949cd">>}},
{schema_endpoint,domain_admin},
{{ejabberd_cwd,mongooseim@localhost},
"/home/circleci/project/_build/mim1/rel/mongooseim"},
{preset,"odbc_mssql_mnesia"},
{mim_data_dir,
"/home/circleci/project/big_tests/tests/graphql_muc_light_SUITE_data"},
{tc_logfile,
"https://circleci-mim-results.s3.eu-central-1.amazonaws.com/PR/4247/213128/odbc_mssql_mnesia.26.1.2-amd64/big/ct_run.test%40441699047eb5.2024-03-21_07.46.05/big_tests.tests.graphql_muc_light_SUITE.logs/run.2024-03-21_07.50.21/graphql_muc_light_suite.admin_create_room_with_unprepped_domain.11781.html"},
{tc_group_properties,[{name,domain_admin_muc_light}]},
{tc_group_path,[[{name,domain_admin}]]},
{data_dir,
"/home/circleci/project/big_tests/_build/default/lib/mongoose_tests/ebin/graphql_muc_light_SUITE_data/"},
{priv_dir,
"https://circleci-mim-results.s3.eu-central-1.amazonaws.com/PR/4247/213128/odbc_mssql_mnesia.26.1.2-amd64/big/ct_run.test%40441699047eb5.2024-03-21_07.46.05/big_tests.tests.graphql_muc_light_SUITE.logs/run.2024-03-21_07.50.21/log_private/"},
{{saved_modules,mongooseim@localhost,<<"localhost">>},
#{mo... pep_SUITE:pep_tests:pep_caps_test{error,
{timeout_when_waiting_for_stanza,
[{escalus_client,wait_for_stanza,
[{client,<<"bob_pep_caps_test_2927@localhost/res1">>,
escalus_tcp,<0.77627.0>,
[{event_manager,<0.77591.0>},
{server,<<"localhost">>},
{username,<<"bOb_pep_caps_test_2927">>},
{resource,<<"res1">>}],
[{event_client,
[{event_manager,<0.77591.0>},
{server,<<"localhost">>},
{username,<<"bOb_pep_caps_test_2927">>},
{resource,<<"res1">>}]},
{resource,<<"res1">>},
{username,<<"bob_pep_caps_test_2927">>},
{server,<<"localhost">>},
{host,<<"localhost">>},
{port,5222},
{auth,{escalus_auth,auth_plain}},
{wspath,undefined},
{username,<<"bOb_pep_caps_test_2927">>},
{server,<<"localhost">>},
{password,<<"makrolika">>},
{stream_id,<<"4473394a2e1ab3b2">>}]},
5000],
[{file,
"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
{line,136}]},
{pep_SUITE,receive_presence_with_caps,3,
[{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
{line,553}]},
{pep_SUITE,'-pep_caps_test/1-fun-0-',1,
[{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
{line,201}]},
{escalus_story,story,4,
[{file,
"/home/circleci/project/big_tests/_build/defau... pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription{error,{{assertion_failed,assert_many,false,[is_roster_set],[],[]},
[{escalus_new_assert,assert_true,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
{line,84}]},
{escalus_story,'-make_all_clients_friends/1-fun-0-',2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,108}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl_1,3,[{file,"lists.erl"},{line,1599}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1594}]},
{escalus_utils,distinct_pairs,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,60}]},
{escalus_story,make_all_clients_friends,1,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,106}]}]}} pep_SUITE:pep_tests:publish_and_notify_test{error,{{assertion_failed,assert_many,false,[is_roster_set],[],[]},
[{escalus_new_assert,assert_true,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
{line,84}]},
{escalus_story,'-make_all_clients_friends/1-fun-0-',2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,108}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl_1,3,[{file,"lists.erl"},{line,1599}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1594}]},
{escalus_utils,distinct_pairs,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,60}]},
{escalus_story,make_all_clients_friends,1,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,106}]}]}} mssql_mnesia_26 / odbc_mssql_mnesia / 3444fe9 graphql_muc_light_SUITE:user:user_muc_light:end_per_group{error,
{{unregistering_failed,
{amount,3},
{unregistered_items,
[{{<<"_user_send_message_to_room_errors_1039">>,
[{escalus_event_mgr,<0.24336.0>},
{tc_name,user_send_message_to_room_errors},
{escalus_cleaner,<0.24335.0>},
{watchdog,<0.24334.0>},
{muc_light_host,<<"muclight.localhost">>},
{secondary_muc_light_host,<<"muclight.localhost.bis">>},
{schema_endpoint,user},
{{ejabberd_cwd,mongooseim@localhost},
"/home/circleci/project/_build/mim1/rel/mongooseim"},
{preset,"odbc_mssql_mnesia"},
{mim_data_dir,
"/home/circleci/project/big_tests/tests/graphql_muc_light_SUITE_data"},
{tc_logfile,
"https://circleci-mim-results.s3.eu-central-1.amazonaws.com/PR/4247/213140/odbc_mssql_mnesia.26.1.2-amd64/big/ct_run.test%40ea415e3524b9.2024-03-21_08.23.57/big_tests.tests.graphql_muc_light_SUITE.logs/run.2024-03-21_08.28.11/graphql_muc_light_suite.user_send_message_to_room_errors.35843.html"},
{tc_group_properties,[{name,user_muc_light},parallel]},
{tc_group_path,[[{name,user}]]},
{data_dir,
"/home/circleci/project/big_tests/_build/default/lib/mongoose_tests/ebin/graphql_muc_light_SUITE_data/"},
{priv_dir,
"https://circleci-mim-results.s3.eu-central-1.amazonaws.com/PR/4247/213140/odbc_mssql_mnesia.26.1.2-amd64/big/ct_run.test%40ea415e3524b9.2024-03-21_08.23.57/big_tests.tests.graphql_muc_light_SUITE.logs/run.2024-03-21_08.28.11/log_private/"},
{{saved_modules,mongooseim@localhost,<<"localhost">>},
#{mod_vcard =>
#{matches => 30,
host => {prefix,<<"vjud.">>},
search => true,iqdisc => parallel,backend =>... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! 🔥
-spec modules_to_funs([module()]) -> [handler_fun()]. | ||
modules_to_funs(Modules) -> | ||
[fun Module:handle_event/4 || Module <- Modules]. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat unrelated to the dynamic handlers but this little thing is a gem to me. Performance!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it after your feedback some time ago, and after checking that gen_*
in OTP do the same.
This PR allows dynamic modification of the configured handlers, which could be useful in tests, similarly to
mongoose_modules
andmongoose_service
.Previously, the tests used
meck
to inject logging events to an ETS table. Now it is possible to do this withadd_handler
andremove_handler
.Calling
intrument_helper:add(my_handler, Opts)
results in:#{my_handler => Opts}
in theinstrumentation
section ofmongoose_config
.mongoose_instrument_my_handler
module to handlers.Calling
instrument_helper:remove(my_handler)
does the opposite:mongoose_config
.By modifying
mongoose_config
in the correct order, there is consistency between the configuration and the registered handlers.