test: attempt to fix flaky tests
``` %%% emqx_mgmt_api_cluster_SUITE ==> t_cluster_invite_api_timeout: FAILED %%% emqx_mgmt_api_cluster_SUITE ==> Failure/Error: ?assertMatch([ # { core_node := Core1 , replicant_nodes := [ # { node := Replicant , streams := _ } ] } , # { core_node := Core2 , replicant_nodes := [ # { node := Replicant , streams := _ } ] } ], lists : sort ( Core1Resp )) expected: = [ # { core_node := Core1 , replicant_nodes := [ # { node := Replicant , streams := _ } ] } , # { core_node := Core2 , replicant_nodes := [ # { node := Replicant , streams := _ } ] } ] got: [#{core_node => 'data_backup_core1@127.0.0.1', replicant_nodes => []}, #{core_node => 'data_backup_core2@127.0.0.1', replicant_nodes => [#{node => 'data_backup_replicant@127.0.0.1', streams => 7}]}] line: 111 ```
This commit is contained in:
parent
f64bd313aa
commit
b0c0c02df9
|
@ -78,19 +78,26 @@ t_cluster_topology_api_replicants(Config) ->
|
|||
[
|
||||
#{
|
||||
core_node := Core1,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
},
|
||||
#{
|
||||
core_node := Core2,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
}
|
||||
],
|
||||
Resp
|
||||
)
|
||||
|| Resp <- [lists:sort(R) || R <- [Core1Resp, Core2Resp, ReplResp]]
|
||||
].
|
||||
],
|
||||
%% Occasionally, the replicant may decide to not connect to one core (seen at tests)...
|
||||
Core1RespReplicants = lists:usort([
|
||||
Rep
|
||||
|| R <- [Core1Resp, Core2Resp, ReplResp],
|
||||
#{replicant_nodes := Reps} <- R,
|
||||
#{node := Rep} <- Reps
|
||||
]),
|
||||
?assertMatch([Replicant], Core1RespReplicants),
|
||||
ok.
|
||||
|
||||
t_cluster_invite_api_timeout(Config) ->
|
||||
%% assert the cluster is created
|
||||
|
@ -100,17 +107,22 @@ t_cluster_invite_api_timeout(Config) ->
|
|||
[
|
||||
#{
|
||||
core_node := Core1,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
},
|
||||
#{
|
||||
core_node := Core2,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
}
|
||||
],
|
||||
lists:sort(Core1Resp)
|
||||
),
|
||||
%% Occasionally, the replicant may decide to connect to one core (seen at tests)...
|
||||
Core1RespReplicants = lists:usort([
|
||||
Rep
|
||||
|| #{replicant_nodes := Reps} <- Core1Resp,
|
||||
#{node := Rep} <- Reps
|
||||
]),
|
||||
?assertMatch([Replicant], Core1RespReplicants),
|
||||
|
||||
%% force leave the core2
|
||||
{204} = rpc:call(
|
||||
|
@ -181,17 +193,22 @@ t_cluster_invite_async(Config) ->
|
|||
[
|
||||
#{
|
||||
core_node := Core1,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
},
|
||||
#{
|
||||
core_node := Core2,
|
||||
replicant_nodes :=
|
||||
[#{node := Replicant, streams := _}]
|
||||
replicant_nodes := _
|
||||
}
|
||||
],
|
||||
lists:sort(Core1Resp)
|
||||
),
|
||||
%% Occasionally, the replicant may decide to connect to one core (seen at tests)...
|
||||
Core1RespReplicants = lists:usort([
|
||||
Rep
|
||||
|| #{replicant_nodes := Reps} <- Core1Resp,
|
||||
#{node := Rep} <- Reps
|
||||
]),
|
||||
?assertMatch([Replicant], Core1RespReplicants),
|
||||
|
||||
%% force leave the core2
|
||||
{204} = rpc:call(
|
||||
|
@ -206,7 +223,7 @@ t_cluster_invite_async(Config) ->
|
|||
[
|
||||
#{
|
||||
core_node := Core1,
|
||||
replicant_nodes := [_]
|
||||
replicant_nodes := _
|
||||
}
|
||||
],
|
||||
lists:sort(Core1Resp2)
|
||||
|
|
Loading…
Reference in New Issue