test(machine): attempt to stabilize flaky test

This commit is contained in:
Thales Macedo Garitezi 2024-03-07 10:23:02 -03:00
parent 98034cb4dd
commit b52c9c0062
1 changed files with 28 additions and 25 deletions

View File

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