mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Add tests for offline with mam storage
This commit is contained in:
parent
c550d36581
commit
eff70951c5
@ -308,14 +308,15 @@ store_options(Host, Module, Opts, Order) ->
|
|||||||
-spec update_module_opts(binary(), module(), opts()) -> ok | {ok, pid()} | error.
|
-spec update_module_opts(binary(), module(), opts()) -> ok | {ok, pid()} | error.
|
||||||
update_module_opts(Host, Module, NewValues) ->
|
update_module_opts(Host, Module, NewValues) ->
|
||||||
case ets:lookup(ejabberd_modules, {Module, Host}) of
|
case ets:lookup(ejabberd_modules, {Module, Host}) of
|
||||||
#ejabberd_module{opts = Opts, order = Order} ->
|
[#ejabberd_module{opts = Opts, order = Order}] ->
|
||||||
NewOpts = lists:foldl(
|
NewOpts = lists:foldl(
|
||||||
fun({K, _} = KV, Acc) ->
|
fun({K, _} = KV, Acc) ->
|
||||||
lists:keystore(K, 1, Acc, KV)
|
lists:keystore(K, 1, Acc, KV)
|
||||||
end, Opts, NewValues),
|
end, Opts, NewValues),
|
||||||
reload_module(Host, Module, NewOpts, Opts, Order);
|
reload_module(Host, Module, NewOpts, Opts, Order);
|
||||||
_ ->
|
Other ->
|
||||||
error
|
?WARNING_MSG("Unable to update module opts: (~p, ~p) -> ~p",
|
||||||
|
[Host, Module, Other])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
maybe_halt_ejabberd() ->
|
maybe_halt_ejabberd() ->
|
||||||
|
@ -175,16 +175,20 @@ flex_slave(Config) ->
|
|||||||
0 = get_number(Config),
|
0 = get_number(Config),
|
||||||
clean(disconnect(Config)).
|
clean(disconnect(Config)).
|
||||||
|
|
||||||
offline_from_mam_master(Config) ->
|
from_mam_master(Config) ->
|
||||||
|
C2 = lists:keystore(mam_enabled, 1, Config, {mam_enabled, true}),
|
||||||
|
C3 = send_all_master(C2),
|
||||||
|
lists:keydelete(mam_enabled, 1, C3).
|
||||||
|
|
||||||
|
from_mam_slave(Config) ->
|
||||||
Server = ?config(server, Config),
|
Server = ?config(server, Config),
|
||||||
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]),
|
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, true}]),
|
||||||
send_all_master(Config),
|
ok = mam_tests:set_default(Config, always),
|
||||||
|
C2 = lists:keystore(mam_enabled, 1, Config, {mam_enabled, true}),
|
||||||
|
C3 = send_all_slave(C2),
|
||||||
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]),
|
gen_mod:update_module_opts(Server, mod_offline, [{use_mam_for_storage, false}]),
|
||||||
wait_for_slave(Config).
|
C4 = lists:keydelete(mam_enabled, 1, C3),
|
||||||
|
mam_tests:clean(C4).
|
||||||
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),
|
||||||
@ -197,8 +201,10 @@ send_all_master(Config) ->
|
|||||||
Acc;
|
Acc;
|
||||||
(Msg, Acc) ->
|
(Msg, Acc) ->
|
||||||
I = send(Config, Msg#message{to = BarePeer}),
|
I = send(Config, Msg#message{to = BarePeer}),
|
||||||
case xmpp:get_subtag(Msg, #xevent{}) of
|
case {xmpp:get_subtag(Msg, #offline{}), xmpp:get_subtag(Msg, #xevent{})} of
|
||||||
#xevent{offline = true, id = undefined} ->
|
{#offline{}, _} ->
|
||||||
|
ok;
|
||||||
|
{_, #xevent{offline = true, id = undefined}} ->
|
||||||
ct:comment("Receiving event-reply for:~n~s",
|
ct:comment("Receiving event-reply for:~n~s",
|
||||||
[xmpp:pp(Msg)]),
|
[xmpp:pp(Msg)]),
|
||||||
#message{} = Reply = recv_message(Config),
|
#message{} = Reply = recv_message(Config),
|
||||||
@ -222,6 +228,8 @@ send_all_master(Config) ->
|
|||||||
send_all_slave(Config) ->
|
send_all_slave(Config) ->
|
||||||
ServerJID = server_jid(Config),
|
ServerJID = server_jid(Config),
|
||||||
Peer = ?config(peer, Config),
|
Peer = ?config(peer, Config),
|
||||||
|
#presence{} = send_recv(Config, #presence{}),
|
||||||
|
send(Config, #presence{type = unavailable}),
|
||||||
wait_for_master(Config),
|
wait_for_master(Config),
|
||||||
peer_down = get_event(Config),
|
peer_down = get_event(Config),
|
||||||
#presence{} = send_recv(Config, #presence{}),
|
#presence{} = send_recv(Config, #presence{}),
|
||||||
@ -422,12 +430,14 @@ message_iterator(Config) ->
|
|||||||
Body <- [[], xmpp:mk_text(<<"body">>)],
|
Body <- [[], xmpp:mk_text(<<"body">>)],
|
||||||
Subject <- [[], xmpp:mk_text(<<"subject">>)],
|
Subject <- [[], xmpp:mk_text(<<"subject">>)],
|
||||||
Els <- AllEls],
|
Els <- AllEls],
|
||||||
|
MamEnabled = ?config(mam_enabled, Config) == true,
|
||||||
lists:partition(
|
lists:partition(
|
||||||
fun(#message{type = error}) -> true;
|
fun(#message{type = error}) -> true;
|
||||||
(#message{type = groupchat}) -> false;
|
(#message{type = groupchat}) -> false;
|
||||||
(#message{sub_els = [#offline{}|_]}) -> false;
|
(#message{sub_els = [#hint{type = store}|_]}) when MamEnabled -> true;
|
||||||
(#message{sub_els = [_, #xevent{id = I}]}) when I /= undefined -> false;
|
(#message{sub_els = [#offline{}|_]}) when not MamEnabled -> false;
|
||||||
(#message{sub_els = [#xevent{id = I}]}) when I /= undefined -> false;
|
(#message{sub_els = [_, #xevent{id = I}]}) when I /= undefined, not MamEnabled -> false;
|
||||||
|
(#message{sub_els = [#xevent{id = I}]}) when I /= undefined, not MamEnabled -> false;
|
||||||
(#message{sub_els = [#hint{type = store}|_]}) -> true;
|
(#message{sub_els = [#hint{type = store}|_]}) -> true;
|
||||||
(#message{sub_els = [#hint{type = 'no-store'}|_]}) -> false;
|
(#message{sub_els = [#hint{type = 'no-store'}|_]}) -> false;
|
||||||
(#message{body = [], subject = []}) -> false;
|
(#message{body = [], subject = []}) -> false;
|
||||||
|
Loading…
Reference in New Issue
Block a user