Skip to content

Commit

Permalink
Make get_backend helper use HostType
Browse files Browse the repository at this point in the history
Because backends can be running per host type. This also fixes an
issue of suites logging that they finished dirty, after having
dynamically compiled backends removed.

The old interface is called for the time being, but will be removed when
all modules will have dynamic backends converted.
  • Loading branch information
gustawlippa committed Oct 19, 2021
1 parent 1e065b8 commit bffd681
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
38 changes: 29 additions & 9 deletions big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

-export([is_rdbms_enabled/1,
mnesia_or_rdbms_backend/0,
get_backend_name/1]).
get_backend_name/2]).

-export([auth_modules/0]).

Expand Down Expand Up @@ -141,13 +141,30 @@ new_mongoose_acc(Location, Server) ->
clear_caps_cache(CapsNode) ->
ok = rpc(mim(), mod_caps, delete_caps, [CapsNode]).

get_backend(Module) ->
case rpc(mim(), Module, backend, []) of
{badrpc, _Reason} -> false;
Backend -> Backend
end.
get_backend(HostType, Module) ->
try rpc(mim(), mongoose_backend, get_backend_module, [HostType, Module])
catch
error:{badrpc, _Reason} ->
% TODO: get rid of this after dynamically compiled modules are gone
get_backend_old(Module)
end.

get_backend_name(HostType, Module) ->
try rpc(mim(), mongoose_backend, get_backend_name, [HostType, Module])
catch
error:{badrpc, _Reason} ->
% TODO: get rid of this after dynamically compiled modules are gone
% used by offline_SUITE
get_backend_name_old(Module)
end.

get_backend_old(Module) ->
case rpc(mim(), Module, backend, []) of
{badrpc, _Reason} -> false;
Backend -> Backend
end.

get_backend_name(Module) ->
get_backend_name_old(Module) ->
case rpc(mim(), Module, backend_name, []) of
{badrpc, _Reason} -> false;
Backend -> Backend
Expand All @@ -158,9 +175,12 @@ generic_count(mod_offline_backend, {LUser, LServer}) ->
rpc(mim(), mod_offline_backend, count_offline_messages, [HostType, LUser, LServer, 100]).

generic_count(Module) ->
case get_backend(Module) of
lists:sum([generic_count_per_host_type(HT, Module) || HT <- domain_helper:host_types()]).

generic_count_per_host_type(HostType, Module) ->
case get_backend(HostType, Module) of
false -> %% module disabled
false;
0;
B when is_atom(B) ->
generic_count_backend(B)
end.
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/offline_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ init_per_group(chatmarkers, C) ->
init_per_group(_, C) -> C.

with_groupchat_modules() ->
OfflineBackend = mongoose_helper:get_backend_name(mod_offline_backend),
OfflineBackend = mongoose_helper:get_backend_name(host_type(), mod_offline_backend),
MucLightBackend = mongoose_helper:mnesia_or_rdbms_backend(),
MucPattern = distributed_helper:subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_offline, [{store_groupchat_messages, true},
Expand Down

0 comments on commit bffd681

Please sign in to comment.