Skip to content

Commit

Permalink
MQTT auth_SUITE: terminate setup process
Browse files Browse the repository at this point in the history
Configuring the mock authentication backend blocks
and generates an error in the test process when the
broker goes down. The error report makes the test fail
in some environments.

The process where the setup takes place must stay up
otherwise the ETS table used will go away.

This commit makes sure the broker-side authentication backend
setup returns at the end of the test. This way the calling
process terminates in a normal way.
  • Loading branch information
acogoluegnes authored and michaelklishin committed Jul 19, 2024
1 parent c3dd32f commit 834bed7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions deps/rabbitmq_mqtt/test/auth_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ client_id_propagation(Config) ->
rpc(Config, 0, rabbit_auth_backend_mqtt_mock, setup, [Self])
end),
%% the setup process will notify us
receive
ok -> ok
SetupProcess = receive
{ok, SP} -> SP
after
3000 -> ct:fail("timeout waiting for rabbit_auth_backend_mqtt_mock:setup/1")
end,
Expand Down Expand Up @@ -561,7 +561,11 @@ client_id_propagation(Config) ->
VariableMap = maps:get(variable_map, TopicContext),
?assertEqual(ClientId, maps:get(<<"client_id">>, VariableMap)),

ok = emqtt:disconnect(C).
ok = emqtt:disconnect(C),

SetupProcess ! stop,

ok.

%% These tests try to cover all operations that are listed in the
%% table in https://www.rabbitmq.com/access-control.html#authorisation
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_mqtt/test/rabbit_auth_backend_mqtt_mock.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setup(CallerPid) ->
ets:new(?MODULE, [set, public, named_table]),
CallerPid ! ok,
CallerPid ! {ok, self()},
receive
stop -> ok
end.
Expand Down

0 comments on commit 834bed7

Please # to comment.