Merge pull request #2921 from emqx/ct-metrics

Add test cases for new/1, all/0 functions
This commit is contained in:
tigercl 2019-09-29 09:59:59 +08:00 committed by GitHub
commit 9fed1667bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 0 deletions

View File

@ -24,6 +24,30 @@
all() -> emqx_ct:all(?MODULE).
t_new(_) ->
with_metrics_server(
fun() ->
ok = emqx_metrics:new('metrics.test'),
0 = emqx_metrics:val('metrics.test'),
ok = emqx_metrics:inc('metrics.test'),
1 = emqx_metrics:val('metrics.test'),
ok = emqx_metrics:new(counter, 'metrics.test.cnt'),
0 = emqx_metrics:val('metrics.test.cnt'),
ok = emqx_metrics:inc('metrics.test.cnt'),
1 = emqx_metrics:val('metrics.test.cnt'),
ok = emqx_metrics:new(gauge, 'metrics.test.total'),
0 = emqx_metrics:val('metrics.test.total'),
ok = emqx_metrics:inc('metrics.test.total'),
1 = emqx_metrics:val('metrics.test.total')
end).
t_all(_) ->
with_metrics_server(
fun() ->
Metrics = emqx_metrics:all(),
?assert(length(Metrics) > 50)
end).
t_inc_dec(_) ->
with_metrics_server(
fun() ->