chore: fix flaky tests

This commit is contained in:
JianBo He 2023-11-28 10:10:16 +08:00
parent c8b5c51bbc
commit 891ecc179d
1 changed files with 16 additions and 7 deletions

View File

@ -111,7 +111,7 @@ groups() ->
]. ].
suite() -> suite() ->
[{timetrap, {seconds, 60}}]. [{timetrap, {seconds, 120}}].
init_per_suite(Config) -> init_per_suite(Config) ->
Config. Config.
@ -1329,15 +1329,24 @@ t_cluster_later_join_metrics(Config) ->
ok = erpc:call(OtherNode, ekka, join, [PrimaryNode]), ok = erpc:call(OtherNode, ekka, join, [PrimaryNode]),
%% Check metrics; shouldn't crash even if the bridge is not %% Check metrics; shouldn't crash even if the bridge is not
%% ready on the node that just joined the cluster. %% ready on the node that just joined the cluster.
%% assert: wait for the bridge to be ready on the other node.
fun
WaitConfSync(0) ->
throw(waiting_config_sync_timeout);
WaitConfSync(N) ->
timer:sleep(1000),
case erpc:call(OtherNode, emqx_bridge, list, []) of
[] -> WaitConfSync(N - 1);
[_] -> ok
end
end(
60
),
?assertMatch( ?assertMatch(
{ok, 200, #{ {ok, 200, #{
<<"metrics">> := #{<<"success">> := _}, <<"metrics">> := #{<<"success">> := _},
%% TODO: Why the node2 returns {error, bridge_not_found}? <<"node_metrics">> := [#{<<"metrics">> := #{}}, #{<<"metrics">> := #{}} | _]
%% ct:pal("node: ~p, bridges: ~p~n", [
%% OtherNode, erpc:call(OtherNode, emqx_bridge, list, [])
%% ]),
%%<<"node_metrics">> := [#{<<"metrics">> := #{}}, #{<<"metrics">> := #{}} | _]
<<"node_metrics">> := [#{<<"metrics">> := #{}} | _]
}}, }},
request_json(get, uri(["bridges", BridgeID, "metrics"]), Config) request_json(get, uri(["bridges", BridgeID, "metrics"]), Config)
), ),