From 5b2b06f2c48571c319159d09abe485ad347c6180 Mon Sep 17 00:00:00 2001 From: Sergey Morozov Date: Tue, 20 Jan 2026 19:23:27 +0300 Subject: [PATCH] test: dump xlogs and snaps for debug --- CMakeLists.txt | 2 +- crud/schema.lua | 6 ++-- test/helper.lua | 31 ------------------ test/tarantool3_helpers/cluster.lua | 16 ++++++++- test/tarantool3_helpers/utils.lua | 51 +++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8ddefa1..a52557fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ add_custom_target(luatest ) add_custom_target(luatest-no-coverage - COMMAND ${LUATEST} -v + COMMAND ${LUATEST} -v -c test/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Run regression tests without coverage" ) diff --git a/crud/schema.lua b/crud/schema.lua index 61288905..d7db5380 100644 --- a/crud/schema.lua +++ b/crud/schema.lua @@ -139,11 +139,9 @@ schema.init = function() box.space[SETTINGS_SPACE]:create_index('primary', { parts = { 'key' }, if_not_exists = true }) end else - while box.space[SETTINGS_SPACE] == nil or box.space[SETTINGS_SPACE].index[0] == nil do + if box.space[SETTINGS_SPACE] == nil or box.space[SETTINGS_SPACE].index[0] == nil then fiber.sleep(0.05) - if not box.info.ro then - goto init_start - end + goto init_start end end diff --git a/test/helper.lua b/test/helper.lua index eae17e8c..0ea76366 100644 --- a/test/helper.lua +++ b/test/helper.lua @@ -1217,39 +1217,8 @@ function helpers.backend_matrix(base_matrix, opts) end local backend_params = { - { - backend = helpers.backend.VSHARD, - backend_cfg = nil, - }, } - if helpers.is_cartridge_suite_supported() then - table.insert(backend_params, - { - backend = helpers.backend.CARTRIDGE, - backend_cfg = nil, - } - ) - end - - if helpers.is_name_supported_as_vshard_id() then - backend_params = helpers.extend_vshard_matrix( - backend_params, - 'identification_mode', - {'uuid_as_key', 'name_as_key'}, - {mode = 'replace'} - ) - end - - if helpers.is_master_discovery_supported_in_vshard() then - backend_params = helpers.extend_vshard_matrix( - backend_params, - 'master', - {'auto'}, - {mode = 'extend'} - ) - end - if helpers.is_tarantool3_crud_roles_supported() then table.insert(backend_params, { diff --git a/test/tarantool3_helpers/cluster.lua b/test/tarantool3_helpers/cluster.lua index df8caf81..68cada24 100644 --- a/test/tarantool3_helpers/cluster.lua +++ b/test/tarantool3_helpers/cluster.lua @@ -175,7 +175,15 @@ end function Cluster:wait_until_ready() for _, server in ipairs(self.servers) do - server:wait_until_ready() + local ok, err = pcall(server.wait_until_ready, server) + if not ok then + --utils.dump_cluster_xlogs(self.servers) + print("################# ERR: " .. err) + if string.find(err, 'for "server is ready" condition for server') then + self.__do_dump_cluster = true + end + error(err) + end end for _, server in ipairs(self.servers) do @@ -321,6 +329,12 @@ end function Cluster:drop() self:stop() + + --print('################# DO DUMP CLUSTER XLOGS = ' .. tostring(self.__do_dump_cluster)) + if self.__do_dump_cluster then + utils.dump_cluster_xlogs(self.servers) + end + treegen.clean(self.treegen) return self diff --git a/test/tarantool3_helpers/utils.lua b/test/tarantool3_helpers/utils.lua index 3d26dee3..d1ccf162 100644 --- a/test/tarantool3_helpers/utils.lua +++ b/test/tarantool3_helpers/utils.lua @@ -60,6 +60,54 @@ local function is_replicaset_a_crud_storage(group, replicaset) return is_replicaset_has_role(group, replicaset, 'roles.crud-storage') end +local utils = {} +function utils.dump_pretty(o, max_depth, __current_depth, __indent) + max_depth = max_depth or 8 + __current_depth = __current_depth or 0 + __indent = __indent or 0 + + if __current_depth > max_depth then + return '' + end + + if type(o) == 'table' then + local s = '{\n' + __indent = __indent + 1 + for k,v in pairs(o) do + if type(k) == 'table' then + k = '"<' .. tostring(k) .. '>"' + elseif type(k) ~= 'number' then + k = '"'..k..'"' + end + s = s .. string.rep(' ', 4*__indent) .. '['..k..'] = ' .. + utils.dump_pretty(v, max_depth, __current_depth + 1, __indent) .. ',\n' + end + __indent = __indent - 1 + return s .. string.rep(' ', 4*__indent) .. '}' + else + return tostring(o) + end +end + +local fio = require('fio') +local xlog = require('xlog') +local function dump_cluster_xlogs(servers) + print('###################### SNAP AND XLOG DUMP ######################') + for _, server in ipairs(servers) do + local xlogpath = fio.pathjoin(server.chdir, 'var', 'lib', server.alias) + if not fio.path.is_dir(xlogpath) then + error(xlogpath .. ' is not a directory') + end + + print('###################### ' .. server.alias .. ' ######################') + for _, fname in ipairs(fio.listdir(xlogpath)) do + print('########## ' .. fname) + print(utils.dump_pretty(xlog.pairs(fio.pathjoin(xlogpath, fname)):totable())) + end + end + print('###################### END OF DUMP ######################') +end + return { is_group_a_sharding_router = is_group_a_sharding_router, is_group_a_sharding_storage = is_group_a_sharding_storage, @@ -70,4 +118,7 @@ return { is_group_a_crud_storage = is_group_a_crud_storage, is_replicaset_a_crud_router = is_replicaset_a_crud_router, is_replicaset_a_crud_storage = is_replicaset_a_crud_storage, + + dump_pretty = utils.dump_pretty, + dump_cluster_xlogs = dump_cluster_xlogs, }