@@ -127,38 +127,54 @@ group.test_table_is_immutable = function(g)
127
127
end )
128
128
end
129
129
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
+ {' replicas' , ' tnt_replication_lsn' , ' tnt_info_memory_lua' },
138
+ -- TODO: add more caterories
139
+ }
140
+
141
+ for _ , row in ipairs (matrix ) do
142
+ local m_category , m_include , m_exclude , m_linux_only = unpack (row )
143
+
144
+ group [(' test_include_%s' ):format (m_category )] = function (g )
145
+ g .server :exec (function (category , include , exclude , linux_only )
146
+ t .skip_if (linux_only and jit .os ~= ' Linux' , ' Linux is the only supported platform' )
147
+ local metrics = require (' metrics' )
148
+ local utils = require (' test.utils' ) -- luacheck: ignore 431
149
+
150
+ metrics .cfg {
151
+ include = {category },
152
+ }
153
+
154
+ local default_metrics = metrics .collect {invoke_callbacks = true }
155
+ local included = utils .find_metric (include , default_metrics )
156
+ t .assert_not_equals (included , nil )
157
+ local excluded = utils .find_metric (exclude , default_metrics )
158
+ t .assert_equals (excluded , nil )
159
+ end , {m_category , m_include , m_exclude , m_linux_only })
160
+ end
161
+ group [(' test_exclude_%s' ):format (m_category )] = function (g )
162
+ g .server :exec (function (category , include , exclude , linux_only )
163
+ t .skip_if (linux_only and jit .os ~= ' Linux' , ' Linux is the only supported platform' )
164
+ local metrics = require (' metrics' )
165
+ local utils = require (' test.utils' ) -- luacheck: ignore 431
166
+
167
+ metrics .cfg {
168
+ exclude = {category },
169
+ }
170
+
171
+ local default_metrics = metrics .collect {invoke_callbacks = true }
172
+ local uptime = utils .find_metric (exclude , default_metrics )
173
+ t .assert_not_equals (uptime , nil )
174
+ local memlua = utils .find_metric (include , default_metrics )
175
+ t .assert_equals (memlua , nil )
176
+ end , {m_category , m_include , m_exclude , m_linux_only })
177
+ end
162
178
end
163
179
164
180
group .test_include_with_exclude = function (g )
0 commit comments