Skip to content

Commit

Permalink
Use the new instrumentation assertions for wpool metrics
Browse files Browse the repository at this point in the history
- Remove a leftover assertion
- Fix minor issues with variables
- Disable test repeat (we are doing this for all suites)
  • Loading branch information
chrzaszcz committed Jul 3, 2024
1 parent 9448bf2 commit a5b924a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
38 changes: 14 additions & 24 deletions big_tests/tests/mod_event_pusher_rabbit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ all() ->
].

groups() ->
G = [
[
{pool_startup, [],
[
rabbit_pool_starts_with_default_config
Expand Down Expand Up @@ -103,8 +103,7 @@ groups() ->
connections_events_are_executed,
messages_published_events_are_executed
]}
],
ct_helper:repeat_all_until_all_ok(G).
].

suite() ->
escalus:suite().
Expand Down Expand Up @@ -263,10 +262,7 @@ chat_message_sent_event(Config) ->
%% THEN wait for chat message sent events events from Rabbit.
?assertReceivedMatch({#'basic.deliver'{
routing_key = BobChatMsgSentRK},
#amqp_msg{}}, timer:seconds(5)),
instrument_helper:assert(wpool_rabbit_messages_published,
#{host_type => domain(), pool_tag => event_pusher},
fun(#{count := 1, time := T, size := S}) -> T >= 0 andalso S >= 0 end)
#amqp_msg{}}, timer:seconds(5))
end).

chat_message_received_event(Config) ->
Expand Down Expand Up @@ -471,16 +467,16 @@ messages_published_events_are_executed(Config) ->
Msg = <<"Oh, hi Alice from the event's test!">>,
escalus:send(Bob,
escalus_stanza:chat_to(Alice, Msg)),
%% THEN wait for chat message sent events events from Rabbit.
%% THEN wait for chat message sent events from Rabbit.
?assertReceivedMatch({#'basic.deliver'{routing_key = BobChatMsgSentRK},
#amqp_msg{}}, timer:seconds(5)),
instrument_helper:assert(wpool_rabbit_messages_published,
#{host_type => domain(), pool_tag => event_pusher},
fun(#{count := 1, time := T, size := S, payload := P}) ->
{amqp_msg, _, BinData} = P,
T >= 0 andalso S >= 0 andalso
binary:match(BinData, Msg) /= nomatch
end)
{amqp_msg, _, BinData} = P,
T >= 0 andalso S >= 0 andalso
binary:match(BinData, Msg) /= nomatch
end, #{expected_count => 2}) % for sender and receiver
end).

%%--------------------------------------------------------------------
Expand Down Expand Up @@ -756,17 +752,11 @@ is_rabbitmq_available() ->
end.

assert_connection_event(Tag) ->
Measurements = instrument_helper:wait_for(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag}),
instrument_helper:assert(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag},
Measurements,
fun(#{active := 1, opened := 1}) -> true end).
instrument_helper:wait_and_assert(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag},
fun(#{active := 1, opened := 1}) -> true end).

assert_disconnection_event(Tag) ->
Measurements = instrument_helper:wait_for(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag}),
instrument_helper:assert(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag},
Measurements,
fun(#{active := -1, closed := 1}) -> true end).
instrument_helper:wait_and_assert(wpool_rabbit_connections,
#{host_type => domain(), pool_tag => Tag},
fun(#{active := -1, closed := 1}) -> true end).
9 changes: 4 additions & 5 deletions big_tests/tests/rdbms_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,9 @@ test_wrapped_request(Config) ->
SelectResult = sql_query(Config, "SELECT unicode FROM test_types"),
?assertEqual({selected, [{<<"check1">>}]}, selected_to_sorted(SelectResult))
end, ok, #{name => request_queries}),
Measurements = instrument_helper:wait_for(test_wrapped_request, #{pool_tag => Tag}),
instrument_helper:assert(test_wrapped_request, #{pool_tag => Tag}, Measurements,
fun(#{time := T, count := 1, ref := Ref}) -> T > 0 end).
instrument_helper:wait_and_assert(
test_wrapped_request, #{pool_tag => Tag},
fun(#{time := T, count := 1, ref := R}) -> R =:= Ref andalso T > 0 end).

test_failed_wrapper(Config) ->
% given
Expand Down Expand Up @@ -697,9 +697,8 @@ pool_probe_metrics_are_updated(Config) ->

select_one_works_case(Config),

Measurements = instrument_helper:wait_for_new(Event, Labels),
F = fun(#{recv_oct := NewRecv, send_oct := NewSend}) -> NewRecv > Recv andalso NewSend > Send end,
instrument_helper:assert(Event, Labels, Measurements, F).
instrument_helper:wait_and_assert_new(Event, Labels, F).

%%--------------------------------------------------------------------
%% Text searching
Expand Down

0 comments on commit a5b924a

Please sign in to comment.