Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: fix schema log message #463

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/unit-luatest/storage_exports_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,15 @@ test_group.test_deploy_privs = function(g)
box.schema.role.drop('two')
end)
end

test_group.test_core_version = function(g)
g.server:exec(function()
local exports = _G.ivexports.log[#_G.ivexports.log]
exports = _G.ivexports.compile(exports)

local version = _TARANTOOL
local pos = version:find('-g')
version = version:sub(1, pos - 1)
ilt.assert_equals(exports.core_version, version)
end)
end
18 changes: 18 additions & 0 deletions test/unit-luatest/version_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ local lversion = require('vshard.version')

local g = t.group('version')

local function assert_version_str_equals(actual, expected)
-- Remove commit hash, if it exists. It's not saved in version.
local hash_pos = expected:find('-g')
if hash_pos then
expected = expected:sub(1, hash_pos - 1)
end
-- Remove trailing dash.
if expected:sub(-1) == '-' then
expected = expected:sub(1, -2)
end
-- Add 0 number of commits to expected.
if actual:sub(-2) == '-0' and not expected:find('-0') then
expected = expected .. '-0'
end
t.assert_equals(actual, expected)
end

g.test_order = function()
-- Example of a full version: 2.10.0-beta2-86-gc9981a567.
local versions = {
Expand Down Expand Up @@ -215,6 +232,7 @@ g.test_order = function()
t.assert(not (ver > v.ver), ('versions not >, %d'):format(i))
t.assert(ver <= v.ver, ('versions <=, %d'):format(i))
t.assert(ver >= v.ver, ('versions <=, %d'):format(i))
assert_version_str_equals(tostring(ver), v.str)
if i > 1 then
local prev = versions[i - 1].ver
t.assert(prev < ver, ('versions <, %d'):format(i))
Expand Down
2 changes: 1 addition & 1 deletion vshard/storage/exports.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ local function exports_compile(exports)
end
return {
vshard_version = exports.version,
core_version = table.concat(lvutil.core_version, '.'),
core_version = tostring(lvutil.core_version),
funcs = compiled_funcs,
}
end
Expand Down
11 changes: 11 additions & 0 deletions vshard/version.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ local version_mt = {
__le = function(l, r)
return version_cmp(l, r) <= 0
end,
__tostring = function(v)
local str = v.id_major .. '.' .. v.id_middle .. '.' .. v.id_minor
if v.rel_type then
str = str .. '-' .. v.rel_type
if v.rel_num ~= 0 then
str = str .. v.rel_num
end
end
str = str .. '-' .. v.id_commit
return str
end,
}

local function version_new(id_major, id_middle, id_minor, rel_type, rel_num,
Expand Down
Loading