Skip to content

Enable selected rabbit exchanges - #4576

Merged
telezynski merged 11 commits into
masterfrom
rabbit-optional-exchanges
Nov 19, 2025
Merged

telezynski merged 11 commits into
masterfrom
rabbit-optional-exchanges

Conversation

@chrzaszcz

@chrzaszcz chrzaszcz commented Nov 17, 2025 •

Copy link
Copy Markdown
Member

This PR makes it possible to enable selected RabbitMQ exchanges in mod_event_pusher_rabbit instead of having them always enabled.

Main changes:

  • Make the config subsections for exchanges optional. If not present, the notifications will be disabled.
  • Create only the configured exchanges.
  • Publish notifications only for the enabled exchanges.
  • Add small tests for configuration.
  • Add big tests for the case when only one exchange (presence_exchange) is enabled. We could test other options, but the tests are sequential, and I decided not to create too many of them. After all, the functionality is provided by the same code, so it makes sense to only hit the lines once.
  • Document the change, updating the migration guide as well.

Other changes:

  • Refactormod_event_pusher_rabbit and the big tests. The goal is to make the code easier to extend and maintain.
  • Prevent a flood of errors in mod_event_pusher_rabbit_SUITE. They were caused by the pools being brutally killed when restarted. I gave them a sane shutdown timeout of 5 seconds.

Notes:

  • Regarding the restart strategy, rdbms pools have an inifite shutdown timeout, while other pools have the default brutal_kill strategy. It is worth investigating this further. The priority is not high, because restarting pools shouldn't happen during normal operation.

More details in commit messages.

@mongoose-im

This comment was marked as outdated.

@codecov

codecov Bot commented Nov 17, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.02%. Comparing base (f9677d6) to head (e108f0d).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/event_pusher/mod_event_pusher_rabbit.erl 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4576      +/-   ##
==========================================
+ Coverage   85.91%   86.02%   +0.11%     
==========================================
  Files         565      565              
  Lines       33888    33877      -11     
==========================================
+ Hits        29114    29143      +29     
+ Misses       4774     4734      -40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Also, refactor verification for created exchanges:
- Use the new error format
- Report failed exchanges with errors instead of all exchanges
Also, refactor push_event/2, improving code reuse.
@chrzaszcz
chrzaszcz force-pushed the rabbit-optional-exchanges branch from b82a84b to 9504ad7 Compare November 18, 2025 11:18
@mongoose-im

This comment was marked as outdated.

Without this, workers were killed with no chance for cleanup,
resulting in a flood of errors during mod_event_pusher_rabbit_SUITE,
and missed instrumentation events as well.
The test case was waiting only for the 'sent' event,
while it should also wait for the 'recv' one.

As a result, the test was flaky.
It wasn't failing on CI, but minor changes to the source code could
make it fail locally.
This is done for all other suites, and it facilitates debugging.
- Type specs were incorrect
- There was a redundant case + throw (wait_helper does this already)
With only presence_exchange, verify that:
  - Only the enabled exchange is created.
  - There are no push attempts for chat messages.

Other combinations are not tested to reduce the number of tests.
This commit actually enables the whole feature for the user.
Update migration guide as well
@chrzaszcz
chrzaszcz force-pushed the rabbit-optional-exchanges branch from 9504ad7 to e108f0d Compare November 18, 2025 11:45
@mongoose-im

mongoose-im commented Nov 18, 2025 •

Copy link
Copy Markdown
Collaborator

elasticsearch_and_cassandra_28 / elasticsearch_and_cassandra_mnesia / e108f0d
Reports root/ big
OK: 683 / Failed: 0 / User-skipped: 72 / Auto-skipped: 0


small_tests_28 / small_tests / e108f0d
Reports root / small


small_tests_27 / small_tests / e108f0d
Reports root / small


small_tests_28_arm64 / small_tests / e108f0d
Reports root / small


ldap_mnesia_27 / ldap_mnesia / e108f0d
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1356 / Auto-skipped: 0


ldap_mnesia_28 / ldap_mnesia / e108f0d
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1356 / Auto-skipped: 0


dynamic_domains_mysql_redis_28 / mysql_redis / e108f0d
Reports root/ big
OK: 5179 / Failed: 0 / User-skipped: 154 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_28 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


internal_mnesia_28 / internal_mnesia / e108f0d
Reports root/ big
OK: 2486 / Failed: 0 / User-skipped: 1218 / Auto-skipped: 0


pgsql_cets_28 / pgsql_cets / e108f0d
Reports root/ big
OK: 5301 / Failed: 0 / User-skipped: 192 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_28 / odbc_mssql_mnesia / e108f0d
Reports root/ big
OK: 5208 / Failed: 1 / User-skipped: 124 / Auto-skipped: 0

graphql_session_SUITE:admin_session:admin_session_cli:admin_list_users_with_status
{error,
  {{assertEqual,
     [{module,graphql_session_SUITE},
      {line,591},
      {expression,"lists : sort ( ActualJIDs )"},
      {expected,
        [<<"alice_admin_list_users_with_status_2029@domain.example.org/res1">>]},
      {value,[]}]},
   [{graphql_session_SUITE,check_users,2,
      [{file,
         "/home/circleci/project/big_tests/tests/graphql_session_SUITE.erl"},
       {line,591}]},
    {graphql_session_SUITE,admin_list_users_with_status_story,3,
      [{file,
         "/home/circleci/project/big_tests/tests/graphql_session_SUITE.erl"},
       {line,422}]},
    {escalus_story,story,4,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,75}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1796}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1305}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1237}]}]}}

Report log


pgsql_mnesia_27 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5604 / Failed: 0 / User-skipped: 132 / Auto-skipped: 0


pgsql_mnesia_28 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5604 / Failed: 0 / User-skipped: 132 / Auto-skipped: 0


mysql_redis_28 / mysql_redis / e108f0d
Reports root/ big
OK: 5587 / Failed: 0 / User-skipped: 149 / Auto-skipped: 0


cockroachdb_cets_28 / cockroachdb_cets / e108f0d
Reports root/ big
OK: 5311 / Failed: 5 / User-skipped: 192 / Auto-skipped: 0

pubsub_SUITE:dag+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3729@localhost/res1">>,
          escalus_tcp,<0.115752.0>,
          [{event_manager,<0.115749.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3729">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.115749.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3729">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3729">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3729">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"f0ec5a21c883d0d3">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log

pubsub_SUITE:dag+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3731@localhost/res1">>,
          escalus_tcp,<0.115828.0>,
          [{event_manager,<0.115817.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3731">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.115817.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3731">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3731">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3731">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"a22a07307d90c75e">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log

pubsub_SUITE:dag+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3735@localhost/res1">>,
          escalus_tcp,<0.115905.0>,
          [{event_manager,<0.115903.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3735">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.115903.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3735">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3735">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3735">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"7c1f716a9ea236d5">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log

pubsub_SUITE:dag+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3738@localhost/res1">>,
          escalus_tcp,<0.115983.0>,
          [{event_manager,<0.115980.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3738">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.115980.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3738">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3738">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3738">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"f422f5ad40a56cdd">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log

pubsub_SUITE:tree+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3791@localhost/res1">>,
          escalus_tcp,<0.117265.0>,
          [{event_manager,<0.117246.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3791">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.117246.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3791">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3791">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3791">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"e0f928393900591c">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log


mssql_mnesia_28 / odbc_mssql_mnesia / e108f0d
Reports root/ big
OK: 5599 / Failed: 0 / User-skipped: 137 / Auto-skipped: 0


elasticsearch_and_cassandra_28 / elasticsearch_and_cassandra_mnesia / e108f0d
Reports root
OK: 0 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


dynamic_domains_mysql_redis_28 / mysql_redis / e108f0d
Reports root


dynamic_domains_pgsql_mnesia_28 / pgsql_mnesia / e108f0d
Reports root


ldap_mnesia_28 / ldap_mnesia / e108f0d
Reports root
OK: 0 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


internal_mnesia_28 / internal_mnesia / e108f0d
Reports root
OK: 0 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


pgsql_cets_28 / pgsql_cets / e108f0d
Reports root
OK: 0 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_28 / odbc_mssql_mnesia / e108f0d
Reports root


ldap_mnesia_27 / ldap_mnesia / e108f0d
Reports root
OK: 0 / Failed: 0 / User-skipped: 0 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 203 / Failed: 3 / User-skipped: 36 / Auto-skipped: 0


small_tests_28 / small_tests / e108f0d
Reports root / small


small_tests_27 / small_tests / e108f0d
Reports root / small


small_tests_28_arm64 / small_tests / e108f0d
Reports root / small


small_tests_28 / small_tests / e108f0d
Reports root / small


elasticsearch_and_cassandra_28 / elasticsearch_and_cassandra_mnesia / e108f0d
Reports root/ big
OK: 683 / Failed: 0 / User-skipped: 72 / Auto-skipped: 0


small_tests_28_arm64 / small_tests / e108f0d
Reports root / small


small_tests_28 / small_tests / e108f0d
Reports root / small


small_tests_27 / small_tests / e108f0d
Reports root / small


ldap_mnesia_27 / ldap_mnesia / e108f0d
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1356 / Auto-skipped: 0


dynamic_domains_mysql_redis_28 / mysql_redis / e108f0d
Reports root/ big
OK: 5179 / Failed: 0 / User-skipped: 154 / Auto-skipped: 0


ldap_mnesia_28 / ldap_mnesia / e108f0d
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1356 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_28 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


internal_mnesia_28 / internal_mnesia / e108f0d
Reports root/ big
OK: 2486 / Failed: 0 / User-skipped: 1218 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / e108f0d
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


pgsql_cets_28 / pgsql_cets / e108f0d
Reports root/ big
OK: 5301 / Failed: 0 / User-skipped: 192 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_28 / odbc_mssql_mnesia / e108f0d
Reports root/ big
OK: 5208 / Failed: 1 / User-skipped: 124 / Auto-skipped: 0

connect_SUITE:just_tls:tls:should_fail_without_tls
{error,{{assertEqual,[{module,connect_SUITE},
            {line,394},
            {expression,"logger_ct_backend : recv ( fun ( _ , _Msg ) -> true end )"},
            {expected,[]},
            {value,[{error,"2025-11-18T16:26:16.644976+00:00 error: State machine <0.21677.0> terminating. Reason: {badmatch,{error,einval}}. Stack: [{mongoose_listener,read_connection_details,3,[{file,\"/home/circleci/project/src/listeners/mongoose_listener.erl\"},{line,219}]},{mongoose_xmpp_socket,accept,4,[{file,\"/home/circleci/project/src/listeners/mongoose_xmpp_socket.erl\"},{line,92}]},{mongoose_c2s,handle_event,4,[{file,\"/home/circleci/project/src/c2s/mongoose_c2s.erl\"},{line,94}]},{gen_statem,loop_state_callback,11,[{file,\"gen_statem.erl\"},{line,3750}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,333}]}]. Last event: {internal,{connect,{ranch_ssl,{5222,{0,0,0,0},tcp}}}}. State: {connect,{c2s_data,undefined,<<\"localhost\">>,<<\"en\">>,{1763483176639213,<0.21677.0>},<<\"127f0ccea3632210\">>,undefined,undefined,undefined,undefined,#{access => c2s,module => mongoose_c2s_listener,port => 5222,num_acceptors => 100,max_connections => infinity,hibernate_after => 0,backlog => 1024,state_timeout => 5000,tls => #{mode => tls,cacertfile => \"priv/ssl/cacert.pem\",certfile => \"priv/ssl/fake_cert.pem\",keyfile => \"priv/ssl/fake_key.pem\",dhfile => \"priv/ssl/fake_dh_server.pem\",verify_mode => none,crl_files => [],disconnect_on_failure => true},shaper => normal,connection_type =>...

Report log


small_tests_27 / small_tests / e108f0d
Reports root / small


small_tests_28_arm64 / small_tests / e108f0d
Reports root / small


ldap_mnesia_27 / ldap_mnesia / e108f0d
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1356 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_28 / odbc_mssql_mnesia / e108f0d
Reports root/ big
OK: 5209 / Failed: 0 / User-skipped: 124 / Auto-skipped: 0

@chrzaszcz
chrzaszcz marked this pull request as ready for review November 19, 2025 07:41
@chrzaszcz chrzaszcz changed the title Enable selected rabbit exchanges (WIP) Enable selected rabbit exchanges Nov 19, 2025

@telezynski telezynski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@telezynski
telezynski merged commit 3a099dc into master Nov 19, 2025
4 checks passed
@telezynski
telezynski deleted the rabbit-optional-exchanges branch November 19, 2025 10:13
@pawlooss1 pawlooss1 added this to the 6.5.0 milestone Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants