diff --git a/test/box/admin.result b/test/box/admin.result index b62960cd9be72d83a0df31df0aa8758e614151f5..61c904b75d633cc999831be4491593fe641ebd25 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -1,3 +1,5 @@ +--# stop server default +--# start server default space = box.schema.create_space('tweedledum', { id = 0 }) --- ... @@ -103,24 +105,169 @@ box.delete(0, 1) --- - [1, 'tuple'] ... -box.info() ---- -- version: 1.minor.patch-<rev>-<commit> - status: primary - pid: <pid> - lsn: 5 - snapshot_pid: <pid> - recovery_last_update: 0 - recovery_lag: 0 - uptime: <uptime> - build: - flags: <flags> - target: <target> - compiler: <compiler> - options: <options> - logger_pid: <pid> - config: tarantool.cfg -... -space:drop() +--# setopt delimiter ';' +function check_type(arg, typeof) + if type(arg) == typeof then + return true + else + return false + end +end; --- ... +function test_box_info() + local tmp = box.info() + local num = {'pid', 'snapshot_pid', 'recovery_last_update', 'recovery_lag', 'uptime', 'logger_pid'} + local buildstr = {'flags', 'target', 'compiler', 'options'} + local str = {'version', 'status', 'config'} + local failed = {} + if check_type(tmp.lsn, 'cdata') == false then + table.insert(failed1, 'box.info().lsn') + else + tmp.lsn = nil + end + for k, v in ipairs(num) do + if check_type(tmp[v], 'number') == false then + table.insert(failed, 'box.info().'..v) + else + tmp[v] = nil + end + end + for k, v in ipairs(str) do + if check_type(tmp[v], 'string') == false then + table.insert(failed, 'box.info().'..v) + else + tmp[v] = nil + end + end + if type(tmp.build) == 'table' then + for k, v in ipairs(buildstr) do + if check_type(tmp.build[v], 'string') == false then + table.insert(failed, 'box.info().build.'..v) + else + tmp.build[v] = nil + end + end + if #tmp.build == 0 then + tmp.build = nil + end + else + table.insert(failed, 'box.info().build failed') + end + if #tmp > 0 or #failed > 0 then + return 'box.info() is not ok.', 'failed: ', failed, tmp + else + return 'box.info() is ok.' + end +end; +--- +... +function test_slab(tbl) + local num = {'items', 'bytes_used', 'item_size', 'slabs', 'bytes_free'} + local failed = {} + for k, v in ipairs(num) do + if check_type(tmp[v], 'number') == false then + table.insert(failed, 'box.slab.info().<slab_size>.'..v) + else + tmp[v] = nil + end + end + if #tbl > 0 or #failed > 0 then + return false, failed + else + return true, {} + end +end; +--- +... +function test_box_slab_info() + local tmp = box.slab.info() + local cdata = {'arena_size', 'arena_used'} + local failed = {} + if type(tmp.slabs) == 'table' then + for name, tbl in ipairs(tmp.slabs) do + local bl, fld = test_slab(tbl) + if bl == true then + tmp[name] = nil + else + for k, v in ipairs(fld) do + table.append(failed, v) + end + end + end + else + table.append(failed, 'box.slab.info().slabs is not ok') + end + if #tmp.slabs == 0 then + tmp.slabs = nil + end + for k, v in ipairs(cdata) do + if check_type(tmp[v], 'cdata') == false then + table.insert(failed, 'box.slab.info().'..v) + else + tmp[v] = nil + end + end + if #tmp > 0 or #failed > 0 then + return "box.slab.info() is not ok", tmp, failed + else + return "box.slab.info() is ok" + end +end; +--- +... +function test_fiber(tbl) + local num = {'fid', 'csw'} + for k, v in ipairs(num) do + if check_type(tmp[v], 'number') == false then + table.insert(failed, 'box.fiber.info().<fiber_name>.'..v) + else + tmp[v] = nil + end + end + if type(tbl.backtrace) == 'table' and #tbl.backtrace > 0 then + tbl.backtrace = nil + else + table.append(failed, 'backtrace') + end + if #tbl > 0 or #failed > 0 then + return false, failed + else + return true, {} + end +end; +--- +... +function test_box_fiber_info() + local tmp = box.fiber.info() + local failed = {} + for name, tbl in ipairs(tmp) do + local bl, fld = test_fiber(tbl) + if bl == true then + tmp[name] = nil + else + for k, v in ipairs(fld) do + table.append(failed, v) + end + end + end + if #tmp > 0 or #failed > 0 then + return "box.fiber.info is not ok. failed: ", tmp, failed + else + return "box.fiber.info() is ok" + end +end; +--- +... +test_box_info(); +--- +- box.info() is ok. +... +test_box_slab_info(); +--- +- box.slab.info() is ok +... +test_box_fiber_info(); +--- +- box.fiber.info() is ok +... diff --git a/test/box/admin.test.lua b/test/box/admin.test.lua index 1756fecbb5a91b30ea30d9fe4307574388fd021b..e0a87fb531797667295aecf7530d280b4d0bc667 100644 --- a/test/box/admin.test.lua +++ b/test/box/admin.test.lua @@ -11,115 +11,150 @@ box.stat() box.insert(0, 1, 'tuple') box.snapshot() box.delete(0, 1) ---# setopt delimiter ';' +--# setopt delimiter ';' function check_type(arg, typeof) - if arg == nil then - return false - elseif type(arg) == typeof then + if type(arg) == typeof then return true else return false end end; + function test_box_info() local tmp = box.info() - local num = {'pid', 'lsn', 'snapshot_pid', 'recovery_last_update', 'recovery_lag', 'uptime', 'logger_pid'} + local num = {'pid', 'snapshot_pid', 'recovery_last_update', 'recovery_lag', 'uptime', 'logger_pid'} local buildstr = {'flags', 'target', 'compiler', 'options'} local str = {'version', 'status', 'config'} - failed = {} + local failed = {} + if check_type(tmp.lsn, 'cdata') == false then + table.insert(failed1, 'box.info().lsn') + else + tmp.lsn = nil + end for k, v in ipairs(num) do if check_type(tmp[v], 'number') == false then table.insert(failed, 'box.info().'..v) + else + tmp[v] = nil end end for k, v in ipairs(str) do if check_type(tmp[v], 'string') == false then table.insert(failed, 'box.info().'..v) + else + tmp[v] = nil end end - for k, v in ipairs(buildstr) do - if check_type(tmp.build[v], 'string') == false then - table.insert(failed, 'box.info().build.'..v) + if type(tmp.build) == 'table' then + for k, v in ipairs(buildstr) do + if check_type(tmp.build[v], 'string') == false then + table.insert(failed, 'box.info().build.'..v) + else + tmp.build[v] = nil + end + end + if #tmp.build == 0 then + tmp.build = nil end + else + table.insert(failed, 'box.info().build failed') end - if #failed == 0 then - return 'box.info() is ok.' + if #tmp > 0 or #failed > 0 then + return 'box.info() is not ok.', 'failed: ', failed, tmp else - return 'box.info() is not ok.', 'failed: ', failed + return 'box.info() is ok.' + end end; function test_slab(tbl) - if type(tbl.items) == 'number' then - tbl.items = nil - end - if type(tbl.bytes_used) == 'number' then - tbl.bytes_used = nil - end - if type(tbl.item_size) == 'number' then - tbl.item_size = nil - end - if type(tbl.slabs) == 'number' then - tbl.slabs = nil - end - if type(tbl.bytes_free) == 'number' then - tbl.bytes_free = nil + local num = {'items', 'bytes_used', 'item_size', 'slabs', 'bytes_free'} + local failed = {} + for k, v in ipairs(num) do + if check_type(tmp[v], 'number') == false then + table.insert(failed, 'box.slab.info().<slab_size>.'..v) + else + tmp[v] = nil + end end - if #tbl > 0 then - return false + if #tbl > 0 or #failed > 0 then + return false, failed else - return true + return true, {} end end; function test_box_slab_info() local tmp = box.slab.info() - - for name, tbl in ipairs(tmp.slabs) do - if test_slab(tbl) == true then - tmp[name] = nil + local cdata = {'arena_size', 'arena_used'} + local failed = {} + if type(tmp.slabs) == 'table' then + for name, tbl in ipairs(tmp.slabs) do + local bl, fld = test_slab(tbl) + if bl == true then + tmp[name] = nil + else + for k, v in ipairs(fld) do + table.append(failed, v) + end + end + end + else + table.append(failed, 'box.slab.info().slabs is not ok') end if #tmp.slabs == 0 then tmp.slabs = nil end - if type(tmp.arena_size) == 'number' then - tmp.arena_size = nil - end - if type(tmp.arena_used) == 'number' then - tmp.arena_used = nil + for k, v in ipairs(cdata) do + if check_type(tmp[v], 'cdata') == false then + table.insert(failed, 'box.slab.info().'..v) + else + tmp[v] = nil + end end - if #tmp > 0 then - return tmp + if #tmp > 0 or #failed > 0 then + return "box.slab.info() is not ok", tmp, failed else return "box.slab.info() is ok" + end end; function test_fiber(tbl) - if type(tbl.fid) == 'number' then - tbl.fid = nil - end - if type(tbl.csw) == 'number' then - tbl.csw = nil + local num = {'fid', 'csw'} + for k, v in ipairs(num) do + if check_type(tmp[v], 'number') == false then + table.insert(failed, 'box.fiber.info().<fiber_name>.'..v) + else + tmp[v] = nil + end end if type(tbl.backtrace) == 'table' and #tbl.backtrace > 0 then tbl.backtrace = nil + else + table.append(failed, 'backtrace') end - if #tbl > 0 then - return false + if #tbl > 0 or #failed > 0 then + return false, failed else - return true + return true, {} end end; function test_box_fiber_info() local tmp = box.fiber.info() + local failed = {} for name, tbl in ipairs(tmp) do - if test_fiber(tbl) == true then + local bl, fld = test_fiber(tbl) + if bl == true then tmp[name] = nil + else + for k, v in ipairs(fld) do + table.append(failed, v) + end end end - if #tmp > 0 then - return tmp + if #tmp > 0 or #failed > 0 then + return "box.fiber.info is not ok. failed: ", tmp, failed else return "box.fiber.info() is ok" end diff --git a/test/box/admin.test.py b/test/box/admin.test.py deleted file mode 100644 index f27bb1758f07ea214ec25b22b6a5e598e6db5ee5..0000000000000000000000000000000000000000 --- a/test/box/admin.test.py +++ /dev/null @@ -1,38 +0,0 @@ -import sys - -# clear statistics: -server.stop() -server.deploy() - -admin("space = box.schema.create_space('tweedledum', { id = 0 })") -admin("space:create_index('primary', 'hash', { parts = { 0, 'num' }})") - -admin("box.stat()") -admin("help()") -sys.stdout.push_filter("'function: .*", "function_ptr") -admin("box.cfg()") -sys.stdout.clear_all_filters() -admin("box.stat()") -admin("box.insert(0, 1, 'tuple')") -admin("box.snapshot()") -admin("box.delete(0, 1)") -sys.stdout.push_filter("(\d)\.\d\.\d(-\d+-\w+)?", "\\1.minor.patch-<rev>-<commit>") -sys.stdout.push_filter("pid: \d+", "pid: <pid>") -sys.stdout.push_filter("logger_pid: \d+", "pid: <pid>") -sys.stdout.push_filter("uptime: \d+", "uptime: <uptime>") -sys.stdout.push_filter("flags: .*", "flags: <flags>") -sys.stdout.push_filter("build: .*", "build: <build>") -sys.stdout.push_filter("options: .*", "options: <options>") -sys.stdout.push_filter("target: .*", "target: <target>") -sys.stdout.push_filter("compiler: .*", "compiler: <compiler>") -sys.stdout.push_filter("^ [^:]+$", "") -sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool") -admin("box.info()") -sys.stdout.clear_all_filters() -sys.stdout.push_filter(".*", "") -admin("box.fiber.info()") -admin("box.slab.info()") - -sys.stdout.clear_all_filters() - -admin("space:drop()")