25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Add tests for offline use_mam_for_storage

This commit is contained in:
Paweł Chmielowski 2019-04-29 11:35:18 +02:00
parent 830a2f209a
commit b716b835c4
2 changed files with 28 additions and 3 deletions

View File

@ -44,7 +44,7 @@
%% Deprecated functions %% Deprecated functions
-export([get_opt/3, get_opt/4, get_module_opt/4, get_module_opt/5, -export([get_opt/3, get_opt/4, get_module_opt/4, get_module_opt/5,
get_opt_host/3, get_opt_hosts/3, db_type/2, db_type/3, get_opt_host/3, get_opt_hosts/3, db_type/2, db_type/3,
ram_db_type/2, ram_db_type/3]). ram_db_type/2, ram_db_type/3, update_module_opts/3]).
-deprecated([{get_opt, 3}, -deprecated([{get_opt, 3},
{get_opt, 4}, {get_opt, 4},
{get_opt_host, 3}, {get_opt_host, 3},
@ -305,6 +305,19 @@ store_options(Host, Module, Opts, Order) ->
#ejabberd_module{module_host = {Module, Host}, #ejabberd_module{module_host = {Module, Host},
opts = Opts, order = Order}). opts = Opts, order = Order}).
-spec update_module_opts(binary(), module(), opts()) -> ok | {ok, pid()} | error.
update_module_opts(Host, Module, NewValues) ->
case ets:lookup(ejabberd_modules, {Module, Host}) of
#ejabberd_module{opts = Opts, order = Order} ->
NewOpts = lists:foldl(
fun({K, _} = KV, Acc) ->
lists:keystore(K, 1, Acc, KV)
end, Opts, NewValues),
reload_module(Host, Module, NewOpts, Opts, Order);
_ ->
error
end.
maybe_halt_ejabberd() -> maybe_halt_ejabberd() ->
case is_app_running(ejabberd) of case is_app_running(ejabberd) of
false -> false ->

View File

@ -144,7 +144,8 @@ unsupported_iq(Config) ->
master_slave_cases() -> master_slave_cases() ->
{offline_master_slave, [sequence], {offline_master_slave, [sequence],
[master_slave_test(flex), [master_slave_test(flex),
master_slave_test(send_all)]}. master_slave_test(send_all),
master_slave_test(from_mam)]}.
flex_master(Config) -> flex_master(Config) ->
send_messages(Config, 5), send_messages(Config, 5),
@ -174,6 +175,17 @@ flex_slave(Config) ->
0 = get_number(Config), 0 = get_number(Config),
clean(disconnect(Config)). clean(disconnect(Config)).
offline_from_mam_master(Config) ->
Server = ?config(server, Config),
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]),
send_all_master(Config),
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]),
wait_for_slave(Config).
offline_from_mam_slave(Config) ->
send_all_slave(Config),
wait_for_master(Config).
send_all_master(Config) -> send_all_master(Config) ->
wait_for_slave(Config), wait_for_slave(Config),
Peer = ?config(peer, Config), Peer = ?config(peer, Config),
@ -298,7 +310,7 @@ get_nodes(Config) ->
MyBareJID = jid:remove_resource(MyJID), MyBareJID = jid:remove_resource(MyJID),
Peer = ?config(peer, Config), Peer = ?config(peer, Config),
Peer_s = jid:encode(Peer), Peer_s = jid:encode(Peer),
ct:comment("Getting headers"), ct:comment("Getting headers"),
#iq{type = result, #iq{type = result,
sub_els = [#disco_items{ sub_els = [#disco_items{
node = ?NS_FLEX_OFFLINE, node = ?NS_FLEX_OFFLINE,