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

Fix optargs issue #2105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix optargs issue #2105

wants to merge 1 commit into from

Conversation

kanes115
Copy link
Contributor

@kanes115 kanes115 commented Oct 12, 2018

When you tried to define a command for action different than read/GET MIM would not take optional arguments into consideration.

It was because we checked actual number of arguments against command arity instead of function arity (which is not the same!!!).

This PR is going to fix this problem.

This did not show up earlier because we used opt argsonly with read actions.

@kanes115 kanes115 added the bug label Oct 12, 2018
@mongoose-im
Copy link
Collaborator

mongoose-im commented Oct 12, 2018

5759.1 / Erlang 19.3 / small_tests / 1a0c953
Reports root / small


5759.3 / Erlang 19.3 / mysql_redis / 1a0c953
Reports root/ big
OK: 2868 / Failed: 0 / User-skipped: 222 / Auto-skipped: 0


5759.5 / Erlang 19.3 / ldap_mnesia / 1a0c953
Reports root/ big
OK: 1068 / Failed: 0 / User-skipped: 80 / Auto-skipped: 0


5759.6 / Erlang 19.3 / elasticsearch_and_cassandra_mnesia / 1a0c953
Reports root/ big
OK: 445 / Failed: 0 / User-skipped: 8 / Auto-skipped: 0


5759.2 / Erlang 19.3 / internal_mnesia / 1a0c953
Reports root/ big
OK: 1116 / Failed: 1 / User-skipped: 45 / Auto-skipped: 0

mod_global_distrib_SUITE:mod_global_distrib:test_pm_with_ungraceful_reconnection_to_different_server
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,<<"eve40.10468@localhost/res1">>,escalus_tcp,
          <0.13023.1>,
          [{event_manager,<0.13014.1>},
           {server,<<"localhost">>},
           {username,<<"eve40.10468">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.13014.1>},
            {server,<<"localhost">>},
            {username,<<"eve40.10468">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,<<"eve40.10468">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,{escalus_auth,auth_plain}},
           {wspath,undefined},
           {username,<<"eve40.10468">>},
           {server,<<"localhost">>},
           {password,<<"password">>},
           {port,5222},
           {stream_management,true},
           {stream_id,<<"C4CC70ACD9D8820F">>}]},
        10000],
       [{file,
          "/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,138}]},
     {mod_global_distrib_SUITE,
       '-test_pm_with_ungraceful_reconnection_to_different_server/1-fun-0-',
       4,
       [{file,"mod_global_distrib_SUITE.erl"},{line,603}]},
     {escalus_story,story,4,
       [{file,
          "/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
        {line,72}]},
     {tes...

Report log


5759.4 / Erlang 19.3 / odbc_mssql_mnesia / 1a0c953
Reports root/ big
OK: 2895 / Failed: 1 / User-skipped: 208 / Auto-skipped: 0

mod_global_distrib_SUITE:mod_global_distrib:test_components_in_different_regions
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,undefined,escalus_tcp,<0.17803.3>,undefined,
          [{sid,<<"8B2ADE25E420F56D">>},
           {port,9990},
           {component,<<"service2">>},
           {host,<<"localhost">>},
           {password,<<"secret">>},
           {server,<<"localhost">>},
           {component,<<"test_service">>}]},
        5000],
       [{file,
          "/home/travis/build/esl/MongooseIM/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,138}]},
     {mod_global_distrib_SUITE,test_components_in_different_regions,1,
       [{file,"mod_global_distrib_SUITE.erl"},{line,472}]},
     {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1529}]},
     {test_server,run_test_case_eval1,6,
       [{file,"test_server.erl"},{line,1045}]},
     {test_server,run_test_case_eval,9,
       [{file,"test_server.erl"},{line,977}]}]}}

Report log


5759.8 / Erlang 20.0 / pgsql_mnesia / 1a0c953
Reports root/ big / small
OK: 2914 / Failed: 0 / User-skipped: 176 / Auto-skipped: 0


5759.9 / Erlang 21.0 / riak_mnesia / 1a0c953
Reports root/ big / small
OK: 1326 / Failed: 0 / User-skipped: 43 / Auto-skipped: 0

@codecov
Copy link

codecov bot commented Oct 12, 2018

Codecov Report

Merging #2105 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2105      +/-   ##
==========================================
+ Coverage   75.29%   75.35%   +0.05%     
==========================================
  Files         320      320              
  Lines       28589    28589              
==========================================
+ Hits        21527    21542      +15     
+ Misses       7062     7047      -15
Impacted Files Coverage Δ
src/mongoose_api_admin.erl 84.21% <100%> (ø) ⬆️
..._distrib/mod_global_distrib_outgoing_conns_sup.erl 73.91% <0%> (-8.7%) ⬇️
src/mod_bosh.erl 92.85% <0%> (-2.15%) ⬇️
src/mod_bosh_socket.erl 80.85% <0%> (-1%) ⬇️
src/mod_muc_log.erl 77.69% <0%> (-0.26%) ⬇️
src/mod_roster.erl 79.61% <0%> (-0.24%) ⬇️
src/mongoose_commands.erl 95.07% <0%> (+0.49%) ⬆️
src/ejabberd_c2s.erl 86.26% <0%> (+0.63%) ⬆️
src/mam/mod_mam_utils.erl 81.69% <0%> (+0.67%) ⬆️
src/muc_light/mod_muc_light_utils.erl 84.44% <0%> (+1.11%) ⬆️
... and 3 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 6245d53...4ece84a. Read the comment docs.

@varnerac
Copy link
Contributor

I don't think this solves all cases. It has to handle the situation where some/all of the optargs are present and when they're not. For the func_arity test to be valid parse_request_body would have to insert the default values for missing optargs into the proplist, and it doesn't.

I think you need some sort of argument that fills in the missing values, similar to here before checking the arity.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

6 similar comments
@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch.

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch. Thanks for the comment

3 similar comments
@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch. Thanks for the comment

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch. Thanks for the comment

@kanes115
Copy link
Contributor Author

@varnerac, of course you're right :) We also need tests in this PR that would test this untested till now code branch. Thanks for the comment

@varnerac
Copy link
Contributor

Sorry for comment spam. GitHub went sideways last night.

Copy link
Member

@fenek fenek left a comment

Choose a reason for hiding this comment

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

This issue requires better solution, i.e. automatic application of default values. What is more, as far as I can see, QVals and B are ignored? Or are they extracted later from Req?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants