From: Olga Arkhangelskaia <arkholga@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH 1/2] lua: turn on lua 5.2 compatibility
Date: Thu, 7 Nov 2019 17:03:13 +0300 [thread overview]
Message-ID: <20191107140314.92871-2-arkholga@tarantool.org> (raw)
In-Reply-To: <20191107140314.92871-1-arkholga@tarantool.org>
Enabling features that might slightly break existing code (os.execute,
etc). Done via -DLUAJIT_ENABLE_LUA52COMPAT flag. Now we need to be more
attentive with returning values, methametods and etc.
---
cmake/luajit.cmake | 1 +
| 2 +-
test/app-tap/debug.test.lua | 4 +-
test/app-tap/tarantoolctl.test.lua | 80 ++---
test/box-tap/cfg.test.lua | 46 +--
test/wal_off/rtree_benchmark.result | 255 +++++++++-------
test/wal_off/rtree_benchmark.test.lua | 20 +-
test/wal_off/snapshot_stress.result | 415 ++++++++++++++------------
test/wal_off/snapshot_stress.test.lua | 4 +-
9 files changed, 450 insertions(+), 377 deletions(-)
diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake
index 10df633d5..3157c35ac 100644
--- a/cmake/luajit.cmake
+++ b/cmake/luajit.cmake
@@ -217,6 +217,7 @@ macro(luajit_build)
add_definitions(-DLUAJIT_USE_ASAN=1)
set (luajit_ldflags ${luajit_ldflags} -fsanitize=address)
endif()
+ add_definitions(-DLUAJIT_ENABLE_LUA52COMPAT=1)
add_definitions(-DLUAJIT_SMART_STRINGS=1)
# Add all COMPILE_DEFINITIONS to xcflags
get_property(defs DIRECTORY PROPERTY COMPILE_DEFINITIONS)
--git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 6daf866ac..e8c9ff164 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -309,7 +309,7 @@ local function under_systemd()
if not usermode then
local rv = os.execute("systemctl 2>/dev/null | grep '\\-\\.mount' " ..
"1>/dev/null 2>/dev/null")
- if rv == 0 then
+ if rv == true then
return true
end
end
diff --git a/test/app-tap/debug.test.lua b/test/app-tap/debug.test.lua
index 0d199e55b..eee932acc 100755
--- a/test/app-tap/debug.test.lua
+++ b/test/app-tap/debug.test.lua
@@ -61,7 +61,7 @@ for _, test in ipairs(tests) do
local cmd = string.format('%s -e "%s; os.exit(0)"', TNTBIN, test)
print('Exec: '..cmd)
io.flush()
- assert(os.execute(cmd) == 0, string.format('cmd: "%s" must execute successfully', cmd))
+ assert(os.execute(cmd) == true, string.format('cmd: "%s" must execute successfully', cmd))
end
local fio = require('fio')
@@ -87,7 +87,7 @@ for _, test in ipairs(tests) do
file:close()
print('Source: '..test)
io.flush()
- assert(os.execute(cmd) == 0, string.format('cmd: "%s" must execute successfully', cmd))
+ assert(os.execute(cmd) == true, string.format('cmd: "%s" must execute successfully', cmd))
end
os.remove(filename)
diff --git a/test/app-tap/tarantoolctl.test.lua b/test/app-tap/tarantoolctl.test.lua
index f38820805..ea780fe07 100755
--- a/test/app-tap/tarantoolctl.test.lua
+++ b/test/app-tap/tarantoolctl.test.lua
@@ -84,10 +84,10 @@ local function run_command(dir, command)
local fstderr = fio.pathjoin(dir, 'stderr-' .. suffix)
local line = [[/bin/sh -c 'cd "%s" && %s >"%s" 2>"%s"']]
line = line:format(dir, command, fstdout, fstderr)
- local res = os.execute(line)
+ local res, exit, status = os.execute(line)
local fstdout_e, fstderr_e = io.open(fstdout):read('*a'), io.open(fstderr):read('*a')
fio.unlink(fstdout); fio.unlink(fstderr);
- return res/256, fstdout_e, fstderr_e
+ return res, status, fstdout_e, fstderr_e
end
local function tctl_wait_start(dir, name)
@@ -133,13 +133,19 @@ local function tctl_command(dir, cmd, args, name)
return run_command(dir, command)
end
-local function check_ok(test, dir, cmd, args, e_res, e_stdout, e_stderr)
- local res, stdout, stderr = tctl_command(dir, cmd, args)
+local FAIL = nil
+local SUCCESS = true
+
+local function check_ok(test, dir, cmd, args, e_res, e_status, e_stdout, e_stderr)
+ local res, status, stdout, stderr = tctl_command(dir, cmd, args)
stdout, stderr = stdout or '', stderr or ''
local ares = true
if (e_res ~= nil) then
local val = test:is(res, e_res, ("check '%s' command status for '%s'"):format(cmd,args))
ares = ares and val
+ else
+ local val = test:is(status, e_status, ("check '%s' command status for '%s'"):format(cmd,args))
+ ares = ares and val
end
if e_stdout ~= nil then
local val = test:is(res, e_res, ("check '%s' stdout for '%s'"):format(cmd,args))
@@ -190,17 +196,17 @@ do
local status, err = pcall(function()
test:test("basic test", function(test_i)
test_i:plan(18)
- check_ok(test_i, dir, 'start', 'delayed_box_cfg', 0, nil, "Starting instance")
- check_ok(test_i, dir, 'start', 'script', 0, nil, "Starting instance")
+ check_ok(test_i, dir, 'start', 'delayed_box_cfg', SUCCESS, 0, nil, "Starting instance")
+ check_ok(test_i, dir, 'start', 'script', SUCCESS, 0, nil, "Starting instance")
tctl_wait_start(dir, 'script')
- check_ok(test_i, dir, 'status', 'script', 0, nil, "is running")
- check_ok(test_i, dir, 'start', 'script', 1, nil, "is already running")
- check_ok(test_i, dir, 'status', 'script', 0, nil, "is running")
- check_ok(test_i, dir, 'stop', 'script', 0, nil, "Stopping")
+ check_ok(test_i, dir, 'status', 'script', SUCCESS, 0, nil, "is running")
+ check_ok(test_i, dir, 'start', 'script', FAIL, 1, nil, "is already running")
+ check_ok(test_i, dir, 'status', 'script', SUCCESS, 0, nil, "is running")
+ check_ok(test_i, dir, 'stop', 'script', SUCCESS, 0, nil, "Stopping")
tctl_wait_stop(dir, 'script')
- check_ok(test_i, dir, 'status', 'script', 1, nil, "is stopped")
- check_ok(test_i, dir, 'stop', 'script', 0, nil, "is not running")
- check_ok(test_i, dir, 'status', 'script', 1, nil, "is stopped" )
+ check_ok(test_i, dir, 'status', 'script', FAIL, 1, nil, "is stopped")
+ check_ok(test_i, dir, 'stop', 'script', SUCCESS, 0, nil, "is not running")
+ check_ok(test_i, dir, 'status', 'script', FAIL, 1, nil, "is stopped" )
end)
end)
@@ -225,16 +231,16 @@ do
local status, err = pcall(function()
test:test("basic test for bad script", function(test_i)
test_i:plan(7)
- check_ok(test_i, dir, 'start', 'script', 1, nil,
+ check_ok(test_i, dir, 'start', 'script', FAIL, 1, nil,
'Instance script is not found')
- check_ok(test_i, dir, 'start', 'bad_script', 1, nil,
+ check_ok(test_i, dir, 'start', 'bad_script', FAIL,1, nil,
'unexpected symbol near')
- check_ok(test_i, dir, 'start', 'good_script', 0)
+ check_ok(test_i, dir, 'start', 'good_script', SUCCESS, 0)
tctl_wait_start(dir, 'good_script')
-- wait here
- check_ok(test_i, dir, 'eval', 'good_script bad_script.lua', 3,
+ check_ok(test_i, dir, 'eval', 'good_script bad_script.lua', FAIL, 3,
nil, nil)
- check_ok(test_i, dir, 'stop', 'good_script', 0)
+ check_ok(test_i, dir, 'stop', 'good_script', SUCCESS, 0)
end)
end)
@@ -261,13 +267,13 @@ do
local status, err = pcall(function()
test:test("check answers in case of call", function(test_i)
test_i:plan(5)
- check_ok(test_i, dir, 'start', 'good_script', 0)
+ check_ok(test_i, dir, 'start', 'good_script', SUCCESS, 0)
tctl_wait_start(dir, 'good_script')
- check_ok(test_i, dir, 'eval', 'good_script bad_script.lua', 3,
+ check_ok(test_i, dir, 'eval', 'good_script bad_script.lua', FAIL, 3,
nil, nil)
- check_ok(test_i, dir, 'eval', 'good_script ok_script.lua', 0,
+ check_ok(test_i, dir, 'eval', 'good_script ok_script.lua', SUCCESS, 0,
'---\n- 1\n...', nil)
- check_ok(test_i, dir, 'stop', 'good_script', 0)
+ check_ok(test_i, dir, 'stop', 'good_script', SUCCESS, 0)
end)
end)
@@ -290,21 +296,21 @@ do
local status, err = pcall(function()
test:test("check error codes in case of enter", function(test_i)
test_i:plan(10)
- check_ok(test_i, dir, 'enter', 'script', 1, nil, "Can't connect to")
+ check_ok(test_i, dir, 'enter', 'script', FAIL, 1, nil, "Can't connect to")
local console_sock = 'script.control'
console_sock = fio.pathjoin(dir, console_sock)
test_i:is(fio.path.exists(console_sock), false, "directory clean")
- check_ok(test_i, dir, 'start', 'script', 0)
+ check_ok(test_i, dir, 'start', 'script', SUCCESS, 0)
tctl_wait_start(dir, 'script')
test_i:is(fio.path.exists(console_sock), true,
"unix socket created")
- check_ok(test_i, dir, 'stop', 'script', 0)
+ check_ok(test_i, dir, 'stop', 'script', SUCCESS, 0)
tctl_wait_stop(dir, 'script')
test_i:is(fio.path.exists(console_sock), false,
"remove unix socket upon exit")
fio.open(console_sock, 'O_CREAT')
test_i:is(fio.path.exists(console_sock), true, "file created")
- check_ok(test_i, dir, 'enter', 'script', 1, nil, "Can't connect to")
+ check_ok(test_i, dir, 'enter', 'script', FAIL, 1, nil, "Can't connect to")
fio.unlink(console_sock)
end)
end)
@@ -325,7 +331,7 @@ do
local function test_help(test, dir, cmd, e_stderr)
local desc = dir and 'with config' or 'without config'
dir = dir or './'
- local res, stdout, stderr = run_command(dir, cmd)
+ local res, status, stdout, stderr = run_command(dir, cmd)
if e_stderr ~= nil then
if not test:ok(stderr:find(e_stderr), ("check stderr of '%s' %s"):format(cmd, desc)) then
print(("Expected to find '%s' in '%s'"):format(e_stderr, stderr))
@@ -380,8 +386,8 @@ do
local command_base = 'tarantoolctl cat filler/00000000000000000000.xlog'
local desc = args and "cat + " .. args or "cat"
args = args and " " .. args or ""
- local res, stdout, stderr = run_command(dir, command_base .. args)
- test:is(res, 0, desc .. " result")
+ local res, status, stdout, stderr = run_command(dir, command_base .. args)
+ test:is(res, SUCCESS, desc .. " result")
test:is(select(2, stdout:gsub(delim, delim)), lc, desc .. " line count")
end
@@ -389,15 +395,15 @@ do
local command_base = 'tarantoolctl cat filler/00000000000000000000.snap'
local desc = args and "cat + " .. args or "cat"
args = args and " " .. args or ""
- local res, stdout, stderr = run_command(dir, command_base .. args)
- test:is(res, 0, desc .. " result")
+ local res, status, stdout, stderr = run_command(dir, command_base .. args)
+ test:is(res, SUCCESS, desc .. " result")
test:is(select(2, stdout:gsub(delim, delim)), lc, desc .. " line count")
end
local status, err = pcall(function()
test:test("fill and test cat output", function(test_i)
test_i:plan(29)
- check_ok(test_i, dir, 'start', 'filler', 0)
+ check_ok(test_i, dir, 'start', 'filler', SUCCESS, 0)
check_ctlcat_xlog(test_i, dir, nil, "---\n", 7)
check_ctlcat_xlog(test_i, dir, "--space=512", "---\n", 6)
check_ctlcat_xlog(test_i, dir, "--space=666", "---\n", 0)
@@ -470,14 +476,14 @@ else
local status, err = pcall(function()
test:test("fill and test play output", function(test_i)
test_i:plan(6)
- check_ok(test_i, dir, 'start', 'filler', 0)
+ check_ok(test_i, dir, 'start', 'filler', SUCCESS, 0)
local lsn_before = test_run:get_lsn("remote", 1)
test_i:is(lsn_before, 4, "check lsn before")
- local res, stdout, stderr = run_command(dir, command_base)
- test_i:is(res, 0, "execution result")
+ local res, status, stdout, stderr = run_command(dir, command_base)
+ test_i:is(res, SUCCESS, "execution result")
test_i:is(test_run:get_lsn("remote", 1), 10, "check lsn after")
- local res, stdout, stderr = run_command(dir, command_base)
- test_i:is(res, 0, "execution result")
+ local res, status, stdout, stderr = run_command(dir, command_base)
+ test_i:is(res, SUCCESS, "execution result")
test_i:is(test_run:get_lsn("remote", 1), 16, "check lsn after")
end)
end)
diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
index d529447bb..b61073438 100755
--- a/test/box-tap/cfg.test.lua
+++ b/test/box-tap/cfg.test.lua
@@ -162,7 +162,7 @@ box.cfg({ worker_pool_threads = 1})
test:is(box.cfg.worker_pool_threads, 1, 'worker_pool_threads')
local tarantool_bin = arg[-1]
-local PANIC = 256
+local PANIC = nil
function run_script(code)
local dir = fio.tempdir()
local script_path = fio.pathjoin(dir, 'script.lua')
@@ -182,14 +182,14 @@ code =[[
box.cfg{vinyl_memory=0}
os.exit(box.cfg.vinyl_memory == 0 and 0 or 1)
]]
-test:is(run_script(code), 0, "actually set vinyl_memory to 0")
+test:is(run_script(code), true, "actually set vinyl_memory to 0")
-- gh-715: Cannot switch to/from 'fsync'
code = [[ box.cfg{ log="tarantool.log", log_nonblock = false, wal_mode = 'fsync' }; ]]
-test:is(run_script(code), 0, 'wal_mode fsync')
+test:is(run_script(code), true, 'wal_mode fsync')
code = [[ box.cfg{ wal_mode = 'fsync' }; box.cfg { wal_mode = 'fsync' }; ]]
-test:is(run_script(code), 0, 'wal_mode fsync -> fsync')
+test:is(run_script(code), true, 'wal_mode fsync -> fsync')
code = [[ box.cfg{ wal_mode = 'fsync' }; box.cfg { wal_mode = 'none'} ]]
test:is(run_script(code), PANIC, 'wal_mode fsync -> write is not supported')
@@ -204,7 +204,7 @@ test:is(run_script(code), PANIC, 'work_dir is invalid')
-- gh-2664: vinyl_dir is checked on the first use
code = [[ box.cfg{ vinyl_dir='invalid' } ]]
-test:is(run_script(code), 0, 'vinyl_dir is invalid')
+test:is(run_script(code), true, 'vinyl_dir is invalid')
code = [[ box.cfg{ memtx_dir='invalid' } ]]
test:is(run_script(code), PANIC, 'snap_dir is invalid')
@@ -217,7 +217,7 @@ code = [[
box.cfg{log_nonblock = false }
os.exit(box.cfg.log_nonblock == false and 0 or 1)
]]
-test:is(run_script(code), 0, "log_nonblock new value")
+test:is(run_script(code), true, "log_nonblock new value")
-- gh-3048: box.cfg must not crash on invalid log configuration
code = [[ box.cfg{ log = '/' } ]]
@@ -265,7 +265,7 @@ local conn = require('net.box').connect('unix/:./tarantool.sock',
if not conn:ping() then os.exit(1) end
os.exit(0)
]]
-test:is(run_script(code), 0, "wal_mode none and ER_LOADING")
+test:is(run_script(code), true, "wal_mode none and ER_LOADING")
--
-- gh-1962: incorrect replication source
@@ -286,13 +286,13 @@ code = [[
box.cfg{vinyl_page_size = 1 * 1024 * 1024, vinyl_range_size = 2 * 1024 * 1024}
os.exit(0)
]]
-test:is(run_script(code), 0, "page size less than range")
+test:is(run_script(code), true, "page size less than range")
code = [[
box.cfg{vinyl_page_size = 2 * 1024 * 1024, vinyl_range_size = 2 * 1024 * 1024}
os.exit(0)
]]
-test:is(run_script(code), 0, "page size equal with range")
+test:is(run_script(code), true, "page size equal with range")
-- test memtx options upgrade
code = [[
@@ -303,7 +303,7 @@ os.exit(box.cfg.memtx_memory == 214748364
and box.cfg.memtx_max_tuple_size == 64 * 1024
and 0 or 1)
]]
-test:is(run_script(code), 0, "upgrade memtx memory options")
+test:is(run_script(code), true, "upgrade memtx memory options")
code = [[
box.cfg{slab_alloc_arena = 0.2, slab_alloc_minimal = 16, slab_alloc_maximal = 64 * 1024,
@@ -311,7 +311,7 @@ box.cfg{slab_alloc_arena = 0.2, slab_alloc_minimal = 16, slab_alloc_maximal = 64
memtx_max_tuple_size = 64 * 1024}
os.exit(0)
]]
-test:is(run_script(code), 0, "equal new and old memtx options")
+test:is(run_script(code), true, "equal new and old memtx options")
code = [[
box.cfg{slab_alloc_arena = 0.2, slab_alloc_minimal = 16, slab_alloc_maximal = 64 * 1024,
@@ -339,20 +339,20 @@ code = [[
box.cfg{panic_on_wal_error = true}
os.exit(box.cfg.force_recovery == false and 0 or 1)
]]
-test:is(run_script(code), 0, "panic_on_wal_error")
+test:is(run_script(code), true, "panic_on_wal_error")
code = [[
box.cfg{panic_on_snap_error = false}
os.exit(box.cfg.force_recovery == true and 0 or 1)
]]
-test:is(run_script(code), 0, "panic_on_snap_error")
+test:is(run_script(code), true, "panic_on_snap_error")
code = [[
box.cfg{snapshot_period = 100, snapshot_count = 4}
os.exit(box.cfg.checkpoint_interval == 100
and box.cfg.checkpoint_count == 4 and 0 or 1)
]]
-test:is(run_script(code), 0, "setup checkpoint params")
+test:is(run_script(code), true, "setup checkpoint params")
code = [[
box.cfg{snapshot_period = 100, snapshot_count = 4}
@@ -360,7 +360,7 @@ box.cfg{snapshot_period = 150, snapshot_count = 8}
os.exit(box.cfg.checkpoint_interval == 150
and box.cfg.checkpoint_count == 8 and 0 or 1)
]]
-test:is(run_script(code), 0, "update checkpoint params")
+test:is(run_script(code), true, "update checkpoint params")
--
-- test wal_max_size option
@@ -378,7 +378,7 @@ end
cnt2 = #fio.glob(fio.pathjoin(box.cfg.wal_dir, '*.xlog'))
os.exit(cnt1 < cnt2 - 8 and 0 or 1)
]]
-test:is(run_script(code), 0, "wal_max_size xlog rotation")
+test:is(run_script(code), true, "wal_max_size xlog rotation")
--
-- gh-2872 bootstrap is aborted if vinyl_dir contains vylog files
@@ -422,7 +422,7 @@ ok = ok and not pcall(s.insert, s, {1})
ok = ok and pcall(s.select, s)
os.exit(ok and 0 or 1)
]], cfg)
-test:is(run_script(code), 0, "wal_mode none -> vinyl DDL/DML is not supported")
+test:is(run_script(code), true, "wal_mode none -> vinyl DDL/DML is not supported")
fio.rmtree(dir)
--
@@ -441,13 +441,13 @@ instance_uuid = tostring(require('uuid').new())
box.cfg{instance_uuid = instance_uuid}
os.exit(instance_uuid == box.info.uuid and 0 or 1)
]]
-test:is(run_script(code), 0, "check instance_uuid")
+test:is(run_script(code), true, "check instance_uuid")
code = [[
replicaset_uuid = tostring(require('uuid').new())
box.cfg{replicaset_uuid = replicaset_uuid}
os.exit(replicaset_uuid == box.info.cluster.uuid and 0 or 1)
]]
-test:is(run_script(code), 0, "check replicaset_uuid")
+test:is(run_script(code), true, "check replicaset_uuid")
--
-- Configuration fails on instance or replica set UUID mismatch.
@@ -498,7 +498,7 @@ unix_socket:close()
os.remove(path)
os.exit(res)
]]
-test:is(run_script(code), 0, "unix socket syslog log configuration")
+test:is(run_script(code), true, "unix socket syslog log configuration")
--
-- Check syslog remote configuration
@@ -540,7 +540,7 @@ end
sc:close()
os.exit(res)
]]
-test:is(run_script(code), 0, "remote syslog log configuration")
+test:is(run_script(code), true, "remote syslog log configuration")
--
-- gh-3615: check that log_nonblock is not lost
@@ -563,7 +563,7 @@ unix_socket:close()
os.remove(path)
os.exit(0)
]]
-test:is(run_script(code), 0, "log_nonblock")
+test:is(run_script(code), true, "log_nonblock")
--
-- Crash (instead of panic) when trying to recover a huge tuple.
@@ -580,7 +580,7 @@ code2 = string.format([[
box.cfg{wal_dir = '%s', memtx_dir = '%s', memtx_max_tuple_size = 10 * 1024}
os.exit(0)
]], dir, dir)
-test:is(run_script(code1), 0, "create huge tuple")
+test:is(run_script(code1), true, "create huge tuple")
test:is(run_script(code2), PANIC, "panic on huge tuple recovery")
fio.rmtree(dir)
diff --git a/test/wal_off/rtree_benchmark.result b/test/wal_off/rtree_benchmark.result
index 8e01c9f2a..bdcf98b5d 100644
--- a/test/wal_off/rtree_benchmark.result
+++ b/test/wal_off/rtree_benchmark.result
@@ -1,59 +1,67 @@
+-- test-run result file version 2
n_records = 10000
----
-...
+ | ---
+ | ...
n_iterations = 10000
----
-...
+ | ---
+ | ...
n_neighbors = 10
----
-...
+ | ---
+ | ...
env = require('test_run')
----
-...
+ | ---
+ | ...
test_run = env.new()
----
-...
+ | ---
+ | ...
+
file = io.open("rtree_benchmark.res", "w")
----
-...
+ | ---
+ | ...
+
s = box.schema.space.create('rtreebench')
----
-...
+ | ---
+ | ...
_ = s:create_index('primary')
----
-...
+ | ---
+ | ...
_ = s:create_index('spatial', { type = 'rtree', unique = false, parts = {2, 'array'}})
----
-...
-file:write(" *** 2D *** \n")
----
-- true
-...
+ | ---
+ | ...
+
+file:write(" *** 2D *** \n") ~= nil;
+ | ---
+ | - true
+ | ...
rect_width = 180 / math.pow(n_records, 1 / 2)
----
-...
+ | ---
+ | ...
+
start = os.time()
----
-...
+ | ---
+ | ...
+
test_run:cmd("setopt delimiter ';'")
----
-- true
-...
+ | ---
+ | - true
+ | ...
for i = 1, n_records do
s:insert{i,{180*math.random(),180*math.random()}}
end;
----
-...
-file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+
+file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
n = 0;
----
-...
+ | ---
+ | ...
for i = 1, n_iterations do
x = (180 - rect_width) * math.random()
y = (180 - rect_width) * math.random()
@@ -61,15 +69,16 @@ for i = 1, n_iterations do
n = n + 1
end
end;
----
-...
-file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
n = 0
for i = 1, n_iterations do
x = 180 * math.random()
@@ -78,45 +87,54 @@ for i = 1, n_iterations do
n = n + 1
end
end;
----
-...
-file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
for i = 1, n_records do
s:delete{i}
end;
----
-...
-file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
s:drop();
----
-...
+ | ---
+ | ...
+
dimension = 8;
----
-...
+ | ---
+ | ...
+
s = box.schema.space.create('rtreebench');
----
-...
+ | ---
+ | ...
_ = s:create_index('primary');
----
-...
+ | ---
+ | ...
_ = s:create_index('spatial', { type = 'rtree', unique = false, parts = {2, 'array'}, dimension = dimension});
----
-...
-file:write(" *** 8D *** \n")
+ | ---
+ | ...
+
+file:write(" *** 8D *** \n") ~= nil;
+ | ---
+ | - true
+ | ...
rect_width = 180 / math.pow(n_records, 1 / dimension)
start = os.time();
----
-...
+ | ---
+ | ...
+
for i = 1, n_records do
local record = {}
for j = 1, dimension do
@@ -124,18 +142,20 @@ for i = 1, n_records do
end
s:insert{i,record}
end;
----
-...
-file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+
+file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
n = 0;
----
-...
+ | ---
+ | ...
for i = 1, n_iterations do
local rect = {}
for j = 1, dimension do
@@ -148,15 +168,16 @@ for i = 1, n_iterations do
n = n + 1
end
end;
----
-...
-file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
n = 0
for i = 1, 0 do
local rect = {}
@@ -167,32 +188,38 @@ for i = 1, 0 do
n = n + 1
end
end;
----
-...
-file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
start = os.time();
----
-...
+ | ---
+ | ...
for i = 1, n_records do
s:delete{i}
end;
----
-...
-file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start));
----
-- true
-...
+ | ---
+ | ...
+file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start)) ~= nil;
+ | ---
+ | - true
+ | ...
+
s:drop();
----
-...
+ | ---
+ | ...
+
file:close();
----
-- true
-...
+ | ---
+ | - true
+ | ...
+
test_run:cmd("setopt delimiter ''");
----
-- true
-...
+ | ---
+ | - true
+ | ...
+
+
diff --git a/test/wal_off/rtree_benchmark.test.lua b/test/wal_off/rtree_benchmark.test.lua
index 6fae977c9..aa58624d1 100644
--- a/test/wal_off/rtree_benchmark.test.lua
+++ b/test/wal_off/rtree_benchmark.test.lua
@@ -10,7 +10,7 @@ s = box.schema.space.create('rtreebench')
_ = s:create_index('primary')
_ = s:create_index('spatial', { type = 'rtree', unique = false, parts = {2, 'array'}})
-file:write(" *** 2D *** \n")
+file:write(" *** 2D *** \n") ~= nil;
rect_width = 180 / math.pow(n_records, 1 / 2)
start = os.time()
@@ -20,7 +20,7 @@ for i = 1, n_records do
s:insert{i,{180*math.random(),180*math.random()}}
end;
-file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start));
+file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start)) ~= nil;
start = os.time();
n = 0;
@@ -31,7 +31,7 @@ for i = 1, n_iterations do
n = n + 1
end
end;
-file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start));
+file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start)) ~= nil;
start = os.time();
n = 0
@@ -42,13 +42,13 @@ for i = 1, n_iterations do
n = n + 1
end
end;
-file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start));
+file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start)) ~= nil;
start = os.time();
for i = 1, n_records do
s:delete{i}
end;
-file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start));
+file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start)) ~= nil;
s:drop();
@@ -58,7 +58,7 @@ s = box.schema.space.create('rtreebench');
_ = s:create_index('primary');
_ = s:create_index('spatial', { type = 'rtree', unique = false, parts = {2, 'array'}, dimension = dimension});
-file:write(" *** 8D *** \n")
+file:write(" *** 8D *** \n") ~= nil;
rect_width = 180 / math.pow(n_records, 1 / dimension)
start = os.time();
@@ -71,7 +71,7 @@ for i = 1, n_records do
s:insert{i,record}
end;
-file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start));
+file:write(string.format("Elapsed time for inserting %d records: %d\n", n_records, os.time() - start)) ~= nil;
start = os.time();
n = 0;
@@ -87,7 +87,7 @@ for i = 1, n_iterations do
n = n + 1
end
end;
-file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start));
+file:write(string.format("Elapsed time for %d belongs searches selecting %d records: %d\n", n_iterations, n, os.time() - start)) ~= nil;
start = os.time();
n = 0
@@ -100,13 +100,13 @@ for i = 1, 0 do
n = n + 1
end
end;
-file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start));
+file:write(string.format("Elapsed time for %d nearest %d neighbors searches selecting %d records: %d\n", n_iterations, n_neighbors, n, os.time() - start)) ~= nil;
start = os.time();
for i = 1, n_records do
s:delete{i}
end;
-file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start));
+file:write(string.format("Elapsed time for deleting %d records: %d\n", n_records, os.time() - start)) ~= nil;
s:drop();
diff --git a/test/wal_off/snapshot_stress.result b/test/wal_off/snapshot_stress.result
index 29cea8c04..f9f17441d 100644
--- a/test/wal_off/snapshot_stress.result
+++ b/test/wal_off/snapshot_stress.result
@@ -1,174 +1,186 @@
+-- test-run result file version 2
-- The test emulates account system. There are increasing number or accounts
-- and a lot of double entry transactions are made that moving random
-- ammount from random account to another random accont.
-- Snapshots are made every snapshot_interval seconds and then checked for consistency
env = require('test_run')
----
-...
+ | ---
+ | ...
test_run = env.new()
----
-...
+ | ---
+ | ...
-- Settings: You may increase theese value to make test longer
-- number of worker fibers:
workers_count = 80
----
-...
+ | ---
+ | ...
-- number of iterations per fiber (operations + add new account + add space)
iteration_count = 8
----
-...
+ | ---
+ | ...
-- number of operations per iterations
operation_count = 8
----
-...
+ | ---
+ | ...
-- limit of random string length in every account
string_max_size = 128
----
-...
+ | ---
+ | ...
-- initial number of accounts
accounts_start = 5
----
-...
+ | ---
+ | ...
-- delay between snapshots
snapshot_interval = 0.005
----
-...
+ | ---
+ | ...
+
fiber = require('fiber')
----
-...
+ | ---
+ | ...
fio = require('fio')
----
-...
+ | ---
+ | ...
log = require('log')
----
-...
+ | ---
+ | ...
+
tarantool_bin_path = arg[-1]
----
-...
+ | ---
+ | ...
work_dir = fio.cwd()
----
-...
+ | ---
+ | ...
script_path = fio.pathjoin(work_dir, 'snap_script.lua')
----
-...
+ | ---
+ | ...
cmd_template = [[/bin/sh -c 'cd "%s" && "%s" ./snap_script.lua 2> /dev/null']]
----
-...
+ | ---
+ | ...
cmd = string.format(cmd_template, work_dir, tarantool_bin_path)
----
-...
+ | ---
+ | ...
+
open_flags = {'O_CREAT', 'O_WRONLY', 'O_TRUNC'}
----
-...
+ | ---
+ | ...
script = fio.open(script_path, open_flags, tonumber('0777', 8))
----
-...
+ | ---
+ | ...
script:write("os.exit(-1)")
----
-- true
-...
+ | ---
+ | - true
+ | ...
script:close()
----
-- true
-...
+ | ---
+ | - true
+ | ...
res = os.execute(cmd)
----
-...
+ | ---
+ | ...
str_res = 'precheck ' .. (res ~= 0 and ' ok(1)' or 'failed(1)')
----
-...
+ | ---
+ | ...
str_res
----
-- precheck ok(1)
-...
+ | ---
+ | - precheck ok(1)
+ | ...
+
script = fio.open(script_path, open_flags, tonumber('0777', 8))
----
-...
+ | ---
+ | ...
script:write("os.exit(0)")
----
-- true
-...
+ | ---
+ | - true
+ | ...
script:close()
----
-- true
-...
+ | ---
+ | - true
+ | ...
res = os.execute(cmd)
----
-...
-str_res = 'precheck ' .. (res == 0 and ' ok(2)' or 'failed(2)')
----
-...
+ | ---
+ | ...
+str_res = 'precheck ' .. (res == true and ' ok(2)' or 'failed(2)')
+ | ---
+ | ...
str_res
----
-- precheck ok(2)
-...
+ | ---
+ | - precheck ok(2)
+ | ...
+
snap_search_wildcard = fio.pathjoin(box.cfg.memtx_dir, '*.snap');
----
-...
+ | ---
+ | ...
snaps = fio.glob(snap_search_wildcard);
----
-...
+ | ---
+ | ...
initial_snap_count = #snaps
----
-...
+ | ---
+ | ...
+
if box.space.accounts then box.space.accounts:drop() end
----
-...
+ | ---
+ | ...
if box.space.operations then box.space.operations:drop() end
----
-...
+ | ---
+ | ...
if box.space.deleting then box.space.deleting:drop() end
----
-...
+ | ---
+ | ...
+
s1 = box.schema.create_space("accounts")
----
-...
+ | ---
+ | ...
i1 = s1:create_index('primary', { type = 'HASH', parts = {1, 'unsigned'} })
----
-...
+ | ---
+ | ...
s2 = box.schema.create_space("operations")
----
-...
+ | ---
+ | ...
i2 = s2:create_index('primary', { type = 'HASH', parts = {1, 'unsigned'} })
----
-...
+ | ---
+ | ...
s3 = box.schema.create_space("deleting")
----
-...
+ | ---
+ | ...
i3 = s3:create_index('primary', { type = 'TREE', parts = {1, 'unsigned'} })
----
-...
+ | ---
+ | ...
+
n_accs = 0
----
-...
+ | ---
+ | ...
n_ops = 0
----
-...
+ | ---
+ | ...
n_spaces = 0
----
-...
+ | ---
+ | ...
workers_done = 0
----
-...
+ | ---
+ | ...
+
test_run:cmd("setopt delimiter ';'")
----
-- true
-...
+ | ---
+ | - true
+ | ...
garbage = {};
----
-...
+ | ---
+ | ...
str = ""
for i = 1,string_max_size do
str = str .. '-' garbage[i - 1] = str
end;
----
-...
+ | ---
+ | ...
+
function get_new_space_name()
n_spaces = n_spaces + 1
return "test" .. tostring(n_spaces - 1)
end;
----
-...
+ | ---
+ | ...
+
tmp = get_new_space_name()
if box.space[tmp] then box.space[tmp]:drop() tmp = get_new_space_name() end
tmp = nil
@@ -177,45 +189,53 @@ n_spaces = 0
function get_rnd_acc()
return math.floor(math.random() * n_accs)
end;
----
-...
+ | ---
+ | ...
+
function get_rnd_val()
return math.floor(math.random() * 10)
end;
----
-...
+ | ---
+ | ...
+
function get_rnd_str()
return garbage[math.floor(math.random() * string_max_size)]
end;
----
-...
+ | ---
+ | ...
+
additional_spaces = { };
----
-...
+ | ---
+ | ...
+
function add_space()
local tmp_space = box.schema.create_space(get_new_space_name())
table.insert(additional_spaces, tmp_space)
tmp_space:create_index('test')
n_spaces = n_spaces + 1
end;
----
-...
+ | ---
+ | ...
+
function add_acc()
s1:insert{n_accs, 0} n_accs = n_accs + 1
end;
----
-...
+ | ---
+ | ...
+
function add_op(n1, n2, v)
s2:insert{n_ops, n1, n2, v}
n_ops = n_ops + 1
end;
----
-...
+ | ---
+ | ...
+
function acc_add(n, v)
s1:update({n}, {{'+', 2, v}, {'=', 3, get_rnd_str()}})
end;
----
-...
+ | ---
+ | ...
+
function do_op(n1, n2, v)
box.begin()
add_op(n1, n2, v)
@@ -223,18 +243,21 @@ function do_op(n1, n2, v)
acc_add(n2, -v)
box.commit()
end;
----
-...
+ | ---
+ | ...
+
function do_rand_op()
do_op(get_rnd_acc(), get_rnd_acc(), get_rnd_val())
end;
----
-...
+ | ---
+ | ...
+
function remove_smth()
s3:delete{i3:min()[1]}
end;
----
-...
+ | ---
+ | ...
+
function init()
for i = 1,accounts_start do
add_acc()
@@ -243,8 +266,9 @@ function init()
s3:auto_increment{"I hate dentists!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}
end
end;
----
-...
+ | ---
+ | ...
+
function work_itr()
for j = 1,operation_count do
do_rand_op()
@@ -254,8 +278,9 @@ function work_itr()
remove_smth()
add_space()
end;
----
-...
+ | ---
+ | ...
+
function work()
for i = 1,iteration_count do
if not pcall(work_itr) then
@@ -265,11 +290,12 @@ function work()
end
workers_done = workers_done + 1
end;
----
-...
+ | ---
+ | ...
+
snaps_done = false;
----
-...
+ | ---
+ | ...
function snaps()
while (workers_done ~= workers_count) do
pcall(box.snapshot)
@@ -277,55 +303,63 @@ function snaps()
end
snaps_done = true
end;
----
-...
+ | ---
+ | ...
+
function wait()
while (not snaps_done) do
fiber.sleep(0.01)
end
end;
----
-...
+ | ---
+ | ...
+
init();
----
-...
+ | ---
+ | ...
+
log.info('Part I: creating snapshot start');
----
-...
+ | ---
+ | ...
+
for i = 1,workers_count do
fiber.create(work)
end;
----
-...
+ | ---
+ | ...
local tmp_fib = fiber.create(snaps);
----
-...
+ | ---
+ | ...
wait();
----
-...
+ | ---
+ | ...
+
log.info('Part I: creating snapshot done');
----
-...
+ | ---
+ | ...
+
#s1:select{};
----
-- 645
-...
+ | ---
+ | - 645
+ | ...
#s2:select{};
----
-- 5120
-...
+ | ---
+ | - 5120
+ | ...
+
s1:drop();
----
-...
+ | ---
+ | ...
s2:drop();
----
-...
+ | ---
+ | ...
for k,v in pairs(additional_spaces) do v:drop() end;
----
-...
+ | ---
+ | ...
s1 = nil s2 = nil additional_spaces = nil;
----
-...
+ | ---
+ | ...
+
script_code = [[
fio = require'fio'
new_snap_dir = "]] .. fio.pathjoin(box.cfg.memtx_dir, "snap_test") .. [["
@@ -358,28 +392,29 @@ log.info('success: snapshot is ok')
os.execute("rm -r " .. new_snap_dir)
os.exit(0)
]];
----
-...
+ | ---
+ | ...
script = fio.open(script_path, open_flags, tonumber('0777', 8))
script:write(script_code)
script:close()
log.info('Part II: checking snapshot start');
----
-...
+ | ---
+ | ...
+
snaps = fio.glob(snap_search_wildcard);
----
-...
+ | ---
+ | ...
snaps_find_status = #snaps <= initial_snap_count and 'where are my snapshots?' or 'snaps found';
----
-...
+ | ---
+ | ...
snaps_find_status;
----
-- snaps found
-...
+ | ---
+ | - snaps found
+ | ...
snapshot_check_failed = false
while #snaps > initial_snap_count do
- if not snapshot_check_failed and os.execute(cmd) ~= 0 then
+ if not snapshot_check_failed and os.execute(cmd) == nil then
snapshot_check_failed = true
end
max_snap = nil
@@ -398,16 +433,20 @@ while #snaps > initial_snap_count do
fio.unlink(max_vylog)
snaps[max_snap_k] = nil
end;
----
-...
+ | ---
+ | ...
snapshot_check_failed;
----
-- false
-...
+ | ---
+ | - false
+ | ...
+
log.info('Part II: checking snapshot done');
----
-...
+ | ---
+ | ...
+
test_run:cmd("setopt delimiter ''");
----
-- true
-...
+ | ---
+ | - true
+ | ...
+
+
diff --git a/test/wal_off/snapshot_stress.test.lua b/test/wal_off/snapshot_stress.test.lua
index 34b3e7b78..715da9eca 100644
--- a/test/wal_off/snapshot_stress.test.lua
+++ b/test/wal_off/snapshot_stress.test.lua
@@ -40,7 +40,7 @@ script = fio.open(script_path, open_flags, tonumber('0777', 8))
script:write("os.exit(0)")
script:close()
res = os.execute(cmd)
-str_res = 'precheck ' .. (res == 0 and ' ok(2)' or 'failed(2)')
+str_res = 'precheck ' .. (res == true and ' ok(2)' or 'failed(2)')
str_res
snap_search_wildcard = fio.pathjoin(box.cfg.memtx_dir, '*.snap');
@@ -237,7 +237,7 @@ snaps_find_status = #snaps <= initial_snap_count and 'where are my snapshots?' o
snaps_find_status;
snapshot_check_failed = false
while #snaps > initial_snap_count do
- if not snapshot_check_failed and os.execute(cmd) ~= 0 then
+ if not snapshot_check_failed and os.execute(cmd) == nil then
snapshot_check_failed = true
end
max_snap = nil
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-11-07 14:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-07 14:03 [Tarantool-patches] [PATCH rfc 0/2] Lua " Olga Arkhangelskaia
2019-11-07 14:03 ` Olga Arkhangelskaia [this message]
2019-11-16 13:47 ` [Tarantool-patches] [PATCH 1/2] lua: turn on lua " Igor Munkin
2019-11-19 9:33 ` Olga Arkhangelskaia
2019-11-07 14:03 ` [Tarantool-patches] [PATCH 2/2] box: raise on raw modifications of box.cfg values Olga Arkhangelskaia
2019-11-17 18:56 ` Igor Munkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191107140314.92871-2-arkholga@tarantool.org \
--to=arkholga@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 1/2] lua: turn on lua 5.2 compatibility' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox