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

Reorganize mod_announce test in order to avoid race

This commit is contained in:
Evgeniy Khramtsov 2014-07-28 13:42:29 +04:00
parent 7d93463d31
commit db3c469d4d

View File

@ -206,7 +206,7 @@ db_tests(riak) ->
[offline_master, offline_slave]}, [offline_master, offline_slave]},
{test_muc, [parallel], {test_muc, [parallel],
[muc_master, muc_slave]}, [muc_master, muc_slave]},
{test_announce, [parallel], {test_announce, [sequence],
[announce_master, announce_slave]}, [announce_master, announce_slave]},
{test_roster_remove, [parallel], {test_roster_remove, [parallel],
[roster_remove_master, [roster_remove_master,
@ -235,7 +235,7 @@ db_tests(mnesia) ->
[carbons_master, carbons_slave]}, [carbons_master, carbons_slave]},
{test_muc, [parallel], {test_muc, [parallel],
[muc_master, muc_slave]}, [muc_master, muc_slave]},
{test_announce, [parallel], {test_announce, [sequence],
[announce_master, announce_slave]}, [announce_master, announce_slave]},
{test_roster_remove, [parallel], {test_roster_remove, [parallel],
[roster_remove_master, [roster_remove_master,
@ -263,7 +263,7 @@ db_tests(_) ->
[offline_master, offline_slave]}, [offline_master, offline_slave]},
{test_muc, [parallel], {test_muc, [parallel],
[muc_master, muc_slave]}, [muc_master, muc_slave]},
{test_announce, [parallel], {test_announce, [sequence],
[announce_master, announce_slave]}, [announce_master, announce_slave]},
{test_roster_remove, [parallel], {test_roster_remove, [parallel],
[roster_remove_master, [roster_remove_master,
@ -1282,9 +1282,7 @@ muc_slave(Config) ->
announce_master(Config) -> announce_master(Config) ->
MyJID = my_jid(Config), MyJID = my_jid(Config),
ServerJID = server_jid(Config), ServerJID = server_jid(Config),
Peer = ?config(slave, Config),
MotdJID = jlib:jid_replace_resource(ServerJID, <<"announce/motd">>), MotdJID = jlib:jid_replace_resource(ServerJID, <<"announce/motd">>),
MotdDelJID = jlib:jid_replace_resource(ServerJID, <<"announce/motd/delete">>),
MotdText = #text{data = <<"motd">>}, MotdText = #text{data = <<"motd">>},
send(Config, #presence{}), send(Config, #presence{}),
#presence{from = MyJID} = recv(), #presence{from = MyJID} = recv(),
@ -1292,24 +1290,18 @@ announce_master(Config) ->
send(Config, #message{to = MotdJID, body = [MotdText]}), send(Config, #message{to = MotdJID, body = [MotdText]}),
%% Receive this message back %% Receive this message back
#message{from = ServerJID, body = [MotdText]} = recv(), #message{from = ServerJID, body = [MotdText]} = recv(),
wait_for_slave(Config),
%% Peer becomes available and then unavailable
#presence{from = Peer} = recv(),
#presence{from = Peer, type = unavailable} = recv(),
%% Delete message of the day
send(Config, #message{to = MotdDelJID}),
disconnect(Config). disconnect(Config).
announce_slave(Config) -> announce_slave(Config) ->
MyJID = my_jid(Config), MyJID = my_jid(Config),
ServerJID = server_jid(Config), ServerJID = server_jid(Config),
Peer = ?config(master, Config), MotdDelJID = jlib:jid_replace_resource(ServerJID, <<"announce/motd/delete">>),
MotdText = #text{data = <<"motd">>}, MotdText = #text{data = <<"motd">>},
wait_for_master(Config),
send(Config, #presence{}), send(Config, #presence{}),
?recv3(#presence{from = Peer}, ?recv2(#presence{from = MyJID},
#presence{from = MyJID},
#message{from = ServerJID, body = [MotdText]}), #message{from = ServerJID, body = [MotdText]}),
%% Delete message of the day
send(Config, #message{to = MotdDelJID}),
disconnect(Config). disconnect(Config).
offline_master(Config) -> offline_master(Config) ->