From a75eaf19708cc2cae614e3ffc3b5488bcdbf50ef Mon Sep 17 00:00:00 2001 From: jacekwegr Date: Tue, 12 Mar 2024 08:06:53 +0100 Subject: [PATCH] Prevent crashing after `http_auth` is started --- big_tests/tests/http_helper.erl | 12 ++++++++++-- big_tests/tests/muc_SUITE.erl | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/big_tests/tests/http_helper.erl b/big_tests/tests/http_helper.erl index 14cea96fe0..1fdda41997 100644 --- a/big_tests/tests/http_helper.erl +++ b/big_tests/tests/http_helper.erl @@ -25,8 +25,16 @@ start(Port, Path, HandleFun) -> application:ensure_all_started(cowboy), Dispatch = cowboy_router:compile([{'_', [{Path, http_helper, HandleFun}]}]), - {ok, _} = cowboy:start_clear(http_helper_listener, [{port, Port}], - #{env => #{dispatch => Dispatch}}). + case cowboy:start_clear(http_helper_listener, [{port, Port}], + #{env => #{dispatch => Dispatch}}) of + {ok, Pid} -> + {ok, Pid}; + {error, {already_started, _}} -> + ct:log("http_helper_listener was already running. Restarting it."), + stop(), + {ok, _} = cowboy:start_clear(http_helper_listener, [{port, Port}], + #{env => #{dispatch => Dispatch}}) + end. stop() -> cowboy:stop_listener(http_helper_listener). diff --git a/big_tests/tests/muc_SUITE.erl b/big_tests/tests/muc_SUITE.erl index fc975be887..2e2fd7e8d0 100644 --- a/big_tests/tests/muc_SUITE.erl +++ b/big_tests/tests/muc_SUITE.erl @@ -341,7 +341,6 @@ end_per_suite(Config) -> dynamic_modules:restore_modules(Config), escalus:end_per_suite(Config). - init_per_group(room_registration_race_condition, Config) -> escalus_fresh:create_users(Config, [{alice, 1}]);