Skip to content

Commit 4a2dae6

Browse files
authored
Merge pull request #1808 (Fix account reusage in ejabberdctl_SUITE)
Properly handle resource reusing between stories in ejabberdctl_SUITE
2 parents a13ee79 + 86f9671 commit 4a2dae6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

big_tests/tests/cluster_commands_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ run_interactive(Cmd, Response, Timeout) ->
401401
Port = erlang:open_port({spawn, Cmd}, [exit_status]),
402402
%% respond to interactive question (yes/no)
403403
Port ! {self(), {command, Response}},
404-
ejabberdctl_helper:loop(Port, [], Timeout).
404+
ejabberdctl_helper:loop(Cmd, Port, [], Timeout).
405405

406406
nodes_clustered(Node1, Node2, ShouldBe) ->
407407
DbNodes1 = distributed_helper:rpc(Node1, mnesia, system_info, [db_nodes]),

big_tests/tests/ejabberdctl_SUITE.erl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ end_per_testcase(delete_old_users, Config) ->
193193
end, Users),
194194
escalus:end_per_testcase(delete_old_users, Config);
195195
end_per_testcase(CaseName, Config) ->
196+
%% Because kick_session fails with unexpected stanza received:
197+
%% <presence from="alicE@localhost/res3"
198+
%% to="alice@localhost/res1" type="unavailable" />
199+
%% TODO: Remove when escalus learns how to automatically deal
200+
%% with 'unavailable' stanzas on client stop.
201+
mongoose_helper:kick_everyone(),
196202
escalus:end_per_testcase(CaseName, Config).
197203

198204
%%--------------------------------------------------------------------
@@ -454,7 +460,8 @@ rosteritem_rw(Config) ->
454460
{Items2, 0} = ejabberdctl("get_roster", [AliceName, Domain], Config),
455461
match_roster([{MikeName, Domain, "MyMike", "MyGroup", "both"}], Items2),
456462

457-
escalus:send(Alice, escalus_stanza:roster_remove_contact(MikeJid)) % cleanup
463+
escalus:send(Alice, escalus_stanza:roster_remove_contact(MikeJid)), % cleanup
464+
escalus:wait_for_stanzas(Alice, 2, 5000)
458465
end).
459466

460467
presence_after_add_rosteritem(Config) ->
@@ -468,7 +475,9 @@ presence_after_add_rosteritem(Config) ->
468475
escalus:send(Alice, escalus_stanza:presence(<<"available">>)),
469476
escalus:assert(is_presence, escalus:wait_for_stanza(Bob)),
470477

471-
escalus:send(Alice, escalus_stanza:roster_remove_contact(BobJid)) % cleanup
478+
escalus:send(Alice, escalus_stanza:roster_remove_contact(BobJid)), % cleanup
479+
%% Wait for stanzas, so they would not end up in the next story
480+
escalus:wait_for_stanzas(Alice, 3, 5000)
472481
end).
473482

474483
push_roster(Config) ->
@@ -483,7 +492,8 @@ push_roster(Config) ->
483492
escalus:assert(is_roster_result, Roster1),
484493
escalus:assert(roster_contains, [BobJid], Roster1),
485494

486-
escalus:send(Alice, escalus_stanza:roster_remove_contact(BobJid)) % cleanup
495+
escalus:send(Alice, escalus_stanza:roster_remove_contact(BobJid)), % cleanup
496+
escalus:wait_for_stanzas(Alice, 2, 5000)
487497
end).
488498

489499
process_rosteritems_list_simple(Config) ->

big_tests/tests/ejabberdctl_helper.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ run(Cmd) ->
4343

4444
run(Cmd, Timeout) ->
4545
Port = erlang:open_port({spawn, Cmd},[exit_status]),
46-
loop(Port,[], Timeout).
46+
loop(Cmd, Port, [], Timeout).
4747

48-
loop(Port, Data, Timeout) ->
48+
loop(Cmd, Port, Data, Timeout) ->
4949
receive
50-
{Port, {data, NewData}} -> loop(Port, Data++NewData, Timeout);
50+
{Port, {data, NewData}} -> loop(Cmd, Port, Data++NewData, Timeout);
5151
{Port, {exit_status, ExitStatus}} -> {Data, ExitStatus}
5252
after Timeout ->
53-
throw(timeout)
53+
erlang:error(#{reason => timeout, command => Cmd})
5454
end.

0 commit comments

Comments
 (0)