From 8fbb948b6f9d03df903469b81a3e41681e0b2338 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Fri, 3 Mar 2023 17:51:48 -0300 Subject: [PATCH] test: fix flaky mqtt bridge test Sometimes, this test fails because the metrics are still in the inflight phase. --- .../test/emqx_bridge_mqtt_SUITE.erl | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/emqx_bridge/test/emqx_bridge_mqtt_SUITE.erl b/apps/emqx_bridge/test/emqx_bridge_mqtt_SUITE.erl index 1bb477dad..e2c9382db 100644 --- a/apps/emqx_bridge/test/emqx_bridge_mqtt_SUITE.erl +++ b/apps/emqx_bridge/test/emqx_bridge_mqtt_SUITE.erl @@ -359,9 +359,13 @@ t_mqtt_conn_bridge_egress(_) -> ?assertMatch(<>, Msg#message.from), %% verify the metrics of the bridge - ?assertMetrics( - #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0}, - BridgeIDEgress + ?retry( + _Interval = 200, + _Attempts = 5, + ?assertMetrics( + #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0}, + BridgeIDEgress + ) ), %% delete the bridge @@ -402,9 +406,13 @@ t_mqtt_conn_bridge_egress_no_payload_template(_) -> ?assertMatch(#{<<"payload">> := Payload}, jsx:decode(Msg#message.payload)), %% verify the metrics of the bridge - ?assertMetrics( - #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0}, - BridgeIDEgress + ?retry( + _Interval = 200, + _Attempts = 5, + ?assertMetrics( + #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0}, + BridgeIDEgress + ) ), %% delete the bridge