@@ -127,38 +127,53 @@ group.test_table_is_immutable = function(g)
127127 end )
128128end
129129
130- group .test_include = function (g )
131- g .server :exec (function ()
132- local metrics = require (' metrics' )
133- local utils = require (' test.utils' ) -- luacheck: ignore 431
134-
135- metrics .cfg {
136- include = {' info' },
137- }
138-
139- local default_metrics = metrics .collect {invoke_callbacks = true }
140- local uptime = utils .find_metric (' tnt_info_uptime' , default_metrics )
141- t .assert_not_equals (uptime , nil )
142- local memlua = utils .find_metric (' tnt_info_memory_lua' , default_metrics )
143- t .assert_equals (memlua , nil )
144- end )
145- end
146-
147- group .test_exclude = function (g )
148- g .server :exec (function ()
149- local metrics = require (' metrics' )
150- local utils = require (' test.utils' ) -- luacheck: ignore 431
151-
152- metrics .cfg {
153- exclude = {' memory' },
154- }
155-
156- local default_metrics = metrics .collect {invoke_callbacks = true }
157- local uptime = utils .find_metric (' tnt_info_uptime' , default_metrics )
158- t .assert_not_equals (uptime , nil )
159- local memlua = utils .find_metric (' tnt_info_memory_lua' , default_metrics )
160- t .assert_equals (memlua , nil )
161- end )
130+ local matrix = {
131+ -- {category: string, includes: string, excludes: string, linux_only: boolean}
132+ {' info' , ' tnt_info_uptime' , ' tnt_info_memory_lua' },
133+ {' cpu_extended' , ' tnt_cpu_thread' , ' tnt_info_memory_lua' , true },
134+ {' network' , ' tnt_net_sent_total' , ' tnt_info_memory_lua' },
135+ {' operations' , ' tnt_stats_op_total' , ' tnt_info_memory_lua' },
136+ {' system' , ' tnt_cfg_current_time' , ' tnt_info_memory_lua' },
137+ -- TODO: add more caterories
138+ }
139+
140+ for _ , row in ipairs (matrix ) do
141+ local m_category , m_include , m_exclude , m_linux_only = unpack (row )
142+
143+ group [(' test_include_%s' ):format (m_category )] = function (g )
144+ g .server :exec (function (category , include , exclude , linux_only )
145+ t .skip_if (linux_only and jit .os ~= ' Linux' , ' Linux is the only supported platform' )
146+ local metrics = require (' metrics' )
147+ local utils = require (' test.utils' ) -- luacheck: ignore 431
148+
149+ metrics .cfg {
150+ include = {category },
151+ }
152+
153+ local default_metrics = metrics .collect {invoke_callbacks = true }
154+ local included = utils .find_metric (include , default_metrics )
155+ t .assert_not_equals (included , nil )
156+ local excluded = utils .find_metric (exclude , default_metrics )
157+ t .assert_equals (excluded , nil )
158+ end , {m_category , m_include , m_exclude , m_linux_only })
159+ end
160+ group [(' test_exclude_%s' ):format (m_category )] = function (g )
161+ g .server :exec (function (category , include , exclude , linux_only )
162+ t .skip_if (linux_only and jit .os ~= ' Linux' , ' Linux is the only supported platform' )
163+ local metrics = require (' metrics' )
164+ local utils = require (' test.utils' ) -- luacheck: ignore 431
165+
166+ metrics .cfg {
167+ exclude = {category },
168+ }
169+
170+ local default_metrics = metrics .collect {invoke_callbacks = true }
171+ local uptime = utils .find_metric (exclude , default_metrics )
172+ t .assert_not_equals (uptime , nil )
173+ local memlua = utils .find_metric (include , default_metrics )
174+ t .assert_equals (memlua , nil )
175+ end , {m_category , m_include , m_exclude , m_linux_only })
176+ end
162177end
163178
164179group .test_include_with_exclude = function (g )
0 commit comments