From e72608f96b465d4f399dbbf7722b3c284fd10289 Mon Sep 17 00:00:00 2001 From: Nikita Zheleztsov Date: Mon, 25 Nov 2024 05:58:46 +0300 Subject: [PATCH] mkversion: drop the module Since the issue #10521 introduced new public `version` module, `internal.mkversion` is not needed anymore. All functions, which are not inside the `version` module are exported to the `box.internal` now. `mkversion` is replaced with `version`. Follow-up #10521 NO_DOC=internal NO_CHANGELOG=internal --- src/box/CMakeLists.txt | 2 +- src/box/lua/config/applier/box_cfg.lua | 18 ++-- src/box/lua/config/applier/box_status.lua | 6 +- src/box/lua/config/applier/credentials.lua | 14 +-- src/box/lua/init.c | 4 +- src/box/lua/load_cfg.lua | 4 +- src/box/lua/mkversion.lua | 80 ---------------- src/box/lua/upgrade.lua | 95 ++++++++++--------- src/box/lua/version.lua | 45 +++++++++ test/box-luatest/downgrade_test.lua | 13 +-- .../gh_10180_upgrade_from_1_6_9_test.lua | 2 +- test/box-luatest/upgrade_to_3_0_0_test.lua | 10 +- test/config-luatest/upgrade_test.lua | 8 +- 13 files changed, 131 insertions(+), 170 deletions(-) delete mode 100644 src/box/lua/mkversion.lua create mode 100644 src/box/lua/version.lua diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index 599455c5f750..c71cdeffafd5 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -41,7 +41,7 @@ lua_source(lua_sources lua/xlog.lua xlog_lua) lua_source(lua_sources lua/key_def.lua key_def_lua) lua_source(lua_sources lua/merger.lua merger_lua) lua_source(lua_sources lua/iproto.lua iproto_lua) -lua_source(lua_sources lua/mkversion.lua mkversion_lua) +lua_source(lua_sources lua/version.lua internal_version_lua) # {{{ config lua_source(lua_sources lua/config/applier/app.lua config_applier_app_lua) diff --git a/src/box/lua/config/applier/box_cfg.lua b/src/box/lua/config/applier/box_cfg.lua index 4eed9353c107..f5a37cd52651 100644 --- a/src/box/lua/config/applier/box_cfg.lua +++ b/src/box/lua/config/applier/box_cfg.lua @@ -3,7 +3,7 @@ local log = require('internal.config.utils.log') local instance_config = require('internal.config.instance_config') local snapshot = require('internal.config.utils.snapshot') local schedule_task = fiber._internal.schedule_task -local mkversion = require('internal.mkversion') +local version = require('version') local tarantool = require('tarantool') local clock = require('clock') @@ -399,9 +399,9 @@ local function names_schema_upgrade_on_replace(old, new) return end - local expected_version = mkversion(2, 11, 5) - local old_version = mkversion.from_tuple(old) - local new_version = mkversion.from_tuple(new) + local expected_version = version.new(2, 11, 5) + local old_version = box.internal.version_from_tuple(old) + local new_version = box.internal.version_from_tuple(new) if old_version < expected_version and new_version >= expected_version then -- We cannot do it inside on_replace trigger, as the version -- is not considered set yet and we may try to set names, when @@ -472,7 +472,8 @@ local function names_apply(config, missing_names, schema_version) names_alert_missing(config, missing_names) -- Don't wait for box.status to change, we may be already rw, set names -- on reload, if it's possible and needed. - if schema_version and schema_version >= mkversion.get_latest() then + if schema_version and + schema_version >= box.internal.latest_dd_version() then names_try_set_missing() end @@ -486,7 +487,7 @@ local function names_apply(config, missing_names, schema_version) -- Wait for rw state and schema 2.11.5 to apply names. If schema version -- is nil, bootstrap is going to be done. - if schema_version and schema_version < mkversion(2, 11, 5) then + if schema_version and schema_version < version.new(2, 11, 5) then box.space._schema:on_replace(names_schema_upgrade_on_replace) names_state.is_upgrade_wait = true else @@ -499,7 +500,8 @@ end local function get_schema_version_before_cfg(config) local snap_path = snapshot.get_path(config._configdata._iconfig_def) if snap_path ~= nil then - return mkversion.from_tuple(snapshot.get_schema_version(snap_path)) + local tuple = snapshot.get_schema_version(snap_path) + return box.internal.version_from_tuple(tuple) end -- Bootstrap, config not found return nil @@ -849,7 +851,7 @@ local function apply(config) end) else -- Note, that we try to find new missing names on every reload. - names_apply(config, missing_names, mkversion.get()) + names_apply(config, missing_names, box.internal.dd_version()) end end diff --git a/src/box/lua/config/applier/box_status.lua b/src/box/lua/config/applier/box_status.lua index 19cfce876753..f51cea348fed 100644 --- a/src/box/lua/config/applier/box_status.lua +++ b/src/box/lua/config/applier/box_status.lua @@ -1,5 +1,3 @@ -local mkversion = require('internal.mkversion') - local box_status_state = { watcher = nil, } @@ -29,8 +27,8 @@ local function drop_schema_version_alert() end local function check_schema_version() - local current_version = mkversion.get() - local latest_version = mkversion.get_latest() + local current_version = box.internal.dd_version() + local latest_version = box.internal.latest_dd_version() if current_version < latest_version then set_schema_version_alert(current_version, latest_version) else diff --git a/src/box/lua/config/applier/credentials.lua b/src/box/lua/config/applier/credentials.lua index ec8070b0ee06..e0de01256828 100644 --- a/src/box/lua/config/applier/credentials.lua +++ b/src/box/lua/config/applier/credentials.lua @@ -3,7 +3,7 @@ local log = require('internal.config.utils.log') local loaders = require('internal.loaders') local digest = require('digest') local fiber = require('fiber') -local mkversion = require('internal.mkversion') +local version = require('version') -- Var is set with the first apply() call. local config @@ -669,9 +669,9 @@ local schema_is_upgraded = false -- the current tarantool version. local schema_is_upgraded_cond -local function update_schema_upgraded_status(version) - local schema_version = version or mkversion.get() - schema_is_upgraded = schema_version >= mkversion(2, 11, 1) +local function update_schema_upgraded_status(current_version) + local schema_version = current_version or box.internal.dd_version() + schema_is_upgraded = schema_version >= version.new(2, 11, 1) if schema_is_upgraded then assert(schema_is_upgraded_cond ~= nil) @@ -685,9 +685,9 @@ local function on_schema_replace_trigger(old, new) return end - local expected_version = mkversion(2, 11, 1) - local old_version = mkversion.from_tuple(old) - local new_version = mkversion.from_tuple(new) + local expected_version = version.new(2, 11, 1) + local old_version = box.internal.version_from_tuple(old) + local new_version = box.internal.version_from_tuple(new) if old_version < expected_version and new_version >= expected_version then box.on_commit(function() update_schema_upgraded_status(new_version) diff --git a/src/box/lua/init.c b/src/box/lua/init.c index 2de76b2b09ae..f1e72f1d9adb 100644 --- a/src/box/lua/init.c +++ b/src/box/lua/init.c @@ -101,7 +101,7 @@ extern char session_lua[], #endif net_box_lua[], net_replicaset_lua[], - mkversion_lua[], + internal_version_lua[], upgrade_lua[], console_lua[], merger_lua[], @@ -227,7 +227,7 @@ static const char *lua_sources[] = { SECURITY_BOX_LUA_MODULES INTEGRITY_BOX_LUA_MODULES "box/xlog", "xlog", xlog_lua, - "box/mkversion", "internal.mkversion", mkversion_lua, + "box/version", NULL, internal_version_lua, "box/upgrade", NULL, upgrade_lua, "box/net_box", "net.box", net_box_lua, "box/net_replicaset", "internal.net.replicaset", net_replicaset_lua, diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 0a545f28572e..e3fa33d4be81 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -8,7 +8,6 @@ local math = require('math') local fiber = require('fiber') local fio = require('fio') local compat = require('compat') -local mkversion = require('internal.mkversion') local function nop() end @@ -1212,7 +1211,8 @@ local function load_cfg(cfg) local msg = string.format( 'Your schema version is %s while Tarantool %s requires a more'.. ' recent schema version. Please, consider using box.'.. - 'schema.upgrade().', tostring(mkversion.get()), box.info.version) + 'schema.upgrade().', tostring(box.internal.dd_version()), + box.info.version) log.warn(msg) end end diff --git a/src/box/lua/mkversion.lua b/src/box/lua/mkversion.lua deleted file mode 100644 index f740bd56b515..000000000000 --- a/src/box/lua/mkversion.lua +++ /dev/null @@ -1,80 +0,0 @@ -local bit = require('bit') -local ffi = require('ffi') - -ffi.cdef([[ - uint32_t box_dd_version_id(void); - uint32_t box_latest_dd_version_id(void); -]]) - -local builtin = ffi.C - -local mkversion_mt = { - __tostring = function(self) - return string.format('%s.%s.%s', self.major, self.minor, self.patch) - end, - __eq = function(lhs, rhs) - return lhs.id == rhs.id - end, - __lt = function(lhs, rhs) - return lhs.id < rhs.id - end, -} - -local function mkversion_new(major, minor, patch) - local self = setmetatable({}, mkversion_mt) - self.major = major - self.minor = minor - self.patch = patch - self.id = bit.bor(bit.lshift(bit.bor(bit.lshift(major, 8), minor), 8), - patch) - return self -end - --- Parse string with version in format 'A.B.C' to version object. -local function mkversion_from_string(version) - local major, minor, patch = version:match('^(%d+)%.(%d+)%.(%d+)$') - if major == nil then - error('version should be in format A.B.C') - end - return mkversion_new(tonumber(major), tonumber(minor), tonumber(patch)) -end - -local function mkversion_from_id(version_id) - local major = bit.band(bit.rshift(version_id, 16), 0xff) - local minor = bit.band(bit.rshift(version_id, 8), 0xff) - local patch = bit.band(version_id, 0xff) - return mkversion_new(major, minor, patch) -end - --- Schema version of the snapshot. -local function mkversion_get() - local version = builtin.box_dd_version_id() - return mkversion_from_id(version) -end - --- Latest schema version this instance recognizes. -local function mkversion_get_latest() - local version = builtin.box_latest_dd_version_id() - return mkversion_from_id(version) -end - -local function mkversion_from_tuple(tuple) - local major, minor, patch = tuple:unpack(2, 4) - patch = patch or 0 - if major and minor and type(major) == 'number' and - type(minor) == 'number' and type(patch) == 'number' then - return mkversion_new(major, minor, patch) - end - return nil -end - -return setmetatable({ - new = mkversion_new, - get = mkversion_get, - get_latest = mkversion_get_latest, - from_id = mkversion_from_id, - from_tuple = mkversion_from_tuple, - from_string = mkversion_from_string, -}, { - __call = function(self, ...) return mkversion_new(...) end; -}) diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index f1acd8b368a1..6633e5273dea 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -7,7 +7,7 @@ local ffi = require('ffi') local fun = require('fun') local utils = require('internal.utils') local tarantool = require('tarantool') -local mkversion = require('internal.mkversion') +local mkversion = require('version') ffi.cdef([[ void box_init_latest_dd_version_id(uint32_t version_id); @@ -124,7 +124,7 @@ local function get_snapshot_version(snap_dir) if sid == box.schema.SCHEMA_ID then local tuple = row.BODY.tuple if tuple and tuple[1] == 'version' then - version = mkversion.from_tuple(tuple) + version = box.internal.version_from_tuple(tuple) if not version then log.error("Corrupted version tuple in space '_schema' ".. "in snapshot '%s': %s ", snap, tuple) @@ -1506,30 +1506,31 @@ end -------------------------------------------------------------------------------- local handlers = { - {version = mkversion(1, 7, 5), func = upgrade_to_1_7_5}, - {version = mkversion(1, 7, 6), func = upgrade_to_1_7_6}, - {version = mkversion(1, 7, 7), func = upgrade_to_1_7_7}, - {version = mkversion(1, 10, 0), func = upgrade_to_1_10_0}, - {version = mkversion(1, 10, 2), func = upgrade_to_1_10_2}, - {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0}, - {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1}, - {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2}, - {version = mkversion(2, 1, 3), func = upgrade_to_2_1_3}, - {version = mkversion(2, 2, 1), func = upgrade_to_2_2_1}, - {version = mkversion(2, 3, 0), func = upgrade_to_2_3_0}, - {version = mkversion(2, 3, 1), func = upgrade_to_2_3_1}, - {version = mkversion(2, 7, 1), func = upgrade_to_2_7_1}, - {version = mkversion(2, 9, 1), func = upgrade_to_2_9_1}, - {version = mkversion(2, 10, 1), func = upgrade_to_2_10_1}, - {version = mkversion(2, 10, 4), func = upgrade_to_2_10_4}, - {version = mkversion(2, 10, 5), func = upgrade_to_2_10_5}, - {version = mkversion(2, 11, 0), func = upgrade_to_2_11_0}, - {version = mkversion(2, 11, 1), func = upgrade_to_2_11_1}, - {version = mkversion(3, 0, 0), func = upgrade_to_3_0_0}, - {version = mkversion(3, 1, 0), func = upgrade_to_3_1_0}, - {version = mkversion(3, 3, 0), func = upgrade_to_3_3_0}, + {version = mkversion.new(1, 7, 5), func = upgrade_to_1_7_5}, + {version = mkversion.new(1, 7, 6), func = upgrade_to_1_7_6}, + {version = mkversion.new(1, 7, 7), func = upgrade_to_1_7_7}, + {version = mkversion.new(1, 10, 0), func = upgrade_to_1_10_0}, + {version = mkversion.new(1, 10, 2), func = upgrade_to_1_10_2}, + {version = mkversion.new(2, 1, 0), func = upgrade_to_2_1_0}, + {version = mkversion.new(2, 1, 1), func = upgrade_to_2_1_1}, + {version = mkversion.new(2, 1, 2), func = upgrade_to_2_1_2}, + {version = mkversion.new(2, 1, 3), func = upgrade_to_2_1_3}, + {version = mkversion.new(2, 2, 1), func = upgrade_to_2_2_1}, + {version = mkversion.new(2, 3, 0), func = upgrade_to_2_3_0}, + {version = mkversion.new(2, 3, 1), func = upgrade_to_2_3_1}, + {version = mkversion.new(2, 7, 1), func = upgrade_to_2_7_1}, + {version = mkversion.new(2, 9, 1), func = upgrade_to_2_9_1}, + {version = mkversion.new(2, 10, 1), func = upgrade_to_2_10_1}, + {version = mkversion.new(2, 10, 4), func = upgrade_to_2_10_4}, + {version = mkversion.new(2, 10, 5), func = upgrade_to_2_10_5}, + {version = mkversion.new(2, 11, 0), func = upgrade_to_2_11_0}, + {version = mkversion.new(2, 11, 1), func = upgrade_to_2_11_1}, + {version = mkversion.new(3, 0, 0), func = upgrade_to_3_0_0}, + {version = mkversion.new(3, 1, 0), func = upgrade_to_3_1_0}, + {version = mkversion.new(3, 3, 0), func = upgrade_to_3_3_0}, } -builtin.box_init_latest_dd_version_id(handlers[#handlers].version.id) +builtin.box_init_latest_dd_version_id( + box.internal.version_to_id(handlers[#handlers].version)) local trig_oldest_version = nil @@ -1551,20 +1552,20 @@ local trig_oldest_version = nil -- * then usual upgrade_to_X_X_X() handlers may be fired to turn schema into the -- latest one. local recovery_triggers = { - {version = mkversion(1, 7, 1), tbl = { + {version = mkversion.new(1, 7, 1), tbl = { _user = user_trig_1_7_1, }}, - {version = mkversion(1, 7, 2), tbl = { + {version = mkversion.new(1, 7, 2), tbl = { _index = index_trig_1_7_2, }}, - {version = mkversion(1, 7, 5), tbl = { + {version = mkversion.new(1, 7, 5), tbl = { _space = space_trig_1_7_5, _user = user_trig_1_7_5, }}, - {version = mkversion(1, 7, 6), tbl = { + {version = mkversion.new(1, 7, 6), tbl = { _space = space_trig_1_7_6, }}, - {version = mkversion(1, 7, 7), tbl = { + {version = mkversion.new(1, 7, 7), tbl = { _priv = priv_trig_1_7_7, }}, } @@ -1573,7 +1574,7 @@ local recovery_triggers = { -- snapshot), the triggers helping recover the old schema should be removed. local function schema_trig_last(_, tuple) if tuple and tuple[1] == 'version' then - local version = mkversion.from_tuple(tuple) + local version = box.internal.version_from_tuple(tuple) if version then log.info("Recovery trigger: recovered schema version %s. ".. "Removing outdated recovery triggers.", version) @@ -1618,7 +1619,7 @@ local function clear_recovery_triggers(version) end local function upgrade_from(version) - if version < mkversion(1, 6, 8) then + if version < mkversion.new(1, 6, 8) then log.warn('can upgrade from 1.6.8 only') return end @@ -1652,7 +1653,7 @@ local function run_upgrade(func, ...) end local function upgrade() - local version = mkversion.get() + local version = box.internal.dd_version() run_upgrade(upgrade_from, version) end @@ -2122,14 +2123,14 @@ end -- if schema version is 2.10.0. -- local downgrade_handlers = { - {version = mkversion(3, 3, 0), func = downgrade_from_3_3_0}, - {version = mkversion(3, 1, 0), func = downgrade_from_3_1_0}, - {version = mkversion(3, 0, 0), func = downgrade_from_3_0_0}, - {version = mkversion(2, 11, 1), func = downgrade_from_2_11_1}, - {version = mkversion(2, 11, 0), func = downgrade_from_2_11_0}, - {version = mkversion(2, 10, 5), func = downgrade_from_2_10_5}, - {version = mkversion(2, 10, 0), func = downgrade_from_2_10_0}, - {version = mkversion(2, 9, 1), func = downgrade_from_2_9_1}, + {version = mkversion.new(3, 3, 0), func = downgrade_from_3_3_0}, + {version = mkversion.new(3, 1, 0), func = downgrade_from_3_1_0}, + {version = mkversion.new(3, 0, 0), func = downgrade_from_3_0_0}, + {version = mkversion.new(2, 11, 1), func = downgrade_from_2_11_1}, + {version = mkversion.new(2, 11, 0), func = downgrade_from_2_11_0}, + {version = mkversion.new(2, 10, 5), func = downgrade_from_2_10_5}, + {version = mkversion.new(2, 10, 0), func = downgrade_from_2_10_0}, + {version = mkversion.new(2, 9, 1), func = downgrade_from_2_9_1}, } -- This downgrade issue handler is used to raise an error when issue is @@ -2167,8 +2168,8 @@ end -- Find schema version which does not require upgrade for given application -- version. For example: -- --- app2schema_version(mkversion('2.10.3')) == mkversion('2.10.1') --- app2schema_version(mkversion('2.10.0')) == mkversion('2.9.1') +-- app2schema_version(mkversion.new('2.10.3')) == mkversion.new('2.10.1') +-- app2schema_version(mkversion.new('2.10.0')) == mkversion.new('2.9.1') local function app2schema_version(app_version) local schema_version for _, handler in ipairs(handlers) do @@ -2234,15 +2235,15 @@ local downgrade_versions = { local function downgrade_impl(version_str, dry_run) utils.box_check_configured() utils.check_param(version_str, 'version_str', 'string') - local version = mkversion.from_string(version_str) + local version = mkversion.fromstr(version_str) if fun.index(version_str, downgrade_versions) == nil then error("Downgrade is only possible to version listed in" .. " box.schema.downgrade_versions().") end - local schema_version_cur = mkversion.get() + local schema_version_cur = box.internal.dd_version() local app_version = tarantool.version:match('^%d+%.%d+%.%d+') - if schema_version_cur > mkversion.from_string(app_version) then + if schema_version_cur > mkversion.fromstr(app_version) then local err = "Cannot downgrade as current schema version %s is newer" .. " than Tarantool version %s" error(err:format(schema_version_cur, app_version)) @@ -2292,7 +2293,7 @@ local function bootstrap() -- insert initial schema initial_1_7_5() -- upgrade schema to the latest version - upgrade_from(mkversion(1, 7, 5)) + upgrade_from(mkversion.new(1, 7, 5)) end) reset_system_formats() diff --git a/src/box/lua/version.lua b/src/box/lua/version.lua new file mode 100644 index 000000000000..b45afe38feaf --- /dev/null +++ b/src/box/lua/version.lua @@ -0,0 +1,45 @@ +local version = require('version') +local bit = require('bit') +local ffi = require('ffi') + +ffi.cdef([[ + uint32_t box_dd_version_id(void); + uint32_t box_latest_dd_version_id(void); +]]) + +local builtin = ffi.C + +local function version_from_tuple(tuple) + local major, minor, patch = tuple:unpack(2, 4) + patch = patch or 0 + assert(type(major) == 'number') + assert(type(minor) == 'number') + return version.new(major, minor, patch) +end + +local function version_from_id(version_id) + local major = bit.band(bit.rshift(version_id, 16), 0xff) + local minor = bit.band(bit.rshift(version_id, 8), 0xff) + local patch = bit.band(version_id, 0xff) + return version.new(major, minor, patch) +end + +local function version_to_id(version) + local id = bit.bor(bit.lshift(version.major, 8), version.minor) + return bit.bor(bit.lshift(id, 8), version.patch) +end + +local function dd_version() + local version = builtin.box_dd_version_id() + return version_from_id(version) +end + +local function latest_dd_version() + local version = builtin.box_latest_dd_version_id() + return version_from_id(version) +end + +box.internal.version_from_tuple = version_from_tuple +box.internal.dd_version = dd_version +box.internal.latest_dd_version = latest_dd_version +box.internal.version_to_id = version_to_id diff --git a/test/box-luatest/downgrade_test.lua b/test/box-luatest/downgrade_test.lua index 7989e48b99a2..ade383ebc20a 100644 --- a/test/box-luatest/downgrade_test.lua +++ b/test/box-luatest/downgrade_test.lua @@ -40,17 +40,12 @@ g.test_downgrade_sanity_checks = function(cg) end local version = schema_version() - t.assert_error_msg_contains('version should be in format A.B.C', - box.schema.downgrade, 'xxx') + local msg = "Error during parsing version string" + t.assert_error_msg_contains(msg, box.schema.downgrade, 'xxx') t.assert_equals(schema_version(), version) - t.assert_error_msg_contains('version should be in format A.B.C', - box.schema.downgrade, '2') + t.assert_error_msg_contains(msg, box.schema.downgrade, '2') t.assert_equals(schema_version(), version) - t.assert_error_msg_contains('version should be in format A.B.C', - box.schema.downgrade, '2.2') - t.assert_equals(schema_version(), version) - t.assert_error_msg_contains('version should be in format A.B.C', - box.schema.downgrade, '2.2.2.2') + t.assert_error_msg_contains(msg, box.schema.downgrade, '2.2') t.assert_equals(schema_version(), version) t.assert_error_msg_contains( diff --git a/test/box-luatest/gh_10180_upgrade_from_1_6_9_test.lua b/test/box-luatest/gh_10180_upgrade_from_1_6_9_test.lua index 7f03030b0d33..a8752612a2cd 100644 --- a/test/box-luatest/gh_10180_upgrade_from_1_6_9_test.lua +++ b/test/box-luatest/gh_10180_upgrade_from_1_6_9_test.lua @@ -18,7 +18,7 @@ g.test_upgrade = function(cg) cg.server:exec(function() t.assert_equals(box.space._schema:get{'version'}, {'version', 1, 6, 8}) t.assert(pcall(box.schema.upgrade)) - local version = require('internal.mkversion').get() + local version = box.internal.dd_version() t.assert_equals(box.space._schema:get{'version'}, {'version', version.major, version.minor, version.patch}) end) diff --git a/test/box-luatest/upgrade_to_3_0_0_test.lua b/test/box-luatest/upgrade_to_3_0_0_test.lua index eae5ef34a000..62bbddb0f067 100644 --- a/test/box-luatest/upgrade_to_3_0_0_test.lua +++ b/test/box-luatest/upgrade_to_3_0_0_test.lua @@ -67,12 +67,12 @@ end -- g.test_dd_version_broadcast = function(cg) local function set_dd_version_watcher() - local mkversion = require('internal.mkversion') + local version = require('version') rawset(_G, 'watcher_counter', 0) rawset(_G, 'watcher_version', {}) rawset(_G, 'watcher', box.watch('box.status', function(_, status) t.assert_not_equals(status.dd_version, nil) - _G.watcher_version = mkversion.from_string(status.dd_version) + _G.watcher_version = version.fromstr(status.dd_version) _G.watcher_counter = _G.watcher_counter + 1 end)) end @@ -85,19 +85,17 @@ g.test_dd_version_broadcast = function(cg) cg.replica:exec(set_dd_version_watcher) cg.master:exec(function() - local mkversion = require('internal.mkversion') local old_counter = _G.watcher_counter box.schema.upgrade() t.helpers.retrying({}, function() t.assert_gt(_G.watcher_counter, old_counter) end) - t.assert_equals(_G.watcher_version, mkversion.get_latest()) + t.assert_equals(_G.watcher_version, box.internal.latest_dd_version()) end) cg.replica:wait_for_vclock_of(g.master) cg.replica:exec(function() - local mkversion = require('internal.mkversion') - t.assert_equals(_G.watcher_version, mkversion.get_latest()) + t.assert_equals(_G.watcher_version, box.internal.latest_dd_version()) end) cg.master:exec(clear_dd_version_watcher) diff --git a/test/config-luatest/upgrade_test.lua b/test/config-luatest/upgrade_test.lua index 7c8ce0f79be6..4931a0621163 100644 --- a/test/config-luatest/upgrade_test.lua +++ b/test/config-luatest/upgrade_test.lua @@ -83,7 +83,7 @@ end) g.test_upgrade = function() g.server:exec(function() local netbox = require("net.box") - local mkversion = require("internal.mkversion") + local version = require("version") local messages = {} for _, alert in pairs(require("config"):info().alerts) do @@ -102,7 +102,8 @@ g.test_upgrade = function() -- Checks the alerts for the outdated schema version. t.assert_items_include(messages, { msgs.credentials, - msgs.schema:format(mkversion(2, 11, 0), mkversion.get_latest()) + msgs.schema:format(version.new(2, 11, 0), + box.internal.latest_dd_version()) }) t.assert_equals(box.space._schema:get("version"), {'version', 2, 11, 0}) @@ -120,7 +121,8 @@ g.test_upgrade = function() table.insert(messages, alert.message) end t.assert_items_include(messages, { - msgs.schema:format(mkversion(2, 11, 1), mkversion.get_latest()) + msgs.schema:format(version.new(2, 11, 1), + box.internal.latest_dd_version()) }) local exp = { 'read', 'space', '_space' }