Skip to content

Commit

Permalink
Use host types acc_e2e_SUITE
Browse files Browse the repository at this point in the history
- Configure the host type in the test spec
- Remove domain_isolation_SUITE (for now)
  - It was passing before because both the test and the code
      were not using dynamic domains, it started failing
      after the previous commit, which fixed the code.
  - The module itself has a bug (reported)
  - It uses MUC Light which lacks dynamic domain support (for now)
  - It needs to use host types
  • Loading branch information
chrzaszcz committed May 6, 2021
1 parent d3a36c6 commit f29e37d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
1 change: 1 addition & 0 deletions big_tests/dynamic_domains.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{domain, <<"domain.example.com">>},
{secondary_domain, <<"domain.example.org">>},
{dynamic_domains, [<<"domain.example.com">>, <<"domain.example.org">>]},
{host_type, <<"test type">>},
{vars, "mim1"},
{cluster, mim},
{s2s_port, 5269},
Expand Down
2 changes: 1 addition & 1 deletion big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
%% http://www.erlang.org/doc/apps/common_test/run_test_chapter.html#test_specifications
{include, "tests"}.

{suites, "tests", domain_isolation_SUITE}.
{suites, "tests", acc_e2e_SUITE}.

{config, ["dynamic_domains.config", "test.config"]}.
{logdir, "ct_report"}.
Expand Down
7 changes: 4 additions & 3 deletions big_tests/tests/acc_e2e_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ acc_test_helper_code(Config) ->
binary_to_list(Code).

add_handler(Hook, F, Seq) ->
rpc(mim(), ejabberd_hooks, add, [Hook, host(), acc_test_helper, F, Seq]).
rpc(mim(), ejabberd_hooks, add, handler(Hook, F, Seq)).

remove_handler(Hook, F, Seq) ->
rpc(mim(), ejabberd_hooks, delete, [Hook, host(), acc_test_helper, F, Seq]).
rpc(mim(), ejabberd_hooks, delete, handler(Hook, F, Seq)).

host() -> <<"localhost">>.
handler(Hook, F, Seq) ->
[Hook, domain_helper:host_type(mim), acc_test_helper, F, Seq].

%% creates a temporary ets table keeping refs and some attrs of accumulators created in c2s
recreate_table() ->
Expand Down
28 changes: 18 additions & 10 deletions big_tests/tests/domain_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,35 @@

-export([insert_configured_domains/0,
delete_configured_domains/0,
insert_domain/2,
delete_domain/2]).
insert_domain/3,
delete_domain/2,
host_type/1,
host_type/2]).

-import(distributed_helper, [get_or_fail/1, rpc/4]).

host_type(NodeKey) ->
host_type(NodeKey, domain).

host_type(NodeKey, DomainKey) ->
Node = #{node => get_or_fail({hosts, NodeKey, node})},
Domain = get_or_fail({hosts, NodeKey, DomainKey}),
{ok, HostType} = rpc(Node, mongoose_domain_core, get_host_type, [Domain]),
HostType.

insert_configured_domains() ->
for_each_configured_domain(fun insert_domain/2).
for_each_configured_domain(fun insert_domain/3).

delete_configured_domains() ->
for_each_configured_domain(fun delete_domain/2).
for_each_configured_domain(fun(Node, Domain, _) -> delete_domain(Node, Domain) end).

insert_domain(Node, Domain) ->
ok = rpc(Node, mongoose_domain_core, insert, [Domain, host_type(), dummy_source]).
insert_domain(Node, Domain, HostType) ->
ok = rpc(Node, mongoose_domain_core, insert, [Domain, HostType, dummy_source]).

delete_domain(Node, Domain) ->
ok = rpc(Node, mongoose_domain_core, delete, [Domain]).

for_each_configured_domain(F) ->
[F(#{node => proplists:get_value(node, Opts)}, Domain) ||
[F(#{node => proplists:get_value(node, Opts)}, Domain, proplists:get_value(host_type, Opts)) ||
{_, Opts} <- ct:get_config(hosts),
Domain <- proplists:get_value(dynamic_domains, Opts, [])].

host_type() ->
<<"test type">>. %% preconfigured in the toml file
2 changes: 1 addition & 1 deletion big_tests/tests/dynamic_domains_pm_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ auth_domain_removal_is_triggered_on_hook(_Config) ->

%% helper functions
insert_domains(Nodes, Domains) ->
[domain_helper:insert_domain(Node, Domain) || Node <- Nodes, Domain <- Domains].
[domain_helper:insert_domain(Node, Domain, ?HOST_TYPE) || Node <- Nodes, Domain <- Domains].

remove_domains(Nodes, Domains) ->
[domain_helper:delete_domain(Node, Domain) || Node <- Nodes, Domain <- Domains].
Expand Down

0 comments on commit f29e37d

Please sign in to comment.