Skip to content
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

Use maps for mongoose_wpool options #3645

Merged
merged 17 commits into from
May 13, 2022
Merged

Use maps for mongoose_wpool options #3645

merged 17 commits into from
May 13, 2022

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented May 10, 2022

The main goal is to keep the configuration options for outgoing pools in maps in the mongoose_wpool_* modules. The benefit is that they don't have to be converted to an intermediate format and then converted again to the format expected by the specific connection libraries.

Other main changes:

  • Store RDBMS backend options in maps as well.
  • Rename some options for improved consistency and less post-processing.
  • Fix some bugs (e.g. Rabbit options were not working because the amqp_ option prefix was not expected by mongoose_amqp
  • Amend config parser tests for outgoing pools to use the new convention of testing individual paths instead of whole structures at once. Some missing tests were added as well. The compare_nodes logic was cleaned up.
  • Make the config/2 helper recursive by default, so there is no more need to use custom helpers to merge nested configs with defaults.

Omitted on purpose:

  • As the team agreed, there is no preparation of library-specific options that could be stored in the maps as well. This would save some processing when each pool worker is started, but the difference would be negligible. It looks like the clarity and brevity of simple options in maps wins here.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz changed the title WIP Use maps for mongoose_wpool options May 11, 2022
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #3645 (8316f89) into master (a5d00fc) will decrease coverage by 0.02%.
The diff coverage is 93.33%.

@@            Coverage Diff             @@
##           master    #3645      +/-   ##
==========================================
- Coverage   81.07%   81.04%   -0.03%     
==========================================
  Files         428      428              
  Lines       31942    31912      -30     
==========================================
- Hits        25896    25863      -33     
- Misses       6046     6049       +3     
Impacted Files Coverage Δ
src/rdbms/mongoose_rdbms_odbc.erl 78.07% <ø> (ø)
src/wpool/mongoose_wpool_elastic.erl 100.00% <ø> (ø)
src/wpool/mongoose_wpool_ldap.erl 100.00% <ø> (ø)
src/wpool/mongoose_wpool_redis.erl 100.00% <ø> (ø)
src/mongoose_ldap_worker.erl 41.86% <75.00%> (-3.04%) ⬇️
src/rdbms/mongoose_rdbms_pgsql.erl 83.78% <81.81%> (-4.46%) ⬇️
src/wpool/mongoose_wpool_cassandra.erl 89.65% <84.61%> (-5.80%) ⬇️
src/config/mongoose_config_spec.erl 100.00% <100.00%> (+0.93%) ⬆️
src/event_pusher/mod_event_pusher_push.erl 94.79% <100.00%> (ø)
src/mongoose_amqp.erl 62.50% <100.00%> (+2.50%) ⬆️
... and 21 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5d00fc...8316f89. Read the comment docs.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Paweł Chrząszcz added 3 commits May 12, 2022 12:33
- Refactor wpool options to use the new utlitity merge_sections/2
- Store connection options in maps
- Remove unnecessary conversions and changes of keys
- Fix rabbit options - they did not work before, as no 'amqp_'
  prefixes were expected in the resulting config.
- Rename rootdn to root_dn - same as in the resulting options
- Add 'max_start_interval' to rdbms - there was code for handling it,
  but the option was missing from the spec.
- Add missing resuired keys for some pools.
- Make some implicit defaults explicit.

See the following commits for the pool-specific counterparts of this change.
Expect connection options in a map
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the pool-config-rework branch 2 times, most recently from 118ad94 to 0105e62 Compare May 12, 2022 11:46
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Paweł Chrząszcz added 4 commits May 12, 2022 15:07
- Expect connection options and server options in maps
- Add type specs: one with generic options and one per backend
- Minimize changes in TLS options for now
Expect original keys from the spec: 'host' and 'tls'
- Expect TLS options with the original 'tls' key.
- Expect credential in the original format.

The previous two-phase processing was too complicated.
Paweł Chrząszcz added 10 commits May 12, 2022 15:07
Expect options in the original format (in maps).
Simplify option processing
- Rename 'host' to 'host_type'
- Expect options without the 'amqp_' prefixes which actually did not work
  (there was no conversion)
- Use options directly to initialize state
- Get rid of the 'encrypt' option - 'tls' is enough and more
  consistent with other pools
- Update option format and default values
- Replace the custom merging function with a generic recursive one
  This way any section with subsections can by specified by providing
  only the extra options.
- Rearrange pool tests to check options from one section in one test case
- Add missing tests for elastic
- Check wpool options for all pool types (they sometimes change)
- Use paths (P ++ [Key]) for all checks
- Rework 'compare_nodes' to be more generic and consistent.
  Only TLS options require unordered list comparisons now.
Use the 'config/2' helper to merge options with defaults.
- Update the format of changed options
- Use the config/2 helper to merge options with defaults
- Update the format of changed options
- Put ODBS after PGSQL/MySQL, as it is less common
- Mention required options explicitly
- Add changed options to the migration guide
@mongoose-im
Copy link
Collaborator

mongoose-im commented May 12, 2022

small_tests_24 / small_tests / 8316f89
Reports root / small


small_tests_23 / small_tests / 8316f89
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 8316f89
Reports root/ big
OK: 2861 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 8316f89
Reports root/ big
OK: 2861 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 8316f89
Reports root/ big
OK: 2856 / Failed: 1 / User-skipped: 150 / Auto-skipped: 0

muc_SUITE:hibernation:hibernated_room_can_be_queried_for_archive
{error,{{assertion_failed,assert,is_groupchat_message,
              [<<"Restorable message">>],
              undefined,"undefined"},
    [{escalus_new_assert,assert_true,2,
               [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
                {line,84}]},
     {muc_SUITE,wait_for_mam_result,3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4383}]},
     {muc_SUITE,'-hibernated_room_can_be_queried_for_archive/1-fun-0-',3,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4124}]},
     {escalus_story,story,4,
            [{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
             {line,72}]},
     {muc_SUITE,hibernated_room_can_be_queried_for_archive,1,
          [{file,"/home/circleci/project/big_tests/tests/muc_SUITE.erl"},
           {line,4120}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
     {test_server,run_test_case_eval1,6,
            [{file,"test_server.erl"},{line,1292}]},
     {test_server,run_test_case_eval,9,
            [{file,"test_server.erl"},{line,1224}]}]}}

Report log


ldap_mnesia_23 / ldap_mnesia / 8316f89
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 8316f89
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 402 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 8316f89
Reports root/ big
OK: 2864 / Failed: 3 / User-skipped: 133 / Auto-skipped: 0

muc_SUITE:register:user_unregisters_nick_twice
{error,
  {{assertion_failed,assert,is_iq_result,
     [{xmlel,<<"iq">>,
        [{<<"type">>,<<"set">>},
         {<<"id">>,<<"807e91f4bf603df2fa9e71b1446e62f0">>},
         {<<"to">>,<<"groupchats.domain.example.com">>}],
        [{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,
                     <<"thirdwitch1room-002f131e00">>}]}]}]}]}]}],
     {xmlel,<<"iq">>,
       [{<<"from">>,<<"groupchats.domain.example.com">>},
        {<<"to">>,
         <<"alice_user_unregisters_nick_twice_1795@domain.example.com/res1">>},
        {<<"type">>,<<"error">>},
        {<<"xml:lang">>,<<"en">>},
        {<<"id">>,<<"807e91f4bf603df2fa9e71b1446e62f0">>}],
       [{xmlel,<<"query">>,
          [{<<"xmlns">>,<<"jabber:iq:register">>}],
          [{xmlel,<<"x">>,
             [{<<"xmlns">>,<<"jabber:x:data">>},
            {<<"type">>,<<"submit">>}],
             [{xmlel,<<"field">>,
              [{<<"type">>,<<"hidden">>},
               {<<...

Report log

smart_markers_SUITE:regular:one2one:marker_after_timestamp_for_threadid_can_be_fetched
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_marker_after_timestamp_for_threadid_can_be_fetched_2004@domain.example.com/res1">>,
          escalus_tcp,<0.536.2>,
          [{event_manager,<0.514.2>},
           {server,<<"domain.example.com">>},
           {username,
             <<"alicE_marker_after_timestamp_for_threadid_can_be_fetched_2004">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.514.2>},
            {server,<<"domain.example.com">>},
            {username,
              <<"alicE_marker_after_timestamp_for_threadid_can_be_fetched_2004">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_marker_after_timestamp_for_threadid_can_be_fetched_2004">>},
           {server,<<"domain.example.com">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,{escalus_auth,auth_plain}},
           {wspath,undefined},
           {username,
             <<"alicE_marker_after_timestamp_for_threadid_can_be_fetched_2004">>},
           {server,<<"domain.example.com">>},
           {host,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"718b1a68edb4bef0">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {smart_markers_SUITE,
       '-mark...

Report log

smart_markers_SUITE:regular:one2one:marker_for_thread_can_be_fetched
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_marker_for_thread_can_be_fetched_2003@domain.example.com/res1">>,
          escalus_tcp,<0.530.2>,
          [{event_manager,<0.507.2>},
           {server,<<"domain.example.com">>},
           {username,
             <<"alicE_marker_for_thread_can_be_fetched_2003">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.507.2>},
            {server,<<"domain.example.com">>},
            {username,
              <<"alicE_marker_for_thread_can_be_fetched_2003">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_marker_for_thread_can_be_fetched_2003">>},
           {server,<<"domain.example.com">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,{escalus_auth,auth_plain}},
           {wspath,undefined},
           {username,
             <<"alicE_marker_for_thread_can_be_fetched_2003">>},
           {server,<<"domain.example.com">>},
           {host,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"0364204a5e80ee38">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {smart_markers_SUITE,'-marker_for_thread_can_be_fetched/1-fun-0-',2,
       [{file,
          "/home/circleci/project/big_tes...

Report log


internal_mnesia_24 / internal_mnesia / 8316f89
Reports root/ big
OK: 1546 / Failed: 1 / User-skipped: 361 / Auto-skipped: 0

service_mongoose_system_metrics_SUITE:system_metrics_are_reported_to_configurable_google_analytics
{error,
  {{assertEqual,
     [{module,service_mongoose_system_metrics_SUITE},
      {line,470},
      {expression,"ActualTrackingIds"},
      {expected,[<<"UA-151671255-1">>,<<"UA-EXTRA-TRACKING-ID">>]},
      {value,[<<"UA-151671255-1">>]}]},
   [{service_mongoose_system_metrics_SUITE,
      events_are_reported_to_tracking_ids,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_mongoose_system_metrics_SUITE.erl"},
       {line,470}]},
    {service_mongoose_system_metrics_SUITE,
      system_metrics_are_reported_to_configurable_google_analytics,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_mongoose_system_metrics_SUITE.erl"},
       {line,204}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1292}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1224}]}]}}

Report log


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 8316f89
Reports root/ big
OK: 1854 / Failed: 0 / User-skipped: 369 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 8316f89
Reports root/ big
OK: 3230 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 8316f89
Reports root/ big
OK: 3235 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 8316f89
Reports root/ big
OK: 3235 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 8316f89
Reports root/ big
OK: 3257 / Failed: 2 / User-skipped: 142 / Auto-skipped: 0

pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_unsubscribe_after_presence_unsubscription_1929@localhost">>},
         {<<"to">>,
        <<"bob_unsubscribe_after_presence_unsubscription_1929@localhost/res1">>},
         {<<"type">>,<<"headline">>}],
        [{xmlel,<<"event">>,
           [{<<"xmlns">>,
           <<"http://jabber.org/protocol/pubsub#event">>}],
           [{xmlel,<<"items">>,
            [{<<"node">>,<<"Ue8G5GJXLiy07XpxTCbieA==">>}],
            [{xmlel,<<"item">>,
               [{<<"id">>,<<"salmon">>}],
               [{xmlel,<<"entry">>,
                  [{<<"xmlns">>,
                  <<"http://www.w3.org/2005/Atom">>}],
                  []}]}]}]},
         {xmlel,<<"headers">>,
           [{<<"xmlns">>,<<"http://jabber.org/protocol/shim">>}],
           []}]}]},
   [{pep_SUITE,'-unsubscribe_after_presence_unsubscription/1-fun-0-',2,
      [{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
       {line,384}]},
    {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,1783}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1292}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1224}]}]}}

Report log

pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_unsubscribe_after_presence_unsubscription_1943@localhost">>},
         {<<"to">>,
        <<"bob_unsubscribe_after_presence_unsubscription_1943@localhost/res1">>},
         {<<"type">>,<<"headline">>}],
        [{xmlel,<<"event">>,
           [{<<"xmlns">>,
           <<"http://jabber.org/protocol/pubsub#event">>}],
           [{xmlel,<<"items">>,
            [{<<"node">>,<<"mbJNG6WFpxlSSHpJCZchIA==">>}],
            [{xmlel,<<"item">>,
               [{<<"id">>,<<"salmon">>}],
               [{xmlel,<<"entry">>,
                  [{<<"xmlns">>,
                  <<"http://www.w3.org/2005/Atom">>}],
                  []}]}]}]},
         {xmlel,<<"headers">>,
           [{<<"xmlns">>,<<"http://jabber.org/protocol/shim">>}],
           []}]}]},
   [{pep_SUITE,'-unsubscribe_after_presence_unsubscription/1-fun-0-',2,
      [{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
       {line,384}]},
    {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,1783}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1292}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1224}]}]}}

Report log


riak_mnesia_24 / riak_mnesia / 8316f89
Reports root/ big
OK: 1697 / Failed: 0 / User-skipped: 368 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 8316f89
Reports root/ big
OK: 1547 / Failed: 0 / User-skipped: 361 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 8316f89
Reports root/ big
OK: 2861 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 8316f89
Reports root/ big
OK: 3235 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0

@chrzaszcz chrzaszcz marked this pull request as ready for review May 12, 2022 13:50
Copy link
Contributor

@Premwoik Premwoik left a comment

Choose a reason for hiding this comment

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

All looks good to me :) It is interesting that options from some sections didn't make an impact and nobody noticed. After all these reviews I've finally started understanding how the internal config works :D

src/config/mongoose_config_spec.erl Show resolved Hide resolved
src/rdbms/mongoose_rdbms.erl Show resolved Hide resolved
@Premwoik Premwoik merged commit adf8001 into master May 13, 2022
@Premwoik Premwoik deleted the pool-config-rework branch May 13, 2022 12:05
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
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.

None yet

3 participants