Skip to content

Commit

Permalink
Try fixing CT error on CI 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sylane committed Nov 27, 2024
1 parent 48a2043 commit 60b21af
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions test/grisp_connect_api_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ init_per_testcase(TestCase, Config) ->

end_per_testcase(_, Config) ->
ok = application:stop(grisp_connect),
grisp_connect_test_server:wait_disconnection(),
?assertEqual([], flush()),
Config.

Expand Down
1 change: 1 addition & 0 deletions test/grisp_connect_connection_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ init_per_testcase(_TestCase, Config) ->
Config.

end_per_testcase(_, Config) ->
grisp_connect_test_server:wait_disconnection(),
?assertEqual([], flush()),
Config.

Expand Down
1 change: 1 addition & 0 deletions test/grisp_connect_log_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ end_per_testcase(log_level_test, Config) ->
end_per_testcase(other, Config);
end_per_testcase(_, Config) ->
ok = application:stop(grisp_connect),
grisp_connect_test_server:wait_disconnection(),
?assertEqual([], flush()),
Config.

Expand Down
23 changes: 11 additions & 12 deletions test/grisp_connect_test_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
-export([send_jsonrpc_request/3]).
-export([send_jsonrpc_result/2]).
-export([send_jsonrpc_error/3]).
-export([wait_disconnection/0]).

% Websocket Callbacks
-export([init/2]).
Expand Down Expand Up @@ -50,7 +51,7 @@ stop(Apps) ->
?assertEqual(ok, stop_cowboy()),
[?assertEqual(ok, application:stop(App)) || App <- Apps],
% Ensure the process is unregistered...
wait_no_websocket().
wait_disconnection().


% Start the cowboy listener.
Expand Down Expand Up @@ -186,6 +187,15 @@ send_jsonrpc_error(Code, Msg, Id) ->
id => Id},
send_text(jsx:encode(Map)).

wait_disconnection() ->
case whereis(?MODULE) of
undefined -> ok;
_Pid ->
timer:sleep(200),
wait_disconnection()
end.


%--- Websocket Callbacks -------------------------------------------------------

init(Req, State) ->
Expand Down Expand Up @@ -213,14 +223,3 @@ websocket_info(close_websocket, State) ->
websocket_info(Info, State) ->
ct:pal("Ignore websocket info:~n~p", [Info]),
{[], State}.


%--- Internal Functions --------------------------------------------------------

wait_no_websocket() ->
case whereis(?MODULE) of
undefined -> ok;
_Pid ->
timer:sleep(200),
wait_no_websocket()
end.

0 comments on commit 60b21af

Please sign in to comment.