test: fix flaky tests

This commit is contained in:
Thales Macedo Garitezi 2023-03-13 10:32:35 -03:00
parent 65fee34fe4
commit 422597a441
1 changed files with 21 additions and 15 deletions

View File

@ -250,8 +250,15 @@ t_batch_query_counter(_) ->
ok ok
end, end,
fun(Trace) -> fun(Trace) ->
QueryTrace = ?of_kind(call_batch_query, Trace), QueryTrace = [
?assertMatch([#{batch := BatchReq} | _] when length(BatchReq) > 1, QueryTrace) Event
|| Event = #{
?snk_kind := call_batch_query,
batch := BatchReq
} <- Trace,
length(BatchReq) > 1
],
?assertMatch([_ | _], QueryTrace)
end end
), ),
{ok, NMsgs} = emqx_resource:query(?ID, get_counter), {ok, NMsgs} = emqx_resource:query(?ID, get_counter),
@ -602,19 +609,18 @@ t_query_counter_async_inflight_batch(_) ->
5_000 5_000
), ),
fun(Trace) -> fun(Trace) ->
QueryTrace = ?of_kind(call_batch_query_async, Trace), QueryTrace = [
?assertMatch( Event
[ || Event = #{
#{ ?snk_kind := call_batch_query_async,
batch := [ batch := [
{query, _, {inc_counter, 1}, _, _}, {query, _, {inc_counter, 1}, _, _},
{query, _, {inc_counter, 1}, _, _} {query, _, {inc_counter, 1}, _, _}
] ]
} } <-
| _ Trace
], ],
QueryTrace ?assertMatch([_ | _], QueryTrace)
)
end end
), ),
tap_metrics(?LINE), tap_metrics(?LINE),