Add more test cases for emqx_tracer
This commit is contained in:
parent
d444d1c61c
commit
bf82c5a1fe
|
@ -47,9 +47,12 @@ t_start_traces(_Config) ->
|
||||||
{error, _} = emqx_tracer:start_trace({clientid, <<"client">>}, debug, "tmp/client.log"),
|
{error, _} = emqx_tracer:start_trace({clientid, <<"client">>}, debug, "tmp/client.log"),
|
||||||
emqx_logger:set_log_level(debug),
|
emqx_logger:set_log_level(debug),
|
||||||
ok = emqx_tracer:start_trace({clientid, <<"client">>}, debug, "tmp/client.log"),
|
ok = emqx_tracer:start_trace({clientid, <<"client">>}, debug, "tmp/client.log"),
|
||||||
ok = emqx_tracer:start_trace({clientid, <<"client2">>}, all, "tmp/client2.log"),
|
ok = emqx_tracer:start_trace({clientid, "client2"}, all, "tmp/client2.log"),
|
||||||
{error, {invalid_log_level, bad_level}} = emqx_tracer:start_trace({clientid, <<"client3">>}, bad_level, "tmp/client3.log"),
|
ok = emqx_tracer:start_trace({clientid, client3}, all, "tmp/client3.log"),
|
||||||
|
{error, {invalid_log_level, bad_level}} = emqx_tracer:start_trace({clientid, <<"client4">>}, bad_level, "tmp/client4.log"),
|
||||||
|
{error, {handler_not_added, {file_error,".",eisdir}}} = emqx_tracer:start_trace({clientid, <<"client5">>}, debug, "."),
|
||||||
ok = emqx_tracer:start_trace({topic, <<"a/#">>}, all, "tmp/topic_trace.log"),
|
ok = emqx_tracer:start_trace({topic, <<"a/#">>}, all, "tmp/topic_trace.log"),
|
||||||
|
ok = emqx_tracer:start_trace({topic, <<"b/#">>}, all, "tmp/topic_trace.log"),
|
||||||
ct:sleep(100),
|
ct:sleep(100),
|
||||||
|
|
||||||
%% Verify the tracing file exits
|
%% Verify the tracing file exits
|
||||||
|
@ -60,7 +63,9 @@ t_start_traces(_Config) ->
|
||||||
%% Get current traces
|
%% Get current traces
|
||||||
?assertEqual([{{clientid,"client"},{debug,"tmp/client.log"}},
|
?assertEqual([{{clientid,"client"},{debug,"tmp/client.log"}},
|
||||||
{{clientid,"client2"},{debug,"tmp/client2.log"}},
|
{{clientid,"client2"},{debug,"tmp/client2.log"}},
|
||||||
{{topic,"a/#"},{debug,"tmp/topic_trace.log"}}], emqx_tracer:lookup_traces()),
|
{{clientid,"client3"},{debug,"tmp/client3.log"}},
|
||||||
|
{{topic,"a/#"},{debug,"tmp/topic_trace.log"}},
|
||||||
|
{{topic,"b/#"},{debug,"tmp/topic_trace.log"}}], emqx_tracer:lookup_traces()),
|
||||||
|
|
||||||
%% set the overall log level to debug
|
%% set the overall log level to debug
|
||||||
emqx_logger:set_log_level(debug),
|
emqx_logger:set_log_level(debug),
|
||||||
|
@ -77,23 +82,11 @@ t_start_traces(_Config) ->
|
||||||
%% Stop tracing
|
%% Stop tracing
|
||||||
ok = emqx_tracer:stop_trace({clientid, <<"client">>}),
|
ok = emqx_tracer:stop_trace({clientid, <<"client">>}),
|
||||||
ok = emqx_tracer:stop_trace({clientid, <<"client2">>}),
|
ok = emqx_tracer:stop_trace({clientid, <<"client2">>}),
|
||||||
|
ok = emqx_tracer:stop_trace({clientid, <<"client3">>}),
|
||||||
ok = emqx_tracer:stop_trace({topic, <<"a/#">>}),
|
ok = emqx_tracer:stop_trace({topic, <<"a/#">>}),
|
||||||
|
ok = emqx_tracer:stop_trace({topic, <<"b/#">>}),
|
||||||
|
{error, _Reason} = emqx_tracer:stop_trace({topic, <<"c/#">>}),
|
||||||
emqtt:disconnect(T),
|
emqtt:disconnect(T),
|
||||||
|
|
||||||
emqx_logger:set_log_level(warning).
|
emqx_logger:set_log_level(warning).
|
||||||
|
|
||||||
|
|
||||||
t_start_trace(_) ->
|
|
||||||
error('TODO').
|
|
||||||
|
|
||||||
t_stop_trace(_) ->
|
|
||||||
error('TODO').
|
|
||||||
|
|
||||||
t_lookup_traces(_) ->
|
|
||||||
error('TODO').
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
t_trace(_) ->
|
|
||||||
error('TODO').
|
|
||||||
|
|
Loading…
Reference in New Issue