Skip to content

Commit

Permalink
Merge branch 'feature/graphql' into mod_vcard_graphql_qpi
Browse files Browse the repository at this point in the history
  • Loading branch information
JanuszJakubiec authored May 6, 2022
2 parents adc5f97 + a6a323b commit 331a993
Show file tree
Hide file tree
Showing 249 changed files with 7,880 additions and 6,938 deletions.
44 changes: 8 additions & 36 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Contribution Guidelines

This document aims to provide guidelines for merging changesets into the MongooseIM master branch.

For the purpose of this document, we classify changesets/pull requests as:

* big: implementation of new XEPs or major changes to core code
Expand All @@ -13,7 +11,7 @@ For the purpose of this document, we classify changesets/pull requests as:
We strive for Inaka's superb [guidelines](https://github.com/inaka/erlang_guidelines).

MongooseIM has an extensive test suite.
Find **unit** (white box) tests under `test/` and **functional** (black box) tests under `test.disabled/ejabberd_tests/tests`.
Find **unit** (white box) tests under `test/` and **functional** (black box) tests under `big_tests/tests`.
It's important that tests are comprehensible: consider any preconditions, the test itself, and any postconditions that must hold.
Inspect the existing test suites to see how _we_ make these clear.

Expand All @@ -40,49 +38,24 @@ Do your work in the branch, push it to the ESL repository if you have access to

### Run tests

When done, run the whole CT suite and write tests related to what you've done.

### Check coding style

Check you coding style by running Elvis on your work. You need:

https://github.com/inaka/elvis (make sure elvis_core is at least version 0.3.3)

in your PATH. Then run:

`make rock BRANCH=your_development_branch`

to check all files you have modified within your branch. Alternatively, you can run:

`make rock FILE=file_to_check`

or just

`make rock`

to check only modified files (both staged and unstaged).

Fix all issues Elvis reports, otherwise your build will fail.
When done with writing tests related to what you've done, run the whole CT suite, as [described in the docs](https://esl.github.io/MongooseDocs/latest/developers-guide/Testing-MongooseIM/).

### Push

Then push the changes and create a pull request to master, following the PR description template.
Make sure all GitHub Actions tests pass (if only some jobs fail it is advisable to restart them, since they sometimes
Make sure all our CI tests pass (if only some jobs fail it may be advisable to restart them, since they seldom
fail at random).

If tests fail, see why here: http://mongooseim-ct-results.s3-website-eu-west-1.amazonaws.com/ and resolve any issues.
If the tests fail, you can see why here: https://esl.github.io/circleci-mim-results/s3_reports.html (the exact link is visible under the `Upload results` step) and resolve any issues.

## 2. Review

Both trivial and non-trivial PRs have to be reviewed by at least one other person from the core development team.
For big changesets consult the Tech Lead.
The reviewer's remarks should be placed as inline comments on github for future reference.
Both trivial and non-trivial PRs have to be reviewed by at least one person from the development team.

Then, apply the reviewer's suggestions.
If the changes are limited to documentation or code formatting, remember to prefix commit message with "[skip ci]" so as not to run redundant tests.

The reviewer should make sure all of their suggestions are applied.
It is the reviewer who actually does the merge, so he takes at least half of the responsibility.
It is the reviewer who actually does the merge, so he takes at some of the responsibility.

## 3. Merging

Expand All @@ -95,8 +68,7 @@ II. After rebase, push your branch with -f, make sure all tests pass.

III. Tell your reviewer he can proceed.

He hits the green button, and you can both celebrate.

IV. He hits the green button, and you can both celebrate.

# Contributing to mobile libraries

Expand All @@ -114,4 +86,4 @@ We highly encourage to go directly to upstream repositories, and follow the rele

# Influencing the MongooseIM roadmap

We do not have a specific process for community roadmap building. You are encouraged and welcome to influence the roadmap with GitHub issues, code contributions, or you can simply contact us to invent the future.
We do not have a specific process for community roadmap building. You are encouraged and welcome to influence the roadmap with GitHub issues, code contributions, or you can simply [contact us](https://www.erlang-solutions.com/contact/) to invent the future.
3 changes: 2 additions & 1 deletion big_tests/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
{suites, "tests", metrics_register_SUITE}.
{suites, "tests", metrics_roster_SUITE}.
{suites, "tests", metrics_session_SUITE}.
{suites, "tests", mod_aws_sns_SUITE}.
{suites, "tests", mod_blocking_SUITE}.
{suites, "tests", mod_event_pusher_rabbit_SUITE}.
{suites, "tests", mod_event_pusher_http_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}.
Expand Down Expand Up @@ -100,6 +100,7 @@
{suites, "tests", mam_send_message_SUITE}.
{suites, "tests", dynamic_domains_SUITE}.
{suites, "tests", auth_methods_for_c2s_SUITE}.
{suites, "tests", local_iq_SUITE}.

{config, ["test.config"]}.
{logdir, "ct_report"}.
Expand Down
1 change: 1 addition & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@

{suites, "tests", domain_removal_SUITE}.
{suites, "tests", auth_methods_for_c2s_SUITE}.
{suites, "tests", local_iq_SUITE}.

{config, ["dynamic_domains.config", "test.config"]}.

Expand Down
12 changes: 5 additions & 7 deletions big_tests/tests/accounts_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ required_modules() ->
[{mod_register, mod_register_options()}].

mod_register_options() ->
[{welcome_message, {"", ""}},
{ip_access, [{allow, "127.0.0.0/8"},
{deny, "0.0.0.0/0"}]},
{access, register},
{registration_watchers, []}].
config_parser_helper:mod_config(mod_register, #{ip_access => [{allow, "127.0.0.0/8"},
{deny, "0.0.0.0/0"}],
access => register}).

init_per_group(bad_cancelation, Config) ->
escalus:create_users(Config, escalus:get_users([alice]));
Expand Down Expand Up @@ -140,7 +138,7 @@ init_per_testcase(admin_notify, Config) ->
escalus:init_per_testcase(admin_notify, Config);
init_per_testcase(not_allowed_registration_cancelation, Config) ->
%% Use a configuration that will not allow inband cancelation (and registration).
reload_mod_register_option(Config, access, {access, none}),
reload_mod_register_option(Config, access, none),
escalus:init_per_testcase(not_allowed_registration_cancelation, Config);
init_per_testcase(registration_failure_timeout, Config) ->
Config1 = deny_everyone_registration(Config),
Expand Down Expand Up @@ -433,7 +431,7 @@ user_exists(Name, Config) ->
reload_mod_register_option(Config, Key, Value) ->
Host = host_type(),
Args = proplists:get_value(mod_register_options, Config),
Args1 = lists:keyreplace(Key, 1, Args, {Key, Value}),
Args1 = maps:put(Key, Value, Args),
dynamic_modules:restart(Host, mod_register, Args1).

restore_mod_register_options(Config) ->
Expand Down
3 changes: 2 additions & 1 deletion big_tests/tests/amp_big_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,8 @@ mam_modules(off) ->
[{mod_mam_meta, stopped}].

offline_modules(on) ->
[{mod_offline, [{access_max_user_messages, max_user_offline_messages}]}];
[{mod_offline, config_parser_helper:mod_config(mod_offline,
#{access_max_user_messages => max_user_offline_messages})}];
offline_modules(off) ->
[{mod_offline, stopped},
{mod_offline_stub, []}].
Expand Down
15 changes: 9 additions & 6 deletions big_tests/tests/connect_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ init_per_group(feature_order, Config) ->
configure_c2s_listener(Config, #{zlib => 10000,
tls => [starttls_required | common_tls_opts(Config)]}),
Config;
init_per_group(just_tls,Config)->
init_per_group(just_tls, Config)->
[{tls_module, just_tls} | Config];
init_per_group(fast_tls,Config)->
init_per_group(fast_tls, Config)->
[{tls_module, fast_tls} | Config];
init_per_group(proxy_protocol, Config) ->
configure_c2s_listener(Config, #{proxy_protocol => true}),
Expand Down Expand Up @@ -765,10 +765,13 @@ configure_c2s_listener(Config, ExtraC2SOpts) ->
mongoose_helper:restart_listener(mim(), NewC2SListener).

common_tls_opts(Config) ->
TLSModule = ?config(tls_module, Config),
[{tls_module, TLSModule},
{certfile, ?CERT_FILE},
{dhfile, ?DH_FILE}].
tls_module_opts(Config) ++ [{certfile, ?CERT_FILE}, {dhfile, ?DH_FILE}].

tls_module_opts(Config) ->
case ?config(tls_module, Config) of
undefined -> [];
Module -> [{tls_module, Module}]
end.

set_secure_connection_protocol(UserSpec, Version) ->
[{ssl_opts, [{versions, [Version]}]} | UserSpec].
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/disco_and_caps_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ user_can_query_server_info(Config) ->
%% Helpers

required_modules(disco_with_caps) ->
[{mod_caps, []},
[{mod_caps, config_parser_helper:default_mod_config(mod_caps)},
{mod_disco, default_mod_config(mod_disco)}];
required_modules(disco_with_extra_features) ->
[{mod_disco, mod_config(mod_disco, extra_disco_opts())}].
Expand Down
8 changes: 8 additions & 0 deletions big_tests/tests/domain_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
delete_configured_domains/0,
insert_domain/3,
delete_domain/2,
set_domain_password/3,
delete_domain_password/2,
make_metrics_prefix/1,
host_types/0,
host_types/1,
Expand Down Expand Up @@ -66,6 +68,12 @@ insert_persistent_domain(Node, Domain, HostType) ->
delete_persistent_domain(Node, Domain, HostType) ->
ok = rpc(Node, mongoose_domain_api, delete_domain, [Domain, HostType]).

set_domain_password(Node, Domain, Password) ->
ok = rpc(Node, mongoose_domain_api, set_domain_password, [Domain, Password]).

delete_domain_password(Node, Domain) ->
ok = rpc(Node, mongoose_domain_api, delete_domain_password, [Domain]).

for_each_configured_domain(F) ->
[for_each_configured_domain(F, Opts) || {_, Opts} <- ct:get_config(hosts)],
ok.
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ group_to_modules(private_removal) ->
group_to_modules(roster_removal) ->
[{mod_roster, mod_config(mod_roster, #{backend => rdbms})}];
group_to_modules(offline_removal) ->
[{mod_offline, [{backend, rdbms}]}];
[{mod_offline, mod_config(mod_offline, #{backend => rdbms})}];
group_to_modules(markers_removal) ->
[{mod_smart_markers, config_parser_helper:default_mod_config(mod_smart_markers)}];
group_to_modules(vcard_removal) ->
Expand Down
23 changes: 10 additions & 13 deletions big_tests/tests/domain_rest_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
stop_listener/1]).

-import(distributed_helper, [mim/0, mim2/0, require_rpc_nodes/1, rpc/4]).
-import(config_parser_helper, [default_config/1, config/2]).

-define(TEST_PORT, 8866).

Expand Down Expand Up @@ -98,23 +99,19 @@ patch_custom(Config, Role, Path, Body) ->

%% REST handler setup
start_listener(Params) ->
rpc(mim(), ejabberd_listener, start_listener, [listener_opts(Params)]).
rpc(mim(), mongoose_listener, start_listener, [listener_opts(Params)]).

stop_listener(Params) ->
rpc(mim(), ejabberd_listener, stop_listener, [listener_opts(Params)]).
rpc(mim(), mongoose_listener, stop_listener, [listener_opts(Params)]).

listener_opts(Params) ->
#{port => ?TEST_PORT,
ip_tuple => {127, 0, 0, 1},
ip_address => "127.0.0.1",
ip_version => 4,
proto => tcp,
module => ejabberd_cowboy,
modules => [domain_handler(Params)],
transport_options => transport_options()}.

transport_options() ->
[{max_connections, 1024}, {num_acceptors, 10}].
config([listen, http],
#{port => ?TEST_PORT,
ip_tuple => {127, 0, 0, 1},
ip_address => "127.0.0.1",
module => ejabberd_cowboy,
handlers => [domain_handler(Params)],
transport => config([listen, http, transport], #{num_acceptors => 10})}).

domain_handler(Params) ->
{"localhost", "/api", mongoose_domain_handler, handler_opts(Params)}.
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/dynamic_domains_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ init_per_group(with_mod_dynamic_domains_test, Config) ->
[ok = rpc(mim(), meck, new, [Module, [passthrough, no_link]])
|| Module <- MockedModules],
dynamic_modules:start(?HOST_TYPE, mod_dynamic_domains_test,
[{host1, subhost_pattern("subdomain1.@HOST@")},
{host2, subhost_pattern("subdomain2.@HOST@")},
{namespace, <<"dummy.namespace">>}]),
#{host1 => subhost_pattern("subdomain1.@HOST@"),
host2 => subhost_pattern("subdomain2.@HOST@"),
namespace => <<"dummy.namespace">>}),
[{reset_meck, MockedModules} | Config];
init_per_group(_, Config) ->
Config.
Expand Down
59 changes: 59 additions & 0 deletions big_tests/tests/dynamic_services.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
-module(dynamic_services).

-compile([export_all, nowarn_export_all]).

-import(distributed_helper, [mim/0, rpc/4]).

save_services(Config) ->
save_services(mim(), Config).

%% Save services from Node, overwriting previously saved services
save_services(Nodes, Config) when is_list(Nodes) ->
lists:foldl(fun save_services/2, Config, Nodes);
save_services(Node = #{node := NodeName}, Config) ->
Key = {saved_services, NodeName},
Value = get_current_services(Node),
lists:keystore(Key, 1, Config, {Key, Value}).

get_saved_config(Service, Config) ->
get_saved_config(mim(), Service, Config).

get_saved_config(#{node := NodeName}, Service, Config) ->
SavedServices = proplists:get_value({saved_services, NodeName}, Config),
maps:get(Service, SavedServices).

restore_services(Config) ->
restore_services(#{}, Config).

restore_services(RPCSpec, Config) when is_map(RPCSpec) ->
[restore_saved_services(RPCSpec#{node => NodeName}, SavedServices)
|| {{saved_services, NodeName}, SavedServices} <- Config],
Config.

restore_saved_services(Node, SavedServices) ->
CurrentServices = get_current_services(Node),
ToStop = maps:keys(CurrentServices) -- maps:keys(SavedServices),
rpc(Node, mongoose_service, replace_services, [ToStop, SavedServices]).

get_current_services() ->
get_current_services(mim()).

get_current_services(Node) ->
rpc(Node, mongoose_service, loaded_services_with_opts, []).

ensure_services(Node, RequiredServices) ->
ToStop = [M || {M, stopped} <- RequiredServices],
ToEnsure = maps:without(ToStop, maps:from_list(RequiredServices)),
rpc(Node, mongoose_service, replace_services, [ToStop, ToEnsure]).

ensure_stopped(Service) ->
ensure_stopped(mim(), Service).

ensure_stopped(Node, Service) ->
rpc(Node, mongoose_service, ensure_stopped, [Service]).

ensure_started(Service, Opts) ->
ensure_started(mim(), Service, Opts).

ensure_started(Node, Service, Opts) ->
rpc(Node, mongoose_service, ensure_started, [Service, Opts]).
Loading

0 comments on commit 331a993

Please sign in to comment.