Skip to content

Commit ab5bb50

Browse files
committed
test: support tarantool 1.6-2.4 in instance file
The compatibility layer for different tarantool versions was broken in several ways: * It did use 'string.split', which was added only in tarantool-1.7.3-666-ga6800388c. * It did not support 2.* versions and uses old options on, say, tarantool-2.4.0-82-gd8a9f1d9c (because assumes the major version as 1 and didn't check it). * 'slab_alloc_arena' value was passed in bytes rather than gigabytes.
1 parent 108855c commit ab5bb50

File tree

1 file changed

+51
-11
lines changed

1 file changed

+51
-11
lines changed

test/shared/box.lua

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,65 @@ local yaml = require('yaml')
1010
log.info(fio.cwd())
1111
log.info("admin: %s, primary: %s", os.getenv('ADMIN_PORT'), os.getenv('PRIMARY_PORT'))
1212

13-
local compat = {
14-
log = 'log',
15-
memtx_memory = 'memtx_memory',
16-
unsigned = 'unsigned',
17-
string = 'string',
18-
}
13+
-- {{{ Compatibility layer between different tarantool versions
14+
15+
local function parse_tarantool_version(component)
16+
local pattern = '^(%d+).(%d+).(%d+)-(%d+)-g[0-9a-f]+$'
17+
return tonumber((select(component, _TARANTOOL:match(pattern))))
18+
end
19+
20+
local _TARANTOOL_MAJOR = parse_tarantool_version(1)
21+
local _TARANTOOL_MINOR = parse_tarantool_version(2)
22+
local _TARANTOOL_PATCH = parse_tarantool_version(3)
23+
local _TARANTOOL_REV = parse_tarantool_version(4)
24+
25+
local function tarantool_version_at_least(major, minor, patch, rev)
26+
if _TARANTOOL_MAJOR < major then return false end
27+
if _TARANTOOL_MAJOR > major then return true end
28+
29+
if _TARANTOOL_MINOR < minor then return false end
30+
if _TARANTOOL_MINOR > minor then return true end
31+
32+
if _TARANTOOL_PATCH < patch then return false end
33+
if _TARANTOOL_PATCH > patch then return true end
1934

20-
if (tonumber(_TARANTOOL:split('-')[1]:split('.')[2]) < 7) then
21-
compat.log = 'logger'
35+
if _TARANTOOL_REV < rev then return false end
36+
if _TARANTOOL_REV > rev then return true end
37+
38+
return true
39+
end
40+
41+
local compat = {}
42+
43+
if tarantool_version_at_least(1, 7, 3, 351) then
44+
compat.log = 'log'
45+
compat.memtx_memory = 'memtx_memory'
46+
compat.memtx_memory_transform = function(v)
47+
return v
48+
end
49+
else
50+
compat.log = 'logger'
2251
compat.memtx_memory = 'slab_alloc_arena'
23-
compat.unsigned = 'NUM'
24-
compat.string = 'STR'
52+
compat.memtx_memory_transform = function(v)
53+
return v / 1024 ^ 3
54+
end
2555
end
2656

57+
if tarantool_version_at_least(1, 7, 1, 147) then
58+
compat.unsigned = 'unsigned'
59+
compat.string = 'string'
60+
else
61+
compat.unsigned = 'NUM'
62+
compat.string = 'STR'
63+
end
64+
65+
-- }}}
66+
2767
box.cfg{
2868
listen = os.getenv('PRIMARY_PORT'),
2969
log_level = 5,
3070
[compat.log] = 'tarantool.log',
31-
[compat.memtx_memory] = 400 * 1024 * 1024
71+
[compat.memtx_memory] = compat.memtx_memory_transform(400 * 1024 * 1024),
3272
}
3373

3474
box.once('initialization', function()

0 commit comments

Comments
 (0)