Skip to content

Commit d0875c9

Browse files
committed
amqp_client_SUITE: Load test module on broker before using one of its anonymous functions
[Why] Before this change, when the `idle_time_out_on_server/1` test case was runned first in the shuffled test group, the test module was not loaded on the remote broker. When the anonymous function was passed to meck and was executed, we got the following crash on the broker: crasher: initial call: rabbit_heartbeat:'-heartbeater/2-fun-0-'/0 pid: <0.704.0> registered_name: [] exception error: {undef, [{#Fun<amqp_client_SUITE.14.116163631>, [#Port<0.45>,[recv_oct]], []}, {rabbit_heartbeat,get_sock_stats,3, [{file,"rabbit_heartbeat.erl"},{line,175}]}, {rabbit_heartbeat,heartbeater,3, [{file,"rabbit_heartbeat.erl"},{line,155}]}, {proc_lib,init_p,3, [{file,"proc_lib.erl"},{line,317}]}, {rabbit_net,getstat,[#Port<0.45>,[recv_oct]],[]}]} This led to a failure of the test case later, when it waited for a message from the connecrtion. We do the same in two other test cases where this is likely to happen too. [How] Loading the module first fixes the problem.
1 parent bbc704e commit d0875c9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,11 @@ link_target_queue_deleted(QType, Config) ->
18671867
ok = amqp10_client:send_msg(Sender, amqp10_msg:new(DTag1, <<"m1">>, false)),
18681868
ok = wait_for_accepted(DTag1),
18691869

1870+
%% Load test module on the broker: we reference an anonymous function
1871+
%% from it during the configuration of meck.
1872+
[_ | _] = rabbit_ct_broker_helpers:rpc(
1873+
Config, ?MODULE, module_info, []),
1874+
18701875
%% Mock delivery to the target queue to do nothing.
18711876
rabbit_ct_broker_helpers:setup_meck(Config, [?MODULE]),
18721877
Mod = rabbit_queue_type,
@@ -1927,6 +1932,11 @@ target_queues_deleted_accepted(Config) ->
19271932
ok = amqp10_client:send_msg(Sender, amqp10_msg:new(DTag1, <<"m1">>, false)),
19281933
ok = wait_for_accepted(DTag1),
19291934

1935+
%% Load test module on the broker: we reference an anonymous function
1936+
%% from it during the configuration of meck.
1937+
[_ | _] = rabbit_ct_broker_helpers:rpc(
1938+
Config, ?MODULE, module_info, []),
1939+
19301940
%% Mock to deliver only to q1.
19311941
rabbit_ct_broker_helpers:setup_meck(Config, [?MODULE]),
19321942
Mod = rabbit_queue_type,
@@ -4726,6 +4736,11 @@ idle_time_out_on_server(Config) ->
47264736
after 30000 -> ct:fail({missing_event, ?LINE})
47274737
end,
47284738

4739+
%% Load test module on the broker: we reference an anonymous function
4740+
%% from it during the configuration of meck.
4741+
[_ | _] = rabbit_ct_broker_helpers:rpc(
4742+
Config, ?MODULE, module_info, []),
4743+
47294744
%% Mock the server socket to not have received any bytes.
47304745
rabbit_ct_broker_helpers:setup_meck(Config),
47314746
ok = rpc(Config, meck, new, [Mod, [no_link, passthrough]]),

0 commit comments

Comments
 (0)