From 97b008d0836f9b1a5492a48634719a27e5b42b20 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 25 Mar 2024 19:27:36 +0300 Subject: [PATCH] test: run all cases on config cluster After this patch, all unit and integration tests run also on cluster started from configuration file. Part of #415 --- test/helper.lua | 360 +++++++++++++++++----- test/integration/select_readview_test.lua | 6 + test/integration/storages_state_test.lua | 4 +- test/performance/perf_test.lua | 68 +++- test/tarantool3_helpers/config.lua | 215 +++++++++++++ test/unit/call_test.lua | 62 +--- test/unit/not_initialized_test.lua | 43 ++- 7 files changed, 608 insertions(+), 150 deletions(-) create mode 100644 test/tarantool3_helpers/config.lua diff --git a/test/helper.lua b/test/helper.lua index 9a2a67bd..9447d8c9 100644 --- a/test/helper.lua +++ b/test/helper.lua @@ -1,8 +1,11 @@ require('strict').on() local t = require('luatest') + local vtest = require('test.vshard_helpers.vtest') local vclock_utils = require('test.vshard_helpers.vclock') +local tarantool3_config = require('test.tarantool3_helpers.config') +local tarantool3_cluster = require('test.tarantool3_helpers.cluster') local luatest_capture = require('luatest.capture') local luatest_helpers = require('luatest.helpers') @@ -27,6 +30,7 @@ local helpers = { backend = { VSHARD = 'vshard', CARTRIDGE = 'cartridge', + CONFIG = 'config', }, } @@ -77,7 +81,7 @@ function helpers.entrypoint_cartridge(name) return path end -local function entrypoint_vshard(name, entrypoint, err) +function helpers.entrypoint_vshard(name, entrypoint, err) local path = fio.pathjoin( 'test', 'entrypoint', name, entrypoint ) @@ -91,15 +95,15 @@ local function entrypoint_vshard(name, entrypoint, err) end function helpers.entrypoint_vshard_storage(name) - return entrypoint_vshard(name, 'storage', true) + return helpers.entrypoint_vshard(name, 'storage', true) end function helpers.entrypoint_vshard_router(name) - return entrypoint_vshard(name, 'router', true) + return helpers.entrypoint_vshard(name, 'router', true) end function helpers.entrypoint_vshard_all(name) - return entrypoint_vshard(name, 'all', true) + return helpers.entrypoint_vshard(name, 'all', true) end function helpers.table_keys(t) @@ -275,6 +279,46 @@ function helpers.get_test_vshard_sharding() return sharding end +function helpers.get_test_config_groups() + local groups = { + routers = { + sharding = { + roles = {'router'}, + }, + replicasets = { + ['router'] = { + leader = 'router', + instances = { + ['router'] = {}, + }, + }, + }, + }, + storages = { + sharding = { + roles = {'storage'}, + }, + replicasets = { + ['s-1'] = { + leader = 's1-master', + instances = { + ['s1-master'] = {}, + ['s1-replica'] = {}, + }, + }, + ['s-2'] = { + leader = 's2-master', + instances = { + ['s2-master'] = {}, + ['s2-replica'] = {}, + }, + }, + }, + }, + } + return groups +end + function helpers.call_on_servers(cluster, aliases, func) for _, alias in ipairs(aliases) do local server = cluster:server(alias) @@ -324,7 +368,7 @@ function helpers.call_on_storages(cluster, func, ...) -- NB: The 'servers' field contains server configs. They are -- not the same as server objects: say, there is no 'net_box' -- field here. - if cluster.replicasets ~= nil then + if cluster.replicasets ~= nil then -- CARTRIDGE backend local alias_map = {} for _, replicaset in ipairs(cluster.replicasets) do -- Whether it is a storage replicaset? @@ -351,7 +395,19 @@ function helpers.call_on_storages(cluster, func, ...) func(server, replicaset_alias, ...) end end - else + elseif cluster.config ~= nil then -- CONFIG backend + for _, group in pairs(cluster.config.groups) do + for rs_id, rs in pairs(group.replicasets) do + for alias, _ in pairs(rs.instances) do + local server = cluster:server(alias) + + if server:is_storage() then + func(server, rs_id, ...) + end + end + end + end + else -- VSHARD backend for _, server in ipairs(cluster.servers) do if server.vtest and server.vtest.is_storage then func(server, server.vtest.replicaset, ...) @@ -602,25 +658,104 @@ function helpers.assert_timeout_error(value, message) error(err, 2) end +local function inherit(self, object) + setmetatable(object, self) + self.__index = self + return object +end + +-- Implements log capture from log file. +local FileCapture = {inherit = inherit} + +function FileCapture:new(object) + checks('table', { + server = 'table', + }) + + self:inherit(object) + object:initialize() + return object +end + +function FileCapture:initialize() + local box_cfg_log = self.server:exec(function() + return box.cfg.log + end) + + local logpath = helpers.string_replace(box_cfg_log, 'file:', '') + + local relative_logpath = logpath:sub(1, 1) ~= '/' + if relative_logpath then + logpath = fio.pathjoin(self.server.chdir, logpath) + end + + local logfile, err = fio.open(logpath, {'O_RDONLY', 'O_NONBLOCK'}) + assert(err == nil, err) + + logfile:read() + + self.logfile = logfile +end + +function FileCapture:read() + return self.logfile:read() +end + +function FileCapture:close() + self.logfile:close() +end + +-- Implements wrapper over built-in Luatest capture. +local LuatestCapture = {inherit = inherit} + +function LuatestCapture:new() + local object = {} + self:inherit(object) + object:initialize() + return object +end + +function LuatestCapture:initialize() + self.capture = luatest_capture:new() + self.capture:enable() +end + +function LuatestCapture:read() + return self.capture:flush().stdout +end + +function LuatestCapture:close() + self.capture:disable() +end + +local function assert_class_implements_interface(class, interface) + for _, method in ipairs(interface) do + assert(type(class[method]) == 'function', ('class implements %q method'):format(method)) + end +end + +local Capture = { + 'new', + 'read', + 'close', +} + +assert_class_implements_interface(FileCapture, Capture) +assert_class_implements_interface(LuatestCapture, Capture) + function helpers.get_command_log(router, backend, call, args) local capture - local logfile - if backend == helpers.backend.CARTRIDGE then - capture = luatest_capture:new() - capture:enable() - elseif backend == helpers.backend.VSHARD then - local logpath = router.net_box:eval('return box.cfg.log') - logfile = fio.open(logpath, {'O_RDONLY', 'O_NONBLOCK'}) - logfile:read() + + local is_builtin_capture = backend == helpers.backend.CARTRIDGE + if is_builtin_capture then + capture = LuatestCapture:new() + else + capture = FileCapture:new({server = router}) end local _, err = router.net_box:call(call, args) if err ~= nil then - if backend == helpers.backend.CARTRIDGE then - capture:disable() - elseif backend == helpers.backend.VSHARD then - logfile:close() - end + capture:close() return nil, err end @@ -631,34 +766,13 @@ function helpers.get_command_log(router, backend, call, args) ]]) local captured = "" while not string.find(captured, "crud fflush message", 1, true) do - if backend == helpers.backend.CARTRIDGE then - captured = captured .. (capture:flush().stdout or "") - elseif backend == helpers.backend.VSHARD then - captured = captured .. (logfile:read() or "") - end + captured = captured .. (capture:read() or "") end - if backend == helpers.backend.CARTRIDGE then - capture:disable() - elseif backend == helpers.backend.VSHARD then - logfile:close() - end + capture:close() return captured, nil end -function helpers.fflush_main_server_stdout(cluster, capture) - -- Sometimes we have a delay here. This hack helps to wait for the end of - -- the output. It shouldn't take much time. - cluster.main_server.net_box:eval([[ - require('log').error("crud fflush stdout message") - ]]) - local captured = "" - while not string.find(captured, "crud fflush stdout message", 1, true) do - captured = captured .. (capture:flush().stdout or "") - end - return captured -end - function helpers.complement_tuples_batch_with_operations(tuples, operations) local tuples_operation_data = {} @@ -711,62 +825,106 @@ function helpers.skip_old_tarantool_cartridge_hotreload() "Cartridge hotreload tests stuck for vshard 0.1.22+ on Tarantool 2.2, 2.3 and 2.4") end -function helpers.start_default_cluster(g, srv_name) - local cartridge_cfg = { +function helpers.build_default_cartridge_cfg(srv_name) + return { datadir = fio.tempdir(), server_command = helpers.entrypoint_cartridge(srv_name), use_vshard = true, replicasets = helpers.get_test_cartridge_replicasets(), } - local vshard_cfg = { +end + +function helpers.build_default_vshard_cfg(srv_name) + return { sharding = helpers.get_test_vshard_sharding(), bucket_count = 3000, - storage_entrypoint = entrypoint_vshard(srv_name, 'storage', false), - router_entrypoint = entrypoint_vshard(srv_name, 'router', false), - all_entrypoint = entrypoint_vshard(srv_name, 'all', false), + storage_entrypoint = helpers.entrypoint_vshard(srv_name, 'storage', false), + router_entrypoint = helpers.entrypoint_vshard(srv_name, 'router', false), + all_entrypoint = helpers.entrypoint_vshard(srv_name, 'all', false), + crud_init = true, + } +end + +function helpers.build_default_tarantool3_cluster_cfg(srv_name) + return { + groups = helpers.get_test_config_groups(), + bucket_count = 3000, + storage_entrypoint = helpers.entrypoint_vshard(srv_name, 'storage', false), + router_entrypoint = helpers.entrypoint_vshard(srv_name, 'router', false), + all_entrypoint = helpers.entrypoint_vshard(srv_name, 'all', false), crud_init = true, } +end + +function helpers.start_default_cluster(g, srv_name) + local cartridge_cfg = helpers.build_default_cartridge_cfg(srv_name) + local vshard_cfg = helpers.build_default_vshard_cfg(srv_name) + local tarantool3_cluster_cfg = helpers.build_default_tarantool3_cluster_cfg(srv_name) - helpers.start_cluster(g, cartridge_cfg, vshard_cfg) + helpers.start_cluster(g, cartridge_cfg, vshard_cfg, tarantool3_cluster_cfg) end -function helpers.start_cluster(g, cartridge_cfg, vshard_cfg, opts) - checks('table', '?table', '?table', {wait_crud_is_ready = '?boolean'}) +function helpers.start_cartridge_cluster(g, cfg) + local cfg = table.deepcopy(cfg) + cfg.env = { + ['ENGINE'] = g.params.engine + } + + g.cfg = cfg + g.cluster = helpers.Cluster:new(cfg) - opts = opts or {} - if opts.wait_crud_is_ready == nil then - opts.wait_crud_is_ready = true + for k, server in ipairs(g.cluster.servers) do + local mt = getmetatable(server) + + local extended_mt = table.deepcopy(mt) + extended_mt.__index = vclock_utils.extend_with_vclock_methods(extended_mt.__index) + + g.cluster.servers[k] = setmetatable(server, extended_mt) end + g.cluster.main_server = g.cluster.servers[1] - if g.params.backend == helpers.backend.CARTRIDGE then - helpers.skip_cartridge_unsupported() + g.cluster:start() +end - local cfg = table.deepcopy(cartridge_cfg) - cfg.env = { - ['ENGINE'] = g.params.engine - } +function helpers.start_vshard_cluster(g, cfg) + local cfg = table.deepcopy(cfg) + cfg.engine = g.params.engine - g.cfg = cfg - g.cluster = helpers.Cluster:new(cfg) + g.cfg = vtest.config_new(cfg, g.params.backend_cfg) + vtest.cluster_new(g, g.cfg) + g.cfg.engine = nil +end - for k, server in ipairs(g.cluster.servers) do - local mt = getmetatable(server) +function helpers.start_tarantool3_cluster(g, cfg) + local cfg = table.deepcopy(cfg) + cfg.env = { + ['ENGINE'] = g.params.engine, + } + cfg = tarantool3_config.new(cfg) - local extended_mt = table.deepcopy(mt) - extended_mt.__index = vclock_utils.extend_with_vclock_methods(extended_mt.__index) + g.cfg = cfg + g.cluster = tarantool3_cluster:new(cfg) + g.cluster:start() +end - g.cluster.servers[k] = setmetatable(server, extended_mt) - end - g.cluster.main_server = g.cluster.servers[1] +function helpers.start_cluster(g, cartridge_cfg, vshard_cfg, tarantool3_cluster_cfg, opts) + checks('table', '?table', '?table', '?table', {wait_crud_is_ready = '?boolean'}) + + opts = opts or {} + if opts.wait_crud_is_ready == nil then + opts.wait_crud_is_ready = true + end + + if g.params.backend == helpers.backend.CARTRIDGE then + helpers.skip_cartridge_unsupported() - g.cluster:start() + helpers.start_cartridge_cluster(g, cartridge_cfg) elseif g.params.backend == helpers.backend.VSHARD then - local cfg = table.deepcopy(vshard_cfg) - cfg.engine = g.params.engine + helpers.start_vshard_cluster(g, vshard_cfg) + elseif g.params.backend == helpers.backend.CONFIG then + helpers.skip_if_tarantool_config_unsupported() - g.cfg = vtest.config_new(cfg, g.params.backend_cfg) - vtest.cluster_new(g, g.cfg) - g.cfg.engine = nil + helpers.start_tarantool3_cluster(g, tarantool3_cluster_cfg) end g.router = g.cluster:server('router') @@ -794,6 +952,8 @@ local function count_storages_in_topology(g, backend, vshard_group, storage_role storages_in_topology = storages_in_topology + 1 end end + elseif backend == helpers.backend.CONFIG then + error('not implemented yet') end return storages_in_topology @@ -852,15 +1012,28 @@ function helpers.wait_crud_is_ready_on_cluster(g, opts) opts.storage_roles = {'crud-storage'} end - local storages_in_topology = count_storages_in_topology(g, opts.backend, opts.vshard_group, opts.storage_roles) + local default_impl = function() + local storages_in_topology = count_storages_in_topology( + g, + opts.backend, + opts.vshard_group, + opts.storage_roles + ) - local WAIT_TIMEOUT = 5 - local DELAY = 0.1 - t.helpers.retrying( - {timeout = WAIT_TIMEOUT, delay = DELAY}, - assert_expected_number_of_storages_is_running, - g, opts.vshard_group, storages_in_topology - ) + local WAIT_TIMEOUT = 5 + local DELAY = 0.1 + t.helpers.retrying( + {timeout = WAIT_TIMEOUT, delay = DELAY}, + assert_expected_number_of_storages_is_running, + g, opts.vshard_group, storages_in_topology + ) + end + + if g.cluster.wait_crud_is_ready_on_cluster ~= nil then + g.cluster:wait_crud_is_ready_on_cluster() + else + default_impl() + end end function helpers.stop_cluster(cluster, backend) @@ -868,6 +1041,8 @@ function helpers.stop_cluster(cluster, backend) helpers.stop_cartridge_cluster(cluster) elseif backend == helpers.backend.VSHARD then cluster:drop() + elseif backend == helpers.backend.CONFIG then + cluster:drop() end end @@ -991,6 +1166,15 @@ function helpers.backend_matrix(base_matrix) ) end + if helpers.is_tarantool_config_supported() then + table.insert(backend_params, + { + backend = helpers.backend.CONFIG, + backend_cfg = nil, + } + ) + end + local matrix = {} for _, params in ipairs(backend_params) do for _, base in ipairs(base_matrix) do @@ -1266,4 +1450,14 @@ function helpers.skip_box_watch_supported() t.skip_if(helpers.is_box_watch_supported(), 'box.watch is supported') end +function helpers.is_tarantool_config_supported() + local tarantool_version = luatest_utils.get_tarantool_version() + return luatest_utils.version_ge(tarantool_version, luatest_utils.version(3, 0, 0)) +end + +function helpers.skip_if_tarantool_config_unsupported() + t.skip_if(not helpers.is_tarantool_config_supported(), + ("Tarantool %s does not support starting from config"):format(box.info.version)) +end + return helpers diff --git a/test/integration/select_readview_test.lua b/test/integration/select_readview_test.lua index aed46fed..a524795c 100644 --- a/test/integration/select_readview_test.lua +++ b/test/integration/select_readview_test.lua @@ -2322,6 +2322,12 @@ pgroup.test_stop_select = function(g) require('vshard.storage').cfg(cfg, box.info[bootstrap_key]) require('crud').init_storage() end, {g.cfg, bootstrap_key}) + elseif g.params.backend == helpers.backend.CONFIG then + g.cluster:server('s2-master'):wait_for_rw() + + g.cluster:server('s2-master'):exec(function() + require('crud').init_storage() + end) end helpers.wait_crud_is_ready_on_cluster(g) diff --git a/test/integration/storages_state_test.lua b/test/integration/storages_state_test.lua index fc9baf58..bcaa7918 100644 --- a/test/integration/storages_state_test.lua +++ b/test/integration/storages_state_test.lua @@ -51,10 +51,12 @@ end) local function build_storage_info(g, array_info) local is_vshard = g.params.backend == 'vshard' + local is_config = g.params.backend == 'config' + local name_as_key = is_vshard and ( type(g.params.backend_cfg) == 'table' and g.params.backend_cfg.identification_mode == 'name_as_key' - ) + ) or is_config local keys if name_as_key then diff --git a/test/performance/perf_test.lua b/test/performance/perf_test.lua index 24db407c..63e41bc6 100644 --- a/test/performance/perf_test.lua +++ b/test/performance/perf_test.lua @@ -10,7 +10,17 @@ local t = require('luatest') local helpers = require('test.helper') -local g = t.group('perf', {{backend = helpers.backend.VSHARD}}) +local PERF_MODE_ON = os.getenv('PERF_MODE_ON') + +local g +if PERF_MODE_ON then + -- With full matrix perf tests length is 1-2 hours + -- at the moment of writing this comment. + g = t.group('perf', {{backend = helpers.backend.VSHARD}}) +else + -- Check that available options are not broken with quick run. + g = t.group('perf', helpers.backend_matrix()) +end local id = 0 local function gen() @@ -98,6 +108,56 @@ local cartridge_cfg_template = { }, } +local tarantool3_cluster_cfg_template = { + groups = { + routers = { + sharding = { + roles = {'router'}, + }, + replicasets = { + ['router'] = { + leader = 'router', + instances = { + ['router'] = {}, + }, + }, + }, + }, + storages = { + sharding = { + roles = {'storage'}, + }, + replicasets = { + ['s-1'] = { + leader = 's1-master', + instances = { + ['s1-master'] = {}, + ['s1-replica'] = {}, + }, + }, + ['s-2'] = { + leader = 's2-master', + instances = { + ['s2-master'] = {}, + ['s2-replica'] = {}, + }, + }, + ['s-3'] = { + leader = 's3-master', + instances = { + ['s3-master'] = {}, + ['s3-replica'] = {}, + }, + }, + }, + }, + }, + bucket_count = 3000, + router_entrypoint = helpers.entrypoint_vshard_storage('srv_ddl'), + storage_entrypoint = helpers.entrypoint_vshard_storage('srv_ddl'), + crud_init = true, +} + g.before_all(function(g) -- Run real perf tests only with flag, otherwise run short version -- to test compatibility as part of unit/integration test run. @@ -108,7 +168,11 @@ g.before_all(function(g) helpers.disable_dev_checks() end - helpers.start_cluster(g, cartridge_cfg_template, vshard_cfg_template) + helpers.start_cluster(g, + cartridge_cfg_template, + vshard_cfg_template, + tarantool3_cluster_cfg_template + ) g.router:eval([[ rawset(_G, 'crud', require('crud')) diff --git a/test/tarantool3_helpers/config.lua b/test/tarantool3_helpers/config.lua new file mode 100644 index 00000000..f8822e0e --- /dev/null +++ b/test/tarantool3_helpers/config.lua @@ -0,0 +1,215 @@ +local checks = require('checks') + +local utils = require('test.tarantool3_helpers.utils') + +local function set_listen_uris_to_instances(groups) + local port = 3301 + + for _, group in pairs(groups) do + for _, replicaset in pairs(group.replicasets) do + for _, instance in pairs(replicaset.instances) do + instance.iproto = {listen = {{uri = ('localhost:%d'):format(port)}}} + + port = port + 1 + end + end + end + + return groups +end + +local Script = { + new = function(self) + local object = {_contents = ''} + + setmetatable(object, self) + self.__index = self + return object + end, + append = function(self, code) + self._contents = self._contents .. ("%s;"):format(code) + end, + append_require_and_run = function(self, to_require, to_run) + self:append(([[ + do + local to_require = %q + local to_run = %q + + local module = require(to_require) + local method = to_run + if module[method] ~= nil then + module[method]() + end + end + ]]):format(to_require, to_run)) + end, + dump = function(self) + return self._contents + end, +} + +local function generate_modules(storage_entrypoint, router_entrypoint, all_entrypoint) + local router = Script:new() + local storage = Script:new() + local router_and_storage = Script:new() + + if storage_entrypoint ~= nil then + storage:append_require_and_run(storage_entrypoint, 'init') + router_and_storage:append_require_and_run(storage_entrypoint, 'init') + end + + if router_entrypoint ~= nil then + router:append_require_and_run(router_entrypoint, 'init') + router_and_storage:append_require_and_run(router_entrypoint, 'init') + end + + if all_entrypoint ~= nil then + router:append_require_and_run(all_entrypoint, 'init') + storage:append_require_and_run(all_entrypoint, 'init') + router_and_storage:append_require_and_run(all_entrypoint, 'init') + end + + return { + ['router'] = router:dump(), + ['storage'] = storage:dump(), + ['router_and_storage'] = router_and_storage:dump(), + } +end + +local function generate_wait_until_ready_evals(storage_entrypoint, router_entrypoint, all_entrypoint) + local router = Script:new() + local storage = Script:new() + + if storage_entrypoint ~= nil then + storage:append_require_and_run(storage_entrypoint, 'wait_until_ready') + end + + if router_entrypoint ~= nil then + router:append_require_and_run(router_entrypoint, 'wait_until_ready') + end + + if all_entrypoint ~= nil then + router:append_require_and_run(all_entrypoint, 'wait_until_ready') + storage:append_require_and_run(all_entrypoint, 'wait_until_ready') + end + + return { + ['router'] = router:dump(), + ['storage'] = storage:dump(), + } +end + +local function set_app_module(app, is_router, is_storage) + if is_router and is_storage then + app.module = 'router_and_storage' + elseif is_router then + app.module = 'router' + elseif is_storage then + app.module = 'storage' + end + + return app +end + +local function set_modules_to_groups(groups) + for _, group in pairs(groups) do + group.app = group.app or {} + + local is_router = utils.is_group_a_sharding_router(group) + local is_storage = utils.is_group_a_sharding_storage(group) + + group.app = set_app_module(group.app, is_router, is_storage) + end + + return groups +end + +-- Do not deepcopy anything here. +local function new(cfg) + checks({ + groups = 'table', + bucket_count = 'number', + storage_entrypoint = '?string', + router_entrypoint = '?string', + all_entrypoint = '?string', + env = '?table', + crud_init = '?boolean', + }) + + local modules = generate_modules( + cfg.storage_entrypoint, + cfg.router_entrypoint, + cfg.all_entrypoint + ) + + local credentials = { + users = { + guest = { + roles = {'super'}, + }, + replicator = { + password = 'replicating', + roles = {'replication'}, + }, + storage = { + password = 'storing-buckets', + roles = {'sharding'}, + }, + }, + } + + local iproto = { + advertise = { + peer = { + login = 'replicator', + }, + sharding = { + login = 'storage' + }, + }, + } + + local sharding = { + bucket_count = cfg.bucket_count, + } + + local groups = cfg.groups + groups = set_listen_uris_to_instances(groups) + groups = set_modules_to_groups(groups) + + local replication = { + failover = 'manual', + } + + local log = { + to = 'file', + } + + local config = { + credentials = credentials, + iproto = iproto, + sharding = sharding, + groups = groups, + replication = replication, + log = log, + } + + local wait_until_ready_evals = generate_wait_until_ready_evals( + cfg.storage_entrypoint, + cfg.router_entrypoint, + cfg.all_entrypoint + ) + + return { + config = config, + modules = modules, + crud_init = cfg.crud_init, + env = cfg.env, + router_wait_until_ready = wait_until_ready_evals.router, + storage_wait_until_ready = wait_until_ready_evals.storage, + } +end + +return { + new = new, +} \ No newline at end of file diff --git a/test/unit/call_test.lua b/test/unit/call_test.lua index 4a9a7cc4..e7e910b6 100644 --- a/test/unit/call_test.lua +++ b/test/unit/call_test.lua @@ -1,71 +1,11 @@ -local fio = require('fio') - local t = require('luatest') local helpers = require('test.helper') local pgroup = t.group('call', helpers.backend_matrix()) -local vshard_cfg_template = { - sharding = { - ['s-1'] = { - replicas = { - ['s1-master'] = { - master = true, - }, - ['s1-replica'] = {}, - }, - }, - ['s-2'] = { - replicas = { - ['s2-master'] = { - master = true, - }, - ['s2-replica'] = {}, - }, - }, - }, - bucket_count = 3000, - all_entrypoint = helpers.entrypoint_vshard_all('srv_say_hi'), - crud_init = true, -} - -local cartridge_cfg_template = { - datadir = fio.tempdir(), - server_command = helpers.entrypoint_cartridge('srv_say_hi'), - use_vshard = true, - replicasets = { - { - uuid = helpers.uuid('a'), - alias = 'router', - roles = { 'crud-router' }, - servers = { - { instance_uuid = helpers.uuid('a', 1), alias = 'router' }, - }, - }, - { - uuid = helpers.uuid('b'), - alias = 's-1', - roles = { 'crud-storage' }, - servers = { - { instance_uuid = helpers.uuid('b', 1), alias = 's1-master' }, - { instance_uuid = helpers.uuid('b', 2), alias = 's1-replica' }, - }, - }, - { - uuid = helpers.uuid('c'), - alias = 's-2', - roles = { 'crud-storage' }, - servers = { - { instance_uuid = helpers.uuid('c', 1), alias = 's2-master' }, - { instance_uuid = helpers.uuid('c', 2), alias = 's2-replica' }, - }, - } - }, -} - pgroup.before_all(function(g) - helpers.start_cluster(g, cartridge_cfg_template, vshard_cfg_template) + helpers.start_default_cluster(g, 'srv_say_hi') g.clear_vshard_calls = function() g.router:call('clear_vshard_calls') diff --git a/test/unit/not_initialized_test.lua b/test/unit/not_initialized_test.lua index 2e23e5bb..f246ae33 100644 --- a/test/unit/not_initialized_test.lua +++ b/test/unit/not_initialized_test.lua @@ -45,10 +45,47 @@ local cartridge_cfg_template = { }, } +local tarantool3_cluster_cfg_template = { + groups = { + routers = { + sharding = { + roles = {'router'}, + }, + replicasets = { + ['router'] = { + leader = 'router', + instances = { + ['router'] = {}, + }, + }, + }, + }, + storages = { + sharding = { + roles = {'storage'}, + }, + replicasets = { + ['s-1'] = { + leader = 's1-master', + instances = { + ['s1-master'] = {}, + }, + }, + }, + }, + }, + bucket_count = 20, + storage_entrypoint = helpers.entrypoint_vshard_storage('srv_not_initialized'), + crud_init = false, +} + pgroup.before_all(function(g) - helpers.start_cluster(g, cartridge_cfg_template, vshard_cfg_template, { - wait_crud_is_ready = false, - }) + helpers.start_cluster(g, + cartridge_cfg_template, + vshard_cfg_template, + tarantool3_cluster_cfg_template, + {wait_crud_is_ready = false} + ) g.router = g.cluster:server('router') end)