Преглед изворни кода

Merge pull request #12337 from SergeTupchiy/refactor-emqx-cm-test-flush

test(emqx_cm_SUITE): use one helper function `emqx_pool:flush_async_tasks/1`
SergeTupchiy пре 2 година
родитељ
комит
23c0dc58fb
1 измењених фајлова са 1 додато и 23 уклоњено
  1. 1 23
      apps/emqx/test/emqx_cm_SUITE.erl

+ 1 - 23
apps/emqx/test/emqx_cm_SUITE.erl

@@ -343,31 +343,9 @@ test_stepdown_session(Action, Reason) ->
     end,
     % sync
     ignored = gen_server:call(?CM, ignore, infinity),
-    ok = flush_emqx_cm_pool(),
+    ok = emqx_pool:flush_async_tasks(?CM_POOL),
     ?assertEqual([], emqx_cm:lookup_channels(ClientId)).
 
-%% Channel deregistration is delegated to emqx_pool as a sync tasks.
-%% The emqx_pool is pool of workers, and there is no way to know
-%% which worker was picked for the last deregistration task.
-%% This help function creates a large enough number of async tasks
-%% to sync with the pool workers.
-%% The number of tasks should be large enough to ensure all workers have
-%% the chance to work on at least one of the tasks.
-flush_emqx_cm_pool() ->
-    Self = self(),
-    L = lists:seq(1, 1000),
-    lists:foreach(
-        fun(I) -> emqx_pool:async_submit_to_pool(?CM_POOL, fun() -> Self ! {done, I} end, []) end, L
-    ),
-    lists:foreach(
-        fun(I) ->
-            receive
-                {done, I} -> ok
-            end
-        end,
-        L
-    ).
-
 t_discard_session_race(_) ->
     ClientId = rand_client_id(),
     ?check_trace(