test(authz cache): attempt to fix flaky test

Hypothesis: some race condition involving the previous test case, which uses the same
clientid.

```
Testing apps.emqx.emqx_authz_cache_SUITE: *** FAILED test case 3 of 3 ***
%%% emqx_authz_cache_SUITE ==> t_drain_authz_cache: FAILED
%%% emqx_authz_cache_SUITE ==>
Failure/Error: ?assertEqual([], list_cache ( ClientPid ))
  expected: []
       got: [{{#{qos => 0,action_type => publish,retain => false},<<"t1">>},
              {allow,1719599365019}}]
      line: 72
```
This commit is contained in:
Thales Macedo Garitezi 2024-06-28 15:40:55 -03:00
parent 9215b3710f
commit ec6e862539
1 changed files with 7 additions and 5 deletions

View File

@ -37,7 +37,7 @@ end_per_suite(Config) ->
%%--------------------------------------------------------------------
t_cache_exclude(_) ->
ClientId = <<"test-id1">>,
ClientId = atom_to_binary(?FUNCTION_NAME),
{ok, Client} = emqtt:start_link([{clientid, ClientId}]),
{ok, _} = emqtt:connect(Client),
{ok, _, _} = emqtt:subscribe(Client, <<"nocache/+/#">>, 0),
@ -47,11 +47,12 @@ t_cache_exclude(_) ->
emqtt:stop(Client).
t_clean_authz_cache(_) ->
{ok, Client} = emqtt:start_link([{clientid, <<"emqx_c">>}]),
ClientId = atom_to_binary(?FUNCTION_NAME),
{ok, Client} = emqtt:start_link([{clientid, ClientId}]),
{ok, _} = emqtt:connect(Client),
{ok, _, _} = emqtt:subscribe(Client, <<"t2">>, 0),
emqtt:publish(Client, <<"t1">>, <<"{\"x\":1}">>, 0),
ClientPid = find_client_pid(<<"emqx_c">>),
ClientPid = find_client_pid(ClientId),
Caches = list_cache(ClientPid),
ct:log("authz caches: ~p", [Caches]),
?assert(length(Caches) > 0),
@ -60,11 +61,12 @@ t_clean_authz_cache(_) ->
emqtt:stop(Client).
t_drain_authz_cache(_) ->
{ok, Client} = emqtt:start_link([{clientid, <<"emqx_c">>}]),
ClientId = atom_to_binary(?FUNCTION_NAME),
{ok, Client} = emqtt:start_link([{clientid, ClientId}]),
{ok, _} = emqtt:connect(Client),
{ok, _, _} = emqtt:subscribe(Client, <<"t2">>, 0),
emqtt:publish(Client, <<"t1">>, <<"{\"x\":1}">>, 0),
ClientPid = find_client_pid(<<"emqx_c">>),
ClientPid = find_client_pid(ClientId),
Caches = list_cache(ClientPid),
ct:log("authz caches: ~p", [Caches]),
?assert(length(Caches) > 0),