Skip to content

Commit f8d8c09

Browse files
committed
jwks_SUITE: Wait for connection exit in test_failed_token_refresh_case2
[Why] The connection is about to be killed at the end of the test case. It's not necessary to close it explicitly. Moreover, on a slow environment like CI, the connection process might have already exited when the test case tries to close it. In this case, it fails with a `noproc` exception. (cherry picked from commit 0601ef4)
1 parent d036cf1 commit f8d8c09

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

deps/rabbitmq_auth_backend_oauth2/test/jwks_SUITE.erl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ test_failed_connection_with_a_token_with_insufficient_resource_permission(Config
896896
?assertExit({{shutdown, {server_initiated_close, 403, _}}, _},
897897
amqp_channel:call(Ch, #'queue.declare'{queue = <<"alt-prefix.eq.1">>,
898898
exclusive = true})),
899+
899900
close_connection(Conn).
900901

901902
test_failed_token_refresh_case1(Config) ->
@@ -941,7 +942,7 @@ test_failed_token_refresh_case2(Config) ->
941942
?assertExit({{shutdown, {connection_closing, {server_initiated_close, 530, _}}}, _},
942943
amqp_connection:open_channel(Conn)),
943944

944-
close_connection(Conn).
945+
wait_for_connection_exit(Conn).
945946

946947
cannot_change_username_on_refreshed_token(Config) ->
947948
Jwk =
@@ -983,4 +984,14 @@ rpc_get_env(Config, Par) ->
983984
[rabbitmq_auth_backend_oauth2, Par]).
984985
rpc_get_env(Config, Par, Default) ->
985986
rpc(Config, 0, application, get_env,
986-
[rabbitmq_auth_backend_oauth2, Par, Default]).
987+
[rabbitmq_auth_backend_oauth2, Par, Default]).
988+
989+
wait_for_connection_exit(Conn) ->
990+
MRef = erlang:monitor(process, Conn),
991+
receive
992+
{'DOWN', MRef, _Type, _Conn, Reason} ->
993+
ct:pal("Connection ~0p exited: ~p", [Conn, Reason]),
994+
ok
995+
after 30000 ->
996+
ct:fail("Connection ~0p is still up after 30 seconds", [Conn])
997+
end.

0 commit comments

Comments
 (0)