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

Merge pull request #12666 from thalesmg/test-flaky-machine-m-20240307

test(machine): attempt to stabilize flaky test
Thales Macedo Garitezi 1 год назад
Родитель
Сommit
5dfd864c1a
1 измененных файлов с 28 добавлено и 25 удалено
  1. 28 25
      apps/emqx_machine/test/emqx_machine_SUITE.erl

+ 28 - 25
apps/emqx_machine/test/emqx_machine_SUITE.erl

@@ -147,29 +147,32 @@ t_open_ports_check(Config) ->
     ok = emqx_cth_cluster:stop_node(Core2),
 
     ?assertEqual(ok, erpc:call(Replicant, emqx_machine, open_ports_check, [])),
-    Results = erpc:call(Core1, emqx_machine, open_ports_check, []),
-    ?assertMatch(
-        #{
-            msg := "some ports are unreachable",
-            results :=
-                #{
-                    Core2 :=
-                        #{
-                            open_ports := #{},
-                            ports_to_check := [_, _],
-                            resolved_ips := [_],
-                            status := bad_ports
-                        }
-                }
-        },
-        Results,
-        #{core2 => Core2, gen_rpc_port => GenRPCPort, ekka_port => EkkaPort}
-    ),
-    %% 2 ports to check; we don't assert the exact ekka port because, when running
-    %% multiple nodes on the same machine as we do in tests, the order of returned ports
-    %% might change between invocations.
-    NumPorts = 2,
-    ?assertEqual(
-        NumPorts, map_size(emqx_utils_maps:deep_get([results, Core2, open_ports], Results))
-    ),
+    ?retry(200, 20, begin
+        Results = erpc:call(Core1, emqx_machine, open_ports_check, []),
+        ?assertMatch(
+            #{
+                msg := "some ports are unreachable",
+                results :=
+                    #{
+                        Core2 :=
+                            #{
+                                open_ports := #{},
+                                ports_to_check := [_, _],
+                                resolved_ips := [_],
+                                status := bad_ports
+                            }
+                    }
+            },
+            Results,
+            #{core2 => Core2, gen_rpc_port => GenRPCPort, ekka_port => EkkaPort}
+        ),
+        %% 2 ports to check; we don't assert the exact ekka port because, when running
+        %% multiple nodes on the same machine as we do in tests, the order of returned ports
+        %% might change between invocations.
+        NumPorts = 2,
+        ?assertEqual(
+            NumPorts, map_size(emqx_utils_maps:deep_get([results, Core2, open_ports], Results))
+        ),
+        ok
+    end),
     ok.