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

Add race_conditions_SUITE to dynamic_domains #3283

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Changes from all commits
Commits
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
21 changes: 12 additions & 9 deletions big_tests/tests/race_conditions_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
-module(race_conditions_SUITE).
-compile(export_all).

-export([handle_delayiq_iq/4]).
-export([handle_delayiq_iq/5]).

-include_lib("escalus/include/escalus.hrl").
-include_lib("exml/include/exml.hrl").
-include_lib("common_test/include/ct.hrl").

-include("mam_helper.hrl"). %% mam? we need assert_equal_extra

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

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

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -131,21 +133,22 @@ ignore_iq_result_from_old_session(Config) ->

start_delayiq_handler() ->
NS = delayiq_ns(),
Domain = domain(),
HostType = host_type(),
%% Register our module as an iq handler.
%% It's important to use IQDisc=parallel, because
%% this particular IQ should be executed in a separate process.
Args = [ejabberd_sm, Domain, NS, ?MODULE, handle_delayiq_iq, parallel],
mongoose_helper:successful_rpc(gen_iq_handler, add_iq_handler, Args).
rpc(mim(), gen_iq_handler, add_iq_handler_for_domain,
[HostType, NS, ejabberd_sm,
fun ?MODULE:handle_delayiq_iq/5, #{}, parallel]).

stop_delayiq_handler() ->
NS = delayiq_ns(),
Domain = domain(),
HostType = host_type(),
%% Register our module as an iq handler.
%% It's important to use IQDisc=parallel, because
%% this particular IQ should be executed in a separate process.
Args = [ejabberd_sm, Domain, NS],
mongoose_helper:successful_rpc(gen_iq_handler, remove_iq_handler, Args).
rpc(mim(), gen_iq_handler, remove_iq_handler_for_domain,
[HostType, NS, ejabberd_sm]).

%% Brand new IQ namespace.
%% Send IQ get with this namespace, and MongooseIM would send you
Expand All @@ -162,7 +165,7 @@ delayiq_iq() ->
escalus_stanza:iq_get(delayiq_ns(), [Payload]).

%% This function is executed by MongooseIM
handle_delayiq_iq(_From, _To, Acc, IQ) ->
handle_delayiq_iq(Acc, _From, _To, IQ, _Extra) ->
SubEl = mongoose_iq:iq_to_sub_el(IQ),
BinCallerPid = exml_query:path(SubEl, [{element, <<"data">>},
{attr, <<"caller_pid">>}]),
Expand Down