Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify stream management suite #3453

Merged
merged 26 commits into from
Dec 17, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6496381
Make some common functions
arcusfelis Dec 13, 2021
61c294c
Use connect_fresh function
arcusfelis Dec 13, 2021
2e9b40a
Cleaner short cases with connect_fresh
arcusfelis Dec 13, 2021
7cafc30
Use connect_fresh for simple cases
arcusfelis Dec 14, 2021
e3c0fe9
Remove sleep in preserve_order
arcusfelis Dec 14, 2021
fff5c6d
Use connect_spec
arcusfelis Dec 14, 2021
6cb92ee
Add connect_same
arcusfelis Dec 14, 2021
927ee04
Simplify buffer_unacked_messages_and_die
arcusfelis Dec 14, 2021
31a3eb5
Specify manual_ack each time
arcusfelis Dec 14, 2021
c406be8
Provide ack argument into connect_fresh
arcusfelis Dec 14, 2021
48f99df
More connect_spec usage
arcusfelis Dec 14, 2021
00d4153
Remove node argument from get_session_pid
arcusfelis Dec 14, 2021
2705b1a
Remove wait_for_c2s_state
arcusfelis Dec 14, 2021
f202966
Move wait_for_c2s_state_name into mongoose_helper
arcusfelis Dec 14, 2021
aaee737
Use connect_same in kill_and_connect_with_resume_session_without_wait…
arcusfelis Dec 14, 2021
eb38790
Use chat_to_short_jid where get_bjid has been used before
arcusfelis Dec 15, 2021
edecf71
Exterminate fully-qualified calls in mongoose_helper
arcusfelis Dec 15, 2021
ced1ded
Remove default timer:seconds from wait_for_c2s_unacked_count
arcusfelis Dec 15, 2021
94d43ae
Move functions into sm_helper
arcusfelis Dec 15, 2021
7f9159c
Use connect_fresh with server_returns_failed
arcusfelis Dec 15, 2021
82b7113
Remove clear_session_table
arcusfelis Dec 15, 2021
e00a9ef
Get rid of last manual_ack confusion
arcusfelis Dec 15, 2021
3d7cf11
Remove exports from sm_SUITE
arcusfelis Dec 15, 2021
b0b9748
Dont import rarely used functions
arcusfelis Dec 15, 2021
27e5068
Enforce order in preserve_order
arcusfelis Dec 16, 2021
7bb63ff
Print expected and received texts in sm_helper:assert_messages
arcusfelis Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions big_tests/tests/mongoose_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
-export([make_jid/2]).
-export([make_jid/3]).
-export([make_jid_noprep/3]).
-export([get_session_pid/1]).
-export([get_session_pid/2]).
-export([get_session_info/2]).
-export([wait_for_route_message_count/2]).
Expand All @@ -48,6 +49,8 @@
-export([print_debug_info_for_module/1]).
-export([backup_and_set_config/2, backup_and_set_config_option/3, change_config_option/3]).
-export([restore_config/1, restore_config_option/2]).
-export([wait_for_n_offline_messages/2]).
-export([wait_for_c2s_state_name/2, get_c2s_state_name/1]).

-import(distributed_helper, [mim/0, rpc/4]).

Expand Down Expand Up @@ -440,6 +443,9 @@ make_jid(User, Server) ->
make_jid(User, Server, Resource) ->
jid:make(User, Server, Resource).

get_session_pid(User) ->
get_session_pid(User, mim()).

get_session_pid(User, Node) ->
Resource = escalus_client:resource(User),
Username = escalus_client:username(User),
Expand Down Expand Up @@ -562,3 +568,22 @@ do_restore_config_option(Option, {ok, Value}) ->
rpc(mim(), mongoose_config, set_opt, [Option, Value]);
do_restore_config_option(Option, {error, not_found}) ->
rpc(mim(), mongoose_config, unset_opt, [Option]).

wait_for_n_offline_messages(Client, N) ->
LUser = escalus_utils:jid_to_lower(escalus_client:username(Client)),
LServer = escalus_utils:jid_to_lower(escalus_client:server(Client)),
WaitFn = fun() -> mongoose_helper:total_offline_messages({LUser, LServer}) end,
NelsonVides marked this conversation as resolved.
Show resolved Hide resolved
wait_until(WaitFn, N).

wait_for_c2s_state_name(C2SPid, NewStateName) ->
wait_until(fun() -> get_c2s_state_name(C2SPid) end, NewStateName,
#{name => get_c2s_state_name, time_left => timer:seconds(5)}).
NelsonVides marked this conversation as resolved.
Show resolved Hide resolved

get_c2s_state_name(C2SPid) when is_pid(C2SPid) ->
SysStatus = rpc(mim(), sys, get_status, [C2SPid]),
extract_state_name(SysStatus).

extract_state_name(SysStatus) ->
{status, _Pid, {module, _},
[_, _, _, _, [_, {data, FSMData} | _]]} = SysStatus,
proplists:get_value("StateName", FSMData).
7 changes: 1 addition & 6 deletions big_tests/tests/offline_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-define(NS_FEATURE_MSGOFFLINE, <<"msgoffline">>).

-import(domain_helper, [host_type/0]).
-import(mongoose_helper, [wait_for_n_offline_messages/2]).

%%%===================================================================
%%% Suite configuration
Expand Down Expand Up @@ -370,12 +371,6 @@ has_element_with_ns(Stanza, Element, NS) ->
%%%===================================================================
%%% Helpers
%%%===================================================================
wait_for_n_offline_messages(Client, N) ->
LUser = escalus_utils:jid_to_lower(escalus_client:username(Client)),
LServer = escalus_utils:jid_to_lower(escalus_client:server(Client)),
WaitFn = fun() -> mongoose_helper:total_offline_messages({LUser, LServer}) end,
mongoose_helper:wait_until(WaitFn, N).

logout(Config, User) ->
mongoose_helper:logout_user(Config, User).

Expand Down
Loading