@@ -5,13 +5,16 @@ local t = require('luatest')
55local stats_registry_utils = require (' crud.stats.registry_utils' )
66
77local pgroup = t .group (' stats_integration' , {
8- { driver = ' local' },
9- { driver = ' metrics' , quantiles = false },
10- { driver = ' metrics' , quantiles = true },
8+ { way = ' call' , args = { driver = ' local' }},
9+ { way = ' call' , args = { driver = ' metrics' , quantiles = false }},
10+ { way = ' call' , args = { driver = ' metrics' , quantiles = true }},
11+ { way = ' role' , args = { driver = ' local' }},
12+ { way = ' role' , args = { driver = ' metrics' , quantiles = false }},
13+ { way = ' role' , args = { driver = ' metrics' , quantiles = true }},
1114})
1215local group_metrics = t .group (' stats_metrics_integration' , {
13- { driver = ' metrics' , quantiles = false },
14- { driver = ' metrics' , quantiles = true },
16+ { way = ' call ' , args = { driver = ' metrics' , quantiles = false } },
17+ { way = ' role ' , args = { driver = ' metrics' , quantiles = true } },
1518})
1619
1720local helpers = require (' test.helper' )
@@ -30,7 +33,7 @@ local function before_all(g)
3033 g .cluster :start ()
3134 g .router = g .cluster :server (' router' ).net_box
3235
33- if g .params .driver == ' metrics' then
36+ if g .params .args . driver == ' metrics' then
3437 local is_metrics_supported = g .router :eval ([[
3538 return require('crud.stats.metrics_registry').is_supported()
3639 ]] )
@@ -46,23 +49,37 @@ local function get_stats(g, space_name)
4649 return g .router :eval (" return require('crud').stats(...)" , { space_name })
4750end
4851
49- local function enable_stats (g , params )
50- params = params or g .params
51- g .router :eval ([[
52- local params = ...
53- require('crud').cfg{
54- stats = true,
55- stats_driver = params.driver,
56- stats_quantiles = params.quantiles,
57- stats_quantile_tolerated_error = 1e-3,
58- stats_quantile_age_buckets_count = 3,
59- stats_quantile_max_age_time = 60,
60- }
61- ]] , { params })
52+ local call_cfg = function (g , way , cfg )
53+ if way == ' call' then
54+ g .router :eval ([[
55+ require('crud').cfg(...)
56+ ]] , { cfg })
57+ elseif way == ' role' then
58+ g .cluster .main_server :upload_config {crud = cfg }
59+ end
60+ end
61+
62+ local function enable_stats (g , args )
63+ args = args or g .params .args
64+
65+ local cfg = {
66+ stats = true ,
67+ stats_driver = args .driver ,
68+ stats_quantiles = args .quantiles ,
69+ stats_quantile_tolerated_error = 1e-3 ,
70+ stats_quantile_age_buckets_count = 3 ,
71+ stats_quantile_max_age_time = 60 ,
72+ }
73+
74+ call_cfg (g , g .params .way , cfg )
6275end
6376
6477local function disable_stats (g )
65- g .router :eval (" require('crud').cfg{ stats = false }" )
78+ local cfg = {
79+ stats = false ,
80+ }
81+
82+ call_cfg (g , g .params .way , cfg )
6683end
6784
6885local function before_each (g )
@@ -643,7 +660,7 @@ for name, case in pairs(simple_operation_cases) do
643660 t .assert_le (changed_after .latency_average , ok_average_max ,
644661 ' Changed average has appropriate value' )
645662
646- if g .params .quantiles == true then
663+ if g .params .args . quantiles == true then
647664 local ok_quantile_max = math.max (
648665 changed_before .latency_quantile_recent or 0 ,
649666 after_finish - before_start )
@@ -755,7 +772,7 @@ pgroup.before_test(
755772 generate_stats )
756773
757774pgroup .test_role_reload_do_not_reset_observations = function (g )
758- t .xfail_if (g .params .driver == ' metrics' ,
775+ t .xfail_if (g .params .args . driver == ' metrics' ,
759776 ' See https://github.com/tarantool/metrics/issues/334' )
760777
761778 local stats_before = get_stats (g )
870887
871888local function validate_metrics (g , metrics )
872889 local quantile_stats
873- if g .params .quantiles == true then
890+ if g .params .args . quantiles == true then
874891 quantile_stats = find_metric (' tnt_crud_stats' , metrics )
875892 t .assert_type (quantile_stats , ' table' , ' `tnt_crud_stats` summary metrics found' )
876893 end
@@ -885,7 +902,7 @@ local function validate_metrics(g, metrics)
885902 local expected_operations = { ' insert' , ' insert_many' , ' get' , ' replace' , ' replace_many' , ' update' ,
886903 ' upsert' , ' upsert_many' , ' delete' , ' select' , ' truncate' , ' len' , ' count' , ' borders' }
887904
888- if g .params .quantiles == true then
905+ if g .params .args . quantiles == true then
889906 t .assert_items_equals (get_unique_label_values (quantile_stats , ' operation' ), expected_operations ,
890907 ' Metrics are labelled with operation' )
891908 end
@@ -899,7 +916,7 @@ local function validate_metrics(g, metrics)
899916
900917 local expected_statuses = { ' ok' , ' error' }
901918
902- if g .params .quantiles == true then
919+ if g .params .args . quantiles == true then
903920 t .assert_items_equals (
904921 get_unique_label_values (quantile_stats , ' status' ),
905922 expected_statuses ,
@@ -915,7 +932,7 @@ local function validate_metrics(g, metrics)
915932
916933 local expected_names = { space_name }
917934
918- if g .params .quantiles == true then
935+ if g .params .args . quantiles == true then
919936 t .assert_items_equals (
920937 get_unique_label_values (quantile_stats , ' name' ),
921938 expected_names ,
@@ -931,7 +948,7 @@ local function validate_metrics(g, metrics)
931948 expected_names ,
932949 ' Metrics are labelled with space name' )
933950
934- if g .params .quantiles == true then
951+ if g .params .args . quantiles == true then
935952 local expected_quantiles = { 0.99 }
936953 t .assert_items_equals (get_unique_label_values (quantile_stats , ' quantile' ), expected_quantiles ,
937954 ' Quantile metrics presents' )
0 commit comments