From 13d7916239a69ae1469b9ed98b29260d62d460ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Wed, 11 Dec 2024 14:38:00 +0100 Subject: [PATCH 1/3] Bump Erlang/OTP 26 version bind2_SUITE was hanging on 26.2.5.4 when the tests were reordered, most likely because of https://github.com/erlang/otp/issues/8971 --- .circleci/template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/template.yml b/.circleci/template.yml index 008089dccd..ac122778ec 100644 --- a/.circleci/template.yml +++ b/.circleci/template.yml @@ -6,7 +6,7 @@ references: # You could need to trigger a pipeline to create a Docker image: # https://github.com/esl/cimg-erlang#trigger-build-using-trigger-pipeline-on-circleci - &LATEST_OTP_VERSION 27.1.2 - - &OTP26 erlangsolutions/erlang:cimg-26.2.5.4 + - &OTP26 erlangsolutions/erlang:cimg-26.2.5.6 - &OTP27 erlangsolutions/erlang:cimg-27.1.2 - &ENTRYPOINT ["/bin/sh", "-c", "eval ${INSTALL_DEPS_CMD:-echo} && echo __INJECT_FILES__ | eval ${BASE32DEC:-base32 --decode} | bash"] # Caches created via the save_cache step are stored for up to 15 days From dea3bfda991cbb1b42037858101f270161c32db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Mon, 9 Dec 2024 14:11:41 +0100 Subject: [PATCH 2/3] Move tests restarting MIM to the end The goal is to minimise impact on other tests. The moved tests either explicitly restart the MongooseIM application or change Mnesia configuration (which also restarts the application). --- big_tests/default.spec | 35 ++++++++------- big_tests/dynamic_domains.spec | 79 ++++++++-------------------------- 2 files changed, 37 insertions(+), 77 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index fd090bea4b..1cc9051c24 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -16,12 +16,9 @@ {suites, "tests", adhoc_SUITE}. {suites, "tests", amp_big_SUITE}. {suites, "tests", anonymous_SUITE}. -{suites, "tests", auth_methods_for_c2s_SUITE}. {suites, "tests", bind2_SUITE}. {suites, "tests", bosh_SUITE}. {suites, "tests", carboncopy_SUITE}. -{suites, "tests", cluster_commands_SUITE}. -{suites, "tests", component_SUITE}. {suites, "tests", connect_SUITE}. {suites, "tests", disco_and_caps_SUITE}. {suites, "tests", extdisco_SUITE}. @@ -46,17 +43,13 @@ {suites, "tests", graphql_cets_SUITE}. {suites, "tests", graphql_vcard_SUITE}. {suites, "tests", graphql_http_upload_SUITE}. -{suites, "tests", graphql_server_SUITE}. {suites, "tests", graphql_metric_SUITE}. {suites, "tests", inbox_SUITE}. {suites, "tests", inbox_extensions_SUITE}. -{suites, "tests", jingle_SUITE}. -{suites, "tests", last_SUITE}. {suites, "tests", login_SUITE}. {suites, "tests", mam_SUITE}. {suites, "tests", mam_proper_SUITE}. {suites, "tests", mam_send_message_SUITE}. -{suites, "tests", metrics_api_SUITE}. {suites, "tests", metrics_c2s_SUITE}. {suites, "tests", metrics_roster_SUITE}. {suites, "tests", metrics_session_SUITE}. @@ -64,7 +57,6 @@ {suites, "tests", mod_event_pusher_http_SUITE}. {suites, "tests", mod_event_pusher_rabbit_SUITE}. {suites, "tests", mod_event_pusher_sns_SUITE}. -{suites, "tests", mod_global_distrib_SUITE}. {suites, "tests", mod_http_upload_SUITE}. {suites, "tests", mod_ping_SUITE}. {suites, "tests", mod_time_SUITE}. @@ -81,7 +73,6 @@ {suites, "tests", offline_SUITE}. {suites, "tests", offline_stub_SUITE}. {suites, "tests", pep_SUITE}. -{suites, "tests", persistent_cluster_id_SUITE}. {suites, "tests", presence_SUITE}. {suites, "tests", privacy_SUITE}. {suites, "tests", private_SUITE}. @@ -95,30 +86,42 @@ {suites, "tests", rdbms_SUITE}. {suites, "tests", rest_SUITE}. {suites, "tests", rest_client_SUITE}. -{suites, "tests", s2s_SUITE}. {suites, "tests", sasl_SUITE}. {suites, "tests", sasl2_SUITE}. -{suites, "tests", sasl_external_SUITE}. -{suites, "tests", service_mongoose_system_metrics_SUITE}. {suites, "tests", shared_roster_SUITE}. {suites, "tests", sic_SUITE}. {suites, "tests", smart_markers_SUITE}. {suites, "tests", sm_SUITE}. -{suites, "tests", system_probes_SUITE}. {suites, "tests", vcard_SUITE}. {suites, "tests", vcard_simple_SUITE}. {suites, "tests", websockets_SUITE}. {suites, "tests", xep_0352_csi_SUITE}. -{suites, "tests", service_domain_db_SUITE}. {suites, "tests", domain_isolation_SUITE}. {suites, "tests", domain_removal_SUITE}. -{suites, "tests", dynamic_domains_SUITE}. -{suites, "tests", local_iq_SUITE}. {suites, "tests", tcp_listener_SUITE}. {suites, "tests", cets_disco_SUITE}. {suites, "tests", start_node_id_SUITE}. {suites, "tests", tr_util_SUITE}. + +%% the below suites restart MIM nodes, so they were moved to the end +%% to minimise impact on other tests +{suites, "tests", auth_methods_for_c2s_SUITE}. +{suites, "tests", cluster_commands_SUITE}. +{suites, "tests", component_SUITE}. +{suites, "tests", dynamic_domains_SUITE}. +{suites, "tests", graphql_server_SUITE}. +{suites, "tests", jingle_SUITE}. +{suites, "tests", last_SUITE}. +{suites, "tests", local_iq_SUITE}. +{suites, "tests", metrics_api_SUITE}. +{suites, "tests", mod_global_distrib_SUITE}. +{suites, "tests", persistent_cluster_id_SUITE}. +{suites, "tests", s2s_SUITE}. +{suites, "tests", sasl_external_SUITE}. +{suites, "tests", service_domain_db_SUITE}. +{suites, "tests", service_mongoose_system_metrics_SUITE}. {suites, "tests", shutdown_SUITE}. +{suites, "tests", system_probes_SUITE}. {config, ["test.config"]}. {logdir, "ct_report"}. diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index 0df35ae5d3..b88a9dc765 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -10,35 +10,17 @@ {include, "tests"}. {suites, "tests", mim_c2s_SUITE}. - {suites, "tests", acc_e2e_SUITE}. - {suites, "tests", accounts_SUITE}. - {suites, "tests", adhoc_SUITE}. - {suites, "tests", amp_big_SUITE}. - {suites, "tests", anonymous_SUITE}. - -{suites, "tests", auth_methods_for_c2s_SUITE}. - {suites, "tests", bind2_SUITE}. - {suites, "tests", bosh_SUITE}. - {suites, "tests", carboncopy_SUITE}. - -{suites, "tests", cluster_commands_SUITE}. - {suites, "tests", connect_SUITE}. - {suites, "tests", disco_and_caps_SUITE}. - {suites, "tests", domain_isolation_SUITE}. - -{suites, "tests", dynamic_domains_SUITE}. - {suites, "tests", extdisco_SUITE}. {suites, "tests", gdpr_SUITE}. @@ -67,38 +49,21 @@ {suites, "tests", graphql_mnesia_SUITE}. {suites, "tests", graphql_cets_SUITE}. {suites, "tests", graphql_http_upload_SUITE}. -{suites, "tests", graphql_server_SUITE}. {suites, "tests", graphql_metric_SUITE}. - {suites, "tests", inbox_SUITE}. {suites, "tests", inbox_extensions_SUITE}. - -{suites, "tests", last_SUITE}. - {suites, "tests", login_SUITE}. - {suites, "tests", mam_SUITE}. {suites, "tests", mam_proper_SUITE}. {suites, "tests", mam_send_message_SUITE}. - {suites, "tests", metrics_c2s_SUITE}. - {suites, "tests", metrics_roster_SUITE}. - {suites, "tests", metrics_session_SUITE}. - -{suites, "tests", metrics_api_SUITE}. - {suites, "tests", mod_blocking_SUITE}. - {suites, "tests", mod_http_upload_SUITE}. - {suites, "tests", mod_ping_SUITE}. - {suites, "tests", mod_time_SUITE}. - {suites, "tests", mod_version_SUITE}. - {suites, "tests", mongooseimctl_SUITE}. {suites, "tests", muc_SUITE}. @@ -108,48 +73,22 @@ "(requires mod_register creating CT users)"}. {suites, "tests", muc_http_api_SUITE}. - {suites, "tests", muc_light_SUITE}. - {suites, "tests", muc_light_legacy_SUITE}. - {suites, "tests", muc_light_http_api_SUITE}. - {suites, "tests", oauth_SUITE}. - {suites, "tests", offline_SUITE}. - {suites, "tests", offline_stub_SUITE}. - -{suites, "tests", persistent_cluster_id_SUITE}. - {suites, "tests", presence_SUITE}. - {suites, "tests", privacy_SUITE}. - {suites, "tests", private_SUITE}. - {suites, "tests", race_conditions_SUITE}. - {suites, "tests", rdbms_SUITE}. - {suites, "tests", rest_SUITE}. - {suites, "tests", rest_client_SUITE}. - {suites, "tests", sasl_SUITE}. {suites, "tests", sasl2_SUITE}. -{suites, "tests", sasl_external_SUITE}. - -{suites, "tests", service_domain_db_SUITE}. - -{suites, "tests", service_mongoose_system_metrics_SUITE}. -{skip_cases, "tests", service_mongoose_system_metrics_SUITE, - [xmpp_components_are_reported], - "at the moment external components doesn't support dynamic domains"}. - {suites, "tests", sic_SUITE}. - {suites, "tests", smart_markers_SUITE}. {suites, "tests", sm_SUITE}. {suites, "tests", system_probes_SUITE}. @@ -163,6 +102,24 @@ {suites, "tests", cets_disco_SUITE}. {suites, "tests", start_node_id_SUITE}. {suites, "tests", tr_util_SUITE}. + +%% the below suites restart MIM nodes, so they were moved to the end +%% to minimise impact on other tests +{suites, "tests", auth_methods_for_c2s_SUITE}. +{suites, "tests", cluster_commands_SUITE}. +{suites, "tests", dynamic_domains_SUITE}. +{suites, "tests", graphql_server_SUITE}. +{suites, "tests", last_SUITE}. +{suites, "tests", metrics_api_SUITE}. +{suites, "tests", persistent_cluster_id_SUITE}. +{suites, "tests", sasl_external_SUITE}. +{suites, "tests", service_domain_db_SUITE}. + +{suites, "tests", service_mongoose_system_metrics_SUITE}. +{skip_cases, "tests", service_mongoose_system_metrics_SUITE, + [xmpp_components_are_reported], + "at the moment external components doesn't support dynamic domains"}. + {suites, "tests", shutdown_SUITE}. {config, ["dynamic_domains.config", "test.config"]}. From e6223e76607d58fd45b5adb782dc26e92f5c8858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 12 Dec 2024 13:57:03 +0100 Subject: [PATCH 3/3] Fix issues in the REST API subscribing for messages - 'terminate' was not called because of missing 'trap_exit' flag - 'terminate' would crash because 'ok' was not stripped from Session - Any stanza other than 'message' would cause the process to crash Before the fix, rest_client_SUITE would end with ghost sessions. Now the state is clear after this suite. --- src/mongoose_client_api/mongoose_client_api_sse.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mongoose_client_api/mongoose_client_api_sse.erl b/src/mongoose_client_api/mongoose_client_api_sse.erl index 118c033d3f..f08b6e8378 100644 --- a/src/mongoose_client_api/mongoose_client_api_sse.erl +++ b/src/mongoose_client_api/mongoose_client_api_sse.erl @@ -18,6 +18,7 @@ routes() -> [{"/sse", lasse_handler, #{module => mongoose_client_api_sse}}]. init(_InitArgs, _LastEvtId, Req) -> + process_flag(trap_exit, true), % needed for 'terminate' to be called ?LOG_DEBUG(#{what => client_api_sse_init, req => Req}), {cowboy_rest, Req1, State0} = mongoose_client_api:init(Req, []), {Authorization, Req2, State} = mongoose_client_api:is_authorized(Req1, State0), @@ -28,7 +29,7 @@ init(_InitArgs, _LastEvtId, Req) -> maybe_init(Authorization, Req2, State#{id => 1}). maybe_init(true, Req, #{jid := JID} = State) -> - Session = mongoose_stanza_api:open_session(JID, false), + {ok, Session} = mongoose_stanza_api:open_session(JID, false), {ok, Req, State#{session => Session}}; maybe_init(true, Req, State) -> %% This is for OPTIONS method @@ -51,7 +52,9 @@ handle_info(Msg, State) -> handle_msg(<<"message">>, Acc, El, State) -> Timestamp = os:system_time(microsecond), Type = mongoose_acc:stanza_type(Acc), - maybe_send_message_event(Type, El, Timestamp, State). + maybe_send_message_event(Type, El, Timestamp, State); +handle_msg(_, _, _, State) -> + {nosend, State}. handle_error(Msg, Reason, State) -> ?LOG_WARNING(#{what => sse_handle_error, msg => Msg, reason => Reason}),