From 834bed7446abdd04019e9c7280cf67dc509ed06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Cogolu=C3=A8gnes?= Date: Wed, 17 Jul 2024 15:36:20 +0200 Subject: [PATCH] MQTT auth_SUITE: terminate setup process 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. --- deps/rabbitmq_mqtt/test/auth_SUITE.erl | 10 +++++++--- .../test/rabbit_auth_backend_mqtt_mock.erl | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/rabbitmq_mqtt/test/auth_SUITE.erl b/deps/rabbitmq_mqtt/test/auth_SUITE.erl index 8a15566290b0..b7c6f33f405d 100644 --- a/deps/rabbitmq_mqtt/test/auth_SUITE.erl +++ b/deps/rabbitmq_mqtt/test/auth_SUITE.erl @@ -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, @@ -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 diff --git a/deps/rabbitmq_mqtt/test/rabbit_auth_backend_mqtt_mock.erl b/deps/rabbitmq_mqtt/test/rabbit_auth_backend_mqtt_mock.erl index f6431039442f..98ad0f4ea6f9 100644 --- a/deps/rabbitmq_mqtt/test/rabbit_auth_backend_mqtt_mock.erl +++ b/deps/rabbitmq_mqtt/test/rabbit_auth_backend_mqtt_mock.erl @@ -21,7 +21,7 @@ setup(CallerPid) -> ets:new(?MODULE, [set, public, named_table]), - CallerPid ! ok, + CallerPid ! {ok, self()}, receive stop -> ok end.