Skip to content

Commit

Permalink
Merge pull request #3221 from esl/mu-vcard-host-types
Browse files Browse the repository at this point in the history
Host types for mod_vcard
  • Loading branch information
chrzaszcz committed Aug 25, 2021
2 parents 622f2ee + 2b05908 commit 413e706
Show file tree
Hide file tree
Showing 17 changed files with 607 additions and 479 deletions.
3 changes: 3 additions & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@

{suites, "tests", sm_SUITE}.

{suites, "tests", vcard_SUITE}.
{suites, "tests", vcard_simple_SUITE}.

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

{logdir, "ct_report"}.
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/cluster_commands_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ run_interactive(Cmd, Response, Timeout) ->
Port = erlang:open_port({spawn, Cmd}, [exit_status]),
%% respond to interactive question (yes/no)
Port ! {self(), {command, Response}},
ejabberdctl_helper:loop(Cmd, Port, [], Timeout).
ejabberdctl_helper:loop(Cmd, [], Port, [], Timeout).

nodes_clustered(#{node := Node1Name} = Node1, #{node := Node2Name} = Node2, ShouldBe) ->
DbNodes1 = distributed_helper:rpc(Node1, mnesia, system_info, [db_nodes]),
Expand Down
15 changes: 11 additions & 4 deletions big_tests/tests/ejabberdctl_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ run(Cmd, Args, Opts) ->
run(Cmd, Args, Opts, Timeout) ->
Port = erlang:open_port({spawn_executable, Cmd},
[exit_status, {args, Args} | Opts]),
loop(Cmd, Port, [], Timeout).
loop(Cmd, Args, Port, [], Timeout).

loop(Cmd, Port, Data, Timeout) ->
loop(Cmd, Args, Port, Data, Timeout) ->
receive
{Port, {data, NewData}} -> loop(Cmd, Port, Data++NewData, Timeout);
{Port, {exit_status, ExitStatus}} -> {Data, ExitStatus}
{Port, {data, NewData}} -> loop(Cmd, Args, Port, Data++NewData, Timeout);
{Port, {exit_status, ExitStatus}} ->
log_command(Cmd, Args, Data, ExitStatus),
{Data, ExitStatus}
after Timeout ->
erlang:error(#{reason => timeout, command => Cmd})
end.

log_command(Cmd, Args, Data, ExitStatus) ->
Pattern = lists:flatten(lists:duplicate(length(Args), " ~s")),
ct:log("Execute ~s " ++ Pattern ++ "~nResult ~p~nExitStatus ~p",
[Cmd] ++ Args ++ [Data, ExitStatus]).
26 changes: 26 additions & 0 deletions big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
-export([restart_listener_with_opts/3]).
-export([should_minio_be_running/1]).
-export([new_mongoose_acc/1]).
-export([print_debug_info_for_module/1]).
-export([get_vcard_config/1]).

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

Expand Down Expand Up @@ -509,3 +511,27 @@ should_minio_be_running(Config) ->
lists:member(minio, DBs)
end.

%% It is useful to debug dynamic IQ handler registration
print_debug_info_for_module(Module) ->
ModConfig = rpc(mim(), gen_mod, hosts_and_opts_with_module, [mod_vcard]),
IqConfig = rpc(mim(), ets, tab2list, [sm_iqtable]),
ct:pal("hosts_and_opts=~p~n iq_handlers=~p~n",
[ModConfig, IqConfig]).

get_vcard_config(Config) ->
Preset = proplists:get_value(preset, Config, undefined),
Backend = preset_to_vcard_backend(Preset),
[{backend, Backend}, {host, {prefix, <<"vjud.">>}}]
++ vcard_backend_specific_options(Backend).

vcard_backend_specific_options(ldap) ->
[{ldap_base, "ou=Users,dc=esl,dc=com"},
{ldap_filter, "(objectClass=inetOrgPerson)"}];
vcard_backend_specific_options(_) ->
[].

preset_to_vcard_backend("ldap_mnesia") -> ldap;
preset_to_vcard_backend("riak_mnesia") -> riak;
preset_to_vcard_backend("internal_mnesia") -> mnesia;
preset_to_vcard_backend("elasticsearch_and_cassandra_mnesia") -> mnesia;
preset_to_vcard_backend(_) -> rdbms.
Loading

0 comments on commit 413e706

Please sign in to comment.