fix(ct): skip node_metric noise when waiting for admin WS pong [skip ci]
This commit is contained in:
@@ -134,7 +134,7 @@ test_admin_ws_report_notification(WS, UserToken, EventId) ->
|
||||
test_admin_ws_ping(WS) ->
|
||||
ct:pal(" TEST: Admin Ping/Pong"),
|
||||
ok = test_ws_send(WS, #{action => <<"ping">>}),
|
||||
{ok, #{<<"status">> := <<"pong">>}} = test_ws_recv(WS).
|
||||
{ok, #{<<"status">> := <<"pong">>}} = test_ws_recv_status(WS, <<"pong">>, 5000).
|
||||
|
||||
%% @doc Отписка от канала reports.
|
||||
-spec test_admin_ws_unsubscribe(pid()) -> ok.
|
||||
@@ -282,6 +282,26 @@ test_ws_recv(ConnPid, Timeout) ->
|
||||
{error, timeout}
|
||||
end.
|
||||
|
||||
%% @doc Ждём WS-сообщение с заданным status, пропуская посторонние (node_metric на shared stand).
|
||||
test_ws_recv_status(ConnPid, ExpectedStatus, Timeout) ->
|
||||
Deadline = erlang:monotonic_time(millisecond) + Timeout,
|
||||
test_ws_recv_status_loop(ConnPid, ExpectedStatus, Deadline).
|
||||
|
||||
test_ws_recv_status_loop(ConnPid, ExpectedStatus, Deadline) ->
|
||||
Remaining = max(0, Deadline - erlang:monotonic_time(millisecond)),
|
||||
case test_ws_recv(ConnPid, Remaining) of
|
||||
{ok, #{<<"status">> := ExpectedStatus} = Msg} ->
|
||||
{ok, Msg};
|
||||
{ok, #{<<"type">> := Type}} ->
|
||||
ct:pal(" Skipping WS type=~s (waiting for status ~s)", [Type, ExpectedStatus]),
|
||||
test_ws_recv_status_loop(ConnPid, ExpectedStatus, Deadline);
|
||||
{ok, Other} ->
|
||||
ct:pal(" Skipping WS message ~p (waiting for status ~s)", [Other, ExpectedStatus]),
|
||||
test_ws_recv_status_loop(ConnPid, ExpectedStatus, Deadline);
|
||||
{error, timeout} = Err ->
|
||||
Err
|
||||
end.
|
||||
|
||||
%% @doc Ждём WS-сообщение заданного type, пропуская посторонние (шум на shared stand).
|
||||
test_ws_recv_type(ConnPid, ExpectedType, Timeout) ->
|
||||
Deadline = erlang:monotonic_time(millisecond) + Timeout,
|
||||
|
||||
Reference in New Issue
Block a user