From d54dbe717e6081a8020dc8e9628154aa86fcbeda Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Sat, 27 Apr 2024 15:15:32 +0300 Subject: [PATCH] Add tests --- .github/workflows/test.yml | 4 ++++ test/tarantool/memtx_metrics_test.lua | 31 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7324622e..632b87af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,10 @@ jobs: cartridge: "2.9.0" - tarantool: "2.11" cartridge: "2.10.0" + - tarantool: "3.0" + cartridge: "" + - tarantool: "3.1" + cartridge: "" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 diff --git a/test/tarantool/memtx_metrics_test.lua b/test/tarantool/memtx_metrics_test.lua index ce042127..91aa4840 100644 --- a/test/tarantool/memtx_metrics_test.lua +++ b/test/tarantool/memtx_metrics_test.lua @@ -63,3 +63,34 @@ g.test_memtx = function(cg) end end) end + +g.test_memtx_read_view = function(cg) + t.skip_if(utils.is_version_less(_TARANTOOL, '3.1.0'), + 'Tarantool version is must be v3.1.0 or greater') + + cg.server:exec(function() + local metrics = require('metrics') + local memtx = require('metrics.tarantool.memtx') + local utils = require('test.utils') -- luacheck: ignore 431 + + metrics.enable_default_metrics() + memtx.update() + local default_metrics = metrics.collect() + local log = require('log') + + local metrics_list = { + 'tnt_memtx_tuples_data_total', + 'tnt_memtx_tuples_data_read_view', + 'tnt_memtx_tuples_data_garbage', + 'tnt_memtx_index_total', + 'tnt_memtx_index_read_view', + } + + for _, item in ipairs(metrics_list) do + log.info('checking metric: ' .. item) + local metric = utils.find_metric(item, default_metrics) + t.assert(metric) + t.assert_type(metric[1].value, 'number') + end + end) +end