Просмотр исходного кода

Merge pull request #12659 from thalesmg/test-flaky-pulsar-r56-20240306

test(pulsar): fix flaky test
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
df3ebc5c56
1 измененных файлов с 18 добавлено и 12 удалено
  1. 18 12
      apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_v2_SUITE.erl

+ 18 - 12
apps/emqx_bridge_pulsar/test/emqx_bridge_pulsar_v2_SUITE.erl

@@ -212,20 +212,25 @@ t_action(Config) ->
     ?assertEqual(ReqPayload, emqx_utils_json:decode(RespPayload)),
     ok = emqtt:disconnect(C1),
     InstanceId = instance_id(actions, Name),
-    #{counters := Counters} = emqx_resource:get_metrics(InstanceId),
+    ?retry(
+        100,
+        20,
+        ?assertMatch(
+            #{
+                counters := #{
+                    dropped := 0,
+                    success := 1,
+                    matched := 1,
+                    failed := 0,
+                    received := 0
+                }
+            },
+            emqx_resource:get_metrics(InstanceId)
+        )
+    ),
     ok = delete_action(Name),
     ActionsAfterDelete = emqx_bridge_v2:list(actions),
     ?assertNot(lists:any(Any, ActionsAfterDelete), ActionsAfterDelete),
-    ?assertMatch(
-        #{
-            dropped := 0,
-            success := 1,
-            matched := 1,
-            failed := 0,
-            received := 0
-        },
-        Counters
-    ),
     ok.
 
 %%------------------------------------------------------------------------------
@@ -292,7 +297,8 @@ pulsar_action(Config) ->
                         <<"pulsar_topic">> => ?config(pulsar_topic, Config)
                     },
                     <<"resource_opts">> => #{
-                        <<"health_check_interval">> => <<"1s">>
+                        <<"health_check_interval">> => <<"1s">>,
+                        <<"metrics_flush_interval">> => <<"300ms">>
                     }
                 }
             }