chore(test): add snabbkaffe for create_trace test
This commit is contained in:
parent
07ba4ad05e
commit
977b1bb7ec
|
@ -19,6 +19,7 @@
|
|||
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("emqx/include/logger.hrl").
|
||||
-include_lib("snabbkaffe/include/trace.hrl").
|
||||
|
||||
-boot_mnesia({mnesia, [boot]}).
|
||||
-export([mnesia/1]).
|
||||
|
@ -261,6 +262,7 @@ handle_info({timeout, TRef, update_trace}, #{timer := TRef} = State) ->
|
|||
Traces = get_enable_trace(),
|
||||
NextTRef = update_trace(Traces),
|
||||
update_trace_handler(),
|
||||
?tp(update_trace_done, #{}),
|
||||
{noreply, State#{timer => NextTRef}};
|
||||
|
||||
handle_info({mnesia_table_event, _Events}, State = #{timer := TRef}) ->
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
-include_lib("stdlib/include/zip.hrl").
|
||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||
|
||||
-define(HOST, "http://127.0.0.1:18083/").
|
||||
-define(API_VERSION, "v5").
|
||||
|
@ -120,9 +121,7 @@ t_download_log(_Config) ->
|
|||
Start = to_rfc3339(Now),
|
||||
Name = <<"test_client_id">>,
|
||||
load(),
|
||||
ok = emqx_trace:create([{<<"name">>, Name},
|
||||
{<<"type">>, clientid}, {<<"clientid">>, ClientId}, {<<"start_at">>, Start}]),
|
||||
ct:sleep(50),
|
||||
create_trace(Name, ClientId, Start),
|
||||
{ok, Client} = emqtt:start_link([{clean_start, true}, {clientid, ClientId}]),
|
||||
{ok, _} = emqtt:connect(Client),
|
||||
[begin _ = emqtt:ping(Client) end ||_ <- lists:seq(1, 5)],
|
||||
|
@ -138,6 +137,18 @@ t_download_log(_Config) ->
|
|||
ok = emqtt:disconnect(Client),
|
||||
ok.
|
||||
|
||||
create_trace(Name, ClientId, Start) ->
|
||||
?check_trace(
|
||||
#{timetrap => 900},
|
||||
begin
|
||||
ok = emqx_trace:create([{<<"name">>, Name},
|
||||
{<<"type">>, clientid}, {<<"clientid">>, ClientId}, {<<"start_at">>, Start}]),
|
||||
?block_until(#{?snk_kind := update_trace_done})
|
||||
end,
|
||||
fun(Trace) ->
|
||||
?assertMatch([#{}], ?of_kind(update_trace_done, Trace))
|
||||
end).
|
||||
|
||||
t_stream_log(_Config) ->
|
||||
application:set_env(emqx, allow_anonymous, true),
|
||||
emqx_trace:clear(),
|
||||
|
@ -146,9 +157,7 @@ t_stream_log(_Config) ->
|
|||
Now = erlang:system_time(second),
|
||||
Name = <<"test_stream_log">>,
|
||||
Start = to_rfc3339(Now - 10),
|
||||
ok = emqx_trace:create(#{<<"name">> => Name,
|
||||
<<"type">> => clientid, <<"clientid">> => ClientId, <<"start_at">> => Start}),
|
||||
ct:sleep(200),
|
||||
create_trace(Name, ClientId, Start),
|
||||
{ok, Client} = emqtt:start_link([{clean_start, true}, {clientid, ClientId}]),
|
||||
{ok, _} = emqtt:connect(Client),
|
||||
[begin _ = emqtt:ping(Client) end || _ <- lists:seq(1, 5)],
|
||||
|
|
Loading…
Reference in New Issue