test(emqx_bridge_mqtt): fix race condition
This commit is contained in:
parent
186dfd04a7
commit
2ffa71abde
|
@ -27,7 +27,8 @@
|
||||||
-type ack_ref() :: emqx_bridge_worker:ack_ref().
|
-type ack_ref() :: emqx_bridge_worker:ack_ref().
|
||||||
-type batch() :: emqx_bridge_worker:batch().
|
-type batch() :: emqx_bridge_worker:batch().
|
||||||
|
|
||||||
start(Cfg) ->
|
start(#{client_pid := Pid} = Cfg) ->
|
||||||
|
Pid ! {self(), ?MODULE, ready},
|
||||||
{ok, Cfg}.
|
{ok, Cfg}.
|
||||||
|
|
||||||
stop(_) -> ok.
|
stop(_) -> ok.
|
||||||
|
|
|
@ -194,6 +194,12 @@ t_stub_normal(Config) when is_list(Config) ->
|
||||||
client_pid => self()
|
client_pid => self()
|
||||||
},
|
},
|
||||||
{ok, Pid} = emqx_bridge_worker:start_link(?FUNCTION_NAME, Cfg),
|
{ok, Pid} = emqx_bridge_worker:start_link(?FUNCTION_NAME, Cfg),
|
||||||
|
receive
|
||||||
|
{Pid, emqx_bridge_stub_conn, ready} -> ok
|
||||||
|
after
|
||||||
|
5000 ->
|
||||||
|
error(timeout)
|
||||||
|
end,
|
||||||
ClientId = <<"ClientId">>,
|
ClientId = <<"ClientId">>,
|
||||||
try
|
try
|
||||||
{ok, ConnPid} = emqtt:start_link([{clientid, ClientId}]),
|
{ok, ConnPid} = emqtt:start_link([{clientid, ClientId}]),
|
||||||
|
@ -203,6 +209,9 @@ t_stub_normal(Config) when is_list(Config) ->
|
||||||
{stub_message, WorkerPid, BatchRef, _Batch} ->
|
{stub_message, WorkerPid, BatchRef, _Batch} ->
|
||||||
WorkerPid ! {batch_ack, BatchRef},
|
WorkerPid ! {batch_ack, BatchRef},
|
||||||
ok
|
ok
|
||||||
|
after
|
||||||
|
5000 ->
|
||||||
|
error(timeout)
|
||||||
end,
|
end,
|
||||||
?SNK_WAIT(inflight_drained),
|
?SNK_WAIT(inflight_drained),
|
||||||
?SNK_WAIT(replayq_drained),
|
?SNK_WAIT(replayq_drained),
|
||||||
|
|
Loading…
Reference in New Issue