Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v1] test: switch on pretest_clean routine
@ 2019-04-04  6:11 avtikhon
  2019-04-07  7:08 ` [tarantool-patches] " Alexander Turenko
  0 siblings, 1 reply; 3+ messages in thread
From: avtikhon @ 2019-04-04  6:11 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: avtikhon, tarantool-patches

Flag 'pretest_clean = True' at the suite.ini file switches on
pretest_clean routine at the 'test-run' which helps to cleanup
the test environment before test start. This option that do
exactly what sqltester had been doing: when the option enabled
test-run removes *.{xlog,snap} files before run a 'core = app'
test. The only difference that now these files will be removed
for every test in sql-tap test suite, not only for ones that
use sqltester. Also it removes the global functions in box suite
before each test, that is why they were moved at the test_helpers
module.
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-3863-pretest-clean
Issue: https://github.com/tarantool/tarantool/issues/4094

 test/app-tap/suite.ini                        |  1 +
 test/app/suite.ini                            |  1 +
 test/box-py/suite.ini                         |  1 +
 test/box-tap/suite.ini                        |  1 +
 test/box/admin.result                         |  5 +-
 test/box/admin.test.lua                       |  3 +-
 test/box/box.lua                              | 29 -----------
 test/box/cfg.result                           |  7 ++-
 test/box/cfg.test.lua                         |  6 ++-
 test/box/lua/test_helpers.lua                 | 32 ++++++++++++
 test/box/sql.result                           | 50 +++++++++++--------
 test/box/sql.test.lua                         | 46 +++++++++--------
 test/box/suite.ini                            |  3 +-
 test/engine/suite.ini                         |  1 +
 test/engine_long/delete_insert.result         |  5 +-
 test/engine_long/delete_insert.test.lua       |  5 +-
 test/engine_long/delete_replace_update.result | 13 +++--
 .../delete_replace_update.test.lua            | 12 +++--
 test/engine_long/suite.ini                    |  1 +
 test/engine_long/suite.lua                    |  7 ++-
 test/long_run-py/suite.ini                    |  1 +
 test/luajit-tap/suite.ini                     |  1 +
 test/replication-py/suite.ini                 |  1 +
 test/replication/suite.ini                    |  1 +
 test/sql/suite.ini                            |  1 +
 test/unit/suite.ini                           |  1 +
 test/vinyl/suite.ini                          |  1 +
 test/wal_off/suite.ini                        |  1 +
 test/xlog-py/suite.ini                        |  1 +
 test/xlog/suite.ini                           |  1 +
 30 files changed, 145 insertions(+), 94 deletions(-)
 create mode 100644 test/box/lua/test_helpers.lua

diff --git a/test/app-tap/suite.ini b/test/app-tap/suite.ini
index 86af82637..9629dfad5 100644
--- a/test/app-tap/suite.ini
+++ b/test/app-tap/suite.ini
@@ -3,3 +3,4 @@ core = app
 description = application server tests (TAP)
 lua_libs = lua/require_mod.lua lua/serializer_test.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/app/suite.ini b/test/app/suite.ini
index 7f3c0a8f5..4f9e51550 100644
--- a/test/app/suite.ini
+++ b/test/app/suite.ini
@@ -5,3 +5,4 @@ script = app.lua
 lua_libs = lua/fiber.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/box-py/suite.ini b/test/box-py/suite.ini
index 18737e48f..fc75362e2 100644
--- a/test/box-py/suite.ini
+++ b/test/box-py/suite.ini
@@ -5,3 +5,4 @@ script = box.lua
 lua_libs = lua/fiber.lua lua/fifo.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/box-tap/suite.ini b/test/box-tap/suite.ini
index 50dc1f435..b3ccf2e6f 100644
--- a/test/box-tap/suite.ini
+++ b/test/box-tap/suite.ini
@@ -2,3 +2,4 @@
 core = app
 description = Database tests with #! using TAP
 is_parallel = True
+pretest_clean = True
diff --git a/test/box/admin.result b/test/box/admin.result
index 53ced2fcc..750050d20 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -24,7 +24,10 @@ help()
       \help                      -- show this screen
       \quit                      -- quit interactive console
 ...
-cfg_filter(box.cfg)
+test_helpers = require('test_helpers')
+---
+...
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
diff --git a/test/box/admin.test.lua b/test/box/admin.test.lua
index 4e7a78f5b..353afea9c 100644
--- a/test/box/admin.test.lua
+++ b/test/box/admin.test.lua
@@ -6,7 +6,8 @@ space = box.schema.space.create('tweedledum')
 index = space:create_index('primary')
 
 help()
-cfg_filter(box.cfg)
+test_helpers = require('test_helpers')
+test_helpers.cfg_filter(box.cfg)
 space:insert{1, 'tuple'}
 box.snapshot()
 space:delete{1}
diff --git a/test/box/box.lua b/test/box/box.lua
index b3b10ffd4..dcd52284c 100644
--- a/test/box/box.lua
+++ b/test/box/box.lua
@@ -8,32 +8,3 @@ box.cfg{
 }
 
 require('console').listen(os.getenv('ADMIN'))
-
-local _hide = {
-    pid_file=1, log=1, listen=1, vinyl_dir=1,
-    memtx_dir=1, wal_dir=1,
-    memtx_max_tuple_size=1, memtx_min_tuple_size=1
-}
-
-function cfg_filter(data)
-    if type(data)~='table' then return data end
-    local keys,k,_ = {}
-    for k in pairs(data) do
-        table.insert(keys, k)
-    end
-    table.sort(keys)
-    local result = {}
-    for _,k in pairs(keys) do
-        table.insert(result, {k, _hide[k] and '<hidden>' or cfg_filter(data[k])})
-    end
-    return result
-end
-
-function compare(a,b)
-    return a[1] < b[1]
-end
-
-function sorted(data)
-    table.sort(data, compare)
-    return data
-end
diff --git a/test/box/cfg.result b/test/box/cfg.result
index 66b02f591..e9b0aad1e 100644
--- a/test/box/cfg.result
+++ b/test/box/cfg.result
@@ -1,3 +1,6 @@
+test_helpers = require('test_helpers')
+---
+...
 env = require('test_run')
 ---
 ...
@@ -12,7 +15,7 @@ box.cfg.nosuchoption = 1
 ---
 - error: 'builtin/box/load_cfg.lua:<line>: Attempt to modify a read-only table'
 ...
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
@@ -111,7 +114,7 @@ cfg_filter(box.cfg)
 box.cfg()
 ---
 ...
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
diff --git a/test/box/cfg.test.lua b/test/box/cfg.test.lua
index eddeab126..29eb8242d 100644
--- a/test/box/cfg.test.lua
+++ b/test/box/cfg.test.lua
@@ -1,11 +1,13 @@
+test_helpers = require('test_helpers')
+
 env = require('test_run')
 test_run = env.new()
 test_run:cmd("push filter '(error: .*)\\.lua:[0-9]+: ' to '\\1.lua:<line>: '")
 box.cfg.nosuchoption = 1
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 -- must be read-only
 box.cfg()
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 
 -- check that cfg with unexpected parameter fails.
 box.cfg{sherlock = 'holmes'}
diff --git a/test/box/lua/test_helpers.lua b/test/box/lua/test_helpers.lua
new file mode 100644
index 000000000..bb231e73b
--- /dev/null
+++ b/test/box/lua/test_helpers.lua
@@ -0,0 +1,32 @@
+local test_helpers = {}
+
+local _hide = {
+    pid_file=1, log=1, listen=1, vinyl_dir=1,
+    memtx_dir=1, wal_dir=1,
+    memtx_max_tuple_size=1, memtx_min_tuple_size=1
+}
+
+function test_helpers.cfg_filter(data)
+    if type(data)~='table' then return data end
+    local keys,k,_ = {}
+    for k in pairs(data) do
+        table.insert(keys, k)
+    end
+    table.sort(keys)
+    local result = {}
+    for _,k in pairs(keys) do
+        table.insert(result, {k, _hide[k] and '<hidden>' or test_helpers.cfg_filter(data[k])})
+    end
+    return result
+end
+
+function compare(a,b)
+    return a[1] < b[1]
+end
+
+function test_helpers.sorted(data)
+    table.sort(data, compare)
+    return data
+end
+
+return test_helpers
diff --git a/test/box/sql.result b/test/box/sql.result
index 78dc47167..c10434986 100644
--- a/test/box/sql.result
+++ b/test/box/sql.result
@@ -227,6 +227,9 @@ space = nil
 net_box = require('net.box')
 ---
 ...
+test_helpers = require('test_helpers')
+---
+...
 -- Prepare spaces
 box.schema.user.create('test', { password = 'test' })
 ---
@@ -275,7 +278,7 @@ space:insert{'Kytes', 'Tomas'}
 ---
 - ['Kytes', 'Tomas']
 ...
-sorted(space.index.secondary:select('Richard'))
+test_helpers.sorted(space.index.secondary:select('Richard'))
 ---
 - - ['Doe', 'Richard']
   - ['Roe', 'Richard']
@@ -284,7 +287,7 @@ sorted(space.index.secondary:select('Richard'))
 -- A test case for Bug#729879
 -- "Zero limit is treated the same as no limit"
 -- https://bugs.launchpad.net/tarantool/+bug/729879
-sorted(space.index.secondary:select('Richard', { limit = 0 }))
+test_helpers.sorted(space.index.secondary:select('Richard', { limit = 0 }))
 ---
 - []
 ...
@@ -301,7 +304,7 @@ space:insert{'Britney'}
 ---
 - error: Tuple field 2 required by space format is missing
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
@@ -309,7 +312,7 @@ space:insert{'Stephanie'}
 ---
 - error: Tuple field 2 required by space format is missing
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
@@ -321,11 +324,11 @@ space:select{'Spears'}
 ---
 - - ['Spears', 'Britney']
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 ---
 - - ['Spears', 'Britney']
 ...
@@ -385,7 +388,7 @@ space:select{'key3'}
 ---
 - - ['key3', 'part1', 'part2_b']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - ['key1', 'part1', 'part2']
   - ['key2', 'part1', 'part2_a']
@@ -418,7 +421,7 @@ space:select{'key3'}
 ---
 - - ['key3', 'part1', 'part2_b']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - ['key1', 'part1', 'part2']
   - ['key2', 'part1', 'part2_a']
@@ -492,33 +495,33 @@ space:select{21234567}
 ---
 - - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
   - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part1_a'))
+test_helpers.sorted(space.index.secondary:select('part1_a'))
 ---
 - - [31234567, 'part1_a', 'part2']
   - [41234567, 'part1_a', 'part2_a']
 ...
-sorted(space.index.secondary:select('part_none'))
+test_helpers.sorted(space.index.secondary:select('part_none'))
 ---
 - []
 ...
-sorted(s.index[1]:select({'part1', 'part2'}))
+test_helpers.sorted(s.index[1]:select({'part1', 'part2'}))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
   - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part2'))
+test_helpers.sorted(space.index.secondary:select('part2'))
 ---
 - []
 ...
@@ -593,19 +596,22 @@ s = box.space.tweedledum
 ---
 ...
 -- Bug#929654 - secondary hash index is not built with build_indexes()
-sorted(space.index.secondary:select('hello'))
+test_helpers = require('test_helpers')
+---
+...
+test_helpers.sorted(space.index.secondary:select('hello'))
 ---
 - - [1, 'hello']
 ...
-sorted(space.index.secondary:select('brave'))
+test_helpers.sorted(space.index.secondary:select('brave'))
 ---
 - - [2, 'brave']
 ...
-sorted(space.index.secondary:select('new'))
+test_helpers.sorted(space.index.secondary:select('new'))
 ---
 - - [3, 'new']
 ...
-sorted(space.index.secondary:select('world'))
+test_helpers.sorted(space.index.secondary:select('world'))
 ---
 - - [4, 'world']
 ...
@@ -629,7 +635,7 @@ space:select{'Spears'}
 ---
 - - ['Spears', 'Britney']
 ...
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 ---
 - - ['Spears', 'Britney']
 ...
@@ -712,7 +718,7 @@ space:insert{15, 'duplicate three'}
 ---
 - [15, 'duplicate three']
 ...
-sorted(space.index.secondary:select('duplicate one'))
+test_helpers.sorted(space.index.secondary:select('duplicate one'))
 ---
 - - [1, 'duplicate one']
   - [2, 'duplicate one']
@@ -720,7 +726,7 @@ sorted(space.index.secondary:select('duplicate one'))
   - [4, 'duplicate one']
   - [5, 'duplicate one']
 ...
-sorted(space.index.secondary:select('duplicate two'))
+test_helpers.sorted(space.index.secondary:select('duplicate two'))
 ---
 - - [6, 'duplicate two']
   - [7, 'duplicate two']
@@ -728,7 +734,7 @@ sorted(space.index.secondary:select('duplicate two'))
   - [9, 'duplicate two']
   - [10, 'duplicate two']
 ...
-sorted(space.index.secondary:select('duplicate three'))
+test_helpers.sorted(space.index.secondary:select('duplicate three'))
 ---
 - - [11, 'duplicate three']
   - [12, 'duplicate three']
diff --git a/test/box/sql.test.lua b/test/box/sql.test.lua
index 3d2a99b74..9db701142 100644
--- a/test/box/sql.test.lua
+++ b/test/box/sql.test.lua
@@ -90,6 +90,7 @@ box.space.test1:drop()
 box.schema.user.drop('test')
 space = nil
 net_box = require('net.box')
+test_helpers = require('test_helpers')
 
 -- Prepare spaces
 box.schema.user.create('test', { password = 'test' })
@@ -110,13 +111,13 @@ space:insert{'Roe', 'Richard'}
 space:insert{'Woe', 'Richard'}
 space:insert{'Major', 'Tomas'}
 space:insert{'Kytes', 'Tomas'}
-sorted(space.index.secondary:select('Richard'))
+test_helpers.sorted(space.index.secondary:select('Richard'))
 
 
 -- A test case for Bug#729879
 -- "Zero limit is treated the same as no limit"
 -- https://bugs.launchpad.net/tarantool/+bug/729879
-sorted(space.index.secondary:select('Richard', { limit = 0 }))
+test_helpers.sorted(space.index.secondary:select('Richard', { limit = 0 }))
 s:truncate()
 
 
@@ -128,13 +129,13 @@ s:truncate()
 -- get away with it.
 
 space:insert{'Britney'}
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 space:insert{'Stephanie'}
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 space:insert{'Spears', 'Britney'}
 space:select{'Spears'}
-sorted(space.index.secondary:select('Anything'))
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 
 s.index[0]:select('Spears', { limit = 100, iterator = 'GE' })
 s.index[1]:select('Britney', { limit = 100, iterator = 'GE' })
@@ -156,7 +157,7 @@ s.index[1]:select{}
 space:select{'key1'}
 space:select{'key2'}
 space:select{'key3'}
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 
 s.index[1]:select('part1', { limit = 100, iterator = 'GE' })
 s.index[0]:select('key2', { limit = 100, iterator = 'GE' })
@@ -164,7 +165,7 @@ s.index[1]:select({ 'part1', 'part2_a' }, { limit = 1, iterator = 'GE' })
 space:select{'key1'}
 space:select{'key2'}
 space:select{'key3'}
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 
 space:delete('key1')
 space:delete('key2')
@@ -188,14 +189,14 @@ l
 space:select{1234567}
 space:select{11234567}
 space:select{21234567}
-sorted(space.index.secondary:select('part1'))
-sorted(space.index.secondary:select('part1_a'))
-sorted(space.index.secondary:select('part_none'))
+test_helpers.sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1_a'))
+test_helpers.sorted(space.index.secondary:select('part_none'))
 
-sorted(s.index[1]:select({'part1', 'part2'}))
+test_helpers.sorted(s.index[1]:select({'part1', 'part2'}))
 
-sorted(space.index.secondary:select('part1'))
-sorted(space.index.secondary:select('part2'))
+test_helpers.sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part2'))
 
 -- cleanup
 space:delete(1234567)
@@ -226,10 +227,11 @@ space = conn.space.tweedledum
 s = box.space.tweedledum
 
 -- Bug#929654 - secondary hash index is not built with build_indexes()
-sorted(space.index.secondary:select('hello'))
-sorted(space.index.secondary:select('brave'))
-sorted(space.index.secondary:select('new'))
-sorted(space.index.secondary:select('world'))
+test_helpers = require('test_helpers')
+test_helpers.sorted(space.index.secondary:select('hello'))
+test_helpers.sorted(space.index.secondary:select('brave'))
+test_helpers.sorted(space.index.secondary:select('new'))
+test_helpers.sorted(space.index.secondary:select('world'))
 s:truncate()
 
 -- A test case for: http://bugs.launchpad.net/bugs/735140
@@ -240,7 +242,7 @@ s.index.secondary:alter{type = 'tree', unique = false}
 
 space:insert{'Spears', 'Britney'}
 space:select{'Spears'}
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 -- try to insert the incoplete tuple
 space:replace{'Spears'}
 -- check that nothing has been updated
@@ -268,9 +270,9 @@ space:insert{14, 'duplicate three'}
 space:insert{15, 'duplicate three'}
 
 
-sorted(space.index.secondary:select('duplicate one'))
-sorted(space.index.secondary:select('duplicate two'))
-sorted(space.index.secondary:select('duplicate three'))
+test_helpers.sorted(space.index.secondary:select('duplicate one'))
+test_helpers.sorted(space.index.secondary:select('duplicate two'))
+test_helpers.sorted(space.index.secondary:select('duplicate three'))
 
 space:delete(1)
 space:delete(2)
diff --git a/test/box/suite.ini b/test/box/suite.ini
index fee1c40b4..ee89dd64b 100644
--- a/test/box/suite.ini
+++ b/test/box/suite.ini
@@ -4,6 +4,7 @@ description = Database tests
 script = box.lua
 disabled = rtree_errinj.test.lua tuple_bench.test.lua
 release_disabled = errinj.test.lua errinj_index.test.lua rtree_errinj.test.lua upsert_errinj.test.lua iproto_stress.test.lua
-lua_libs = lua/fifo.lua lua/utils.lua lua/bitset.lua lua/index_random_test.lua lua/push.lua lua/identifier.lua
+lua_libs = lua/test_helpers.lua lua/fifo.lua lua/utils.lua lua/bitset.lua lua/index_random_test.lua lua/push.lua lua/identifier.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine/suite.ini b/test/engine/suite.ini
index 3db02ab6f..d79efa659 100644
--- a/test/engine/suite.ini
+++ b/test/engine/suite.ini
@@ -8,3 +8,4 @@ config = engine.cfg
 #disabled = replica_join.test.lua
 lua_libs = conflict.lua ../box/lua/utils.lua ../box/lua/push.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine_long/delete_insert.result b/test/engine_long/delete_insert.result
index b1d504271..2cc46486a 100644
--- a/test/engine_long/delete_insert.result
+++ b/test/engine_long/delete_insert.result
@@ -1,3 +1,6 @@
+el_mod = require("suite")
+---
+...
 test_run = require('test_run')
 ---
 ...
@@ -13,7 +16,7 @@ iterations = 100000
 math.randomseed(1)
 ---
 ...
-delete_insert(engine, iterations)
+el_mod.delete_insert(engine, iterations)
 ---
 - - 100000
   - IAKGPQANAOSLARIFIBKB
diff --git a/test/engine_long/delete_insert.test.lua b/test/engine_long/delete_insert.test.lua
index 275aaa23e..83119cf14 100644
--- a/test/engine_long/delete_insert.test.lua
+++ b/test/engine_long/delete_insert.test.lua
@@ -1,6 +1,9 @@
+el_mod = require("suite")
+
 test_run = require('test_run')
 inspector = test_run.new()
 engine = inspector:get_cfg('engine')
 iterations = 100000
+
 math.randomseed(1)
-delete_insert(engine, iterations)
+el_mod.delete_insert(engine, iterations)
diff --git a/test/engine_long/delete_replace_update.result b/test/engine_long/delete_replace_update.result
index 66cb9c82c..b75091945 100644
--- a/test/engine_long/delete_replace_update.result
+++ b/test/engine_long/delete_replace_update.result
@@ -1,3 +1,6 @@
+el_mod = require("suite")
+---
+...
 engine_name = 'memtx'
 ---
 ...
@@ -7,7 +10,7 @@ iterations = 100000
 math.randomseed(1)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -17,7 +20,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(2)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -27,7 +30,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(3)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 1
@@ -37,7 +40,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(4)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -47,7 +50,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(5)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
diff --git a/test/engine_long/delete_replace_update.test.lua b/test/engine_long/delete_replace_update.test.lua
index 466b8f007..004597b15 100644
--- a/test/engine_long/delete_replace_update.test.lua
+++ b/test/engine_long/delete_replace_update.test.lua
@@ -1,17 +1,19 @@
+el_mod = require("suite")
+
 engine_name = 'memtx'
 iterations = 100000
 
 math.randomseed(1)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(2)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(3)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(4)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(5)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
diff --git a/test/engine_long/suite.ini b/test/engine_long/suite.ini
index 66df26715..2447344fb 100644
--- a/test/engine_long/suite.ini
+++ b/test/engine_long/suite.ini
@@ -7,3 +7,4 @@ lua_libs = suite.lua
 use_unix_sockets = True
 config = engine.cfg
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine_long/suite.lua b/test/engine_long/suite.lua
index 464138db1..4db885031 100644
--- a/test/engine_long/suite.lua
+++ b/test/engine_long/suite.lua
@@ -1,3 +1,4 @@
+local engine_long_module = {}
 
 function string_function()
     local random_number
@@ -10,7 +11,7 @@ function string_function()
     return random_string
 end
 
-function delete_replace_update(engine_name, iterations)
+function engine_long_module.delete_replace_update(engine_name, iterations)
     local string_value
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
@@ -69,7 +70,7 @@ function delete_replace_update(engine_name, iterations)
     return {counter, random_number, string_value_2, string_value_3}
 end
 
-function delete_insert(engine_name, iterations)
+function engine_long_module.delete_insert(engine_name, iterations)
     local string_value
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
@@ -107,3 +108,5 @@ function delete_insert(engine_name, iterations)
     box.space.tester:drop()
     return {counter, string_value_2}
 end
+
+return engine_long_module
diff --git a/test/long_run-py/suite.ini b/test/long_run-py/suite.ini
index 9050f9b77..45e825b89 100644
--- a/test/long_run-py/suite.ini
+++ b/test/long_run-py/suite.ini
@@ -8,3 +8,4 @@ release_disabled =
 lua_libs = suite.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/luajit-tap/suite.ini b/test/luajit-tap/suite.ini
index 80899270e..3e860c9ac 100644
--- a/test/luajit-tap/suite.ini
+++ b/test/luajit-tap/suite.ini
@@ -2,3 +2,4 @@
 core = app
 description = Luajit tests
 is_parallel = True
+pretest_clean = True
diff --git a/test/replication-py/suite.ini b/test/replication-py/suite.ini
index df2dd8ef0..2a7b31fb6 100644
--- a/test/replication-py/suite.ini
+++ b/test/replication-py/suite.ini
@@ -3,3 +3,4 @@ core = tarantool
 script =  master.lua
 description = tarantool/box, replication
 is_parallel = True
+pretest_clean = True
diff --git a/test/replication/suite.ini b/test/replication/suite.ini
index dd5b01405..0ca85933b 100644
--- a/test/replication/suite.ini
+++ b/test/replication/suite.ini
@@ -9,3 +9,4 @@ lua_libs = lua/fast_replica.lua lua/rlimit.lua
 use_unix_sockets = True
 long_run = prune.test.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/sql/suite.ini b/test/sql/suite.ini
index bfe0fa063..ebaf81a53 100644
--- a/test/sql/suite.ini
+++ b/test/sql/suite.ini
@@ -8,3 +8,4 @@ is_parallel = True
 lua_libs = lua/sql_tokenizer.lua
 release_disabled = errinj.test.lua view_delayed_wal.test.lua sql-debug.test.lua
 disabled = sql-statN-index-drop.test.lua
+pretest_clean = True
diff --git a/test/unit/suite.ini b/test/unit/suite.ini
index 75c80ece1..df9b458ee 100644
--- a/test/unit/suite.ini
+++ b/test/unit/suite.ini
@@ -2,3 +2,4 @@
 core = unittest
 description = unit tests
 is_parallel = True
+pretest_clean = True
diff --git a/test/vinyl/suite.ini b/test/vinyl/suite.ini
index d2a194d85..3612cf44b 100644
--- a/test/vinyl/suite.ini
+++ b/test/vinyl/suite.ini
@@ -9,3 +9,4 @@ use_unix_sockets = True
 long_run = stress.test.lua large.test.lua write_iterator_rand.test.lua dump_stress.test.lua select_consistency.test.lua throttle.test.lua
 is_parallel = False
 disabled = upgrade.test.lua
+pretest_clean = True
diff --git a/test/wal_off/suite.ini b/test/wal_off/suite.ini
index bd3a349db..679104f82 100644
--- a/test/wal_off/suite.ini
+++ b/test/wal_off/suite.ini
@@ -4,3 +4,4 @@ script = wal.lua
 description = tarantool/box, wal_mode = none
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/xlog-py/suite.ini b/test/xlog-py/suite.ini
index 18737e48f..fc75362e2 100644
--- a/test/xlog-py/suite.ini
+++ b/test/xlog-py/suite.ini
@@ -5,3 +5,4 @@ script = box.lua
 lua_libs = lua/fiber.lua lua/fifo.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/xlog/suite.ini b/test/xlog/suite.ini
index 4043f3700..06cfbb068 100644
--- a/test/xlog/suite.ini
+++ b/test/xlog/suite.ini
@@ -9,3 +9,4 @@ config = suite.cfg
 use_unix_sockets = True
 long_run = snap_io_rate.test.lua
 is_parallel = True
+pretest_clean = True
-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] Re: [PATCH v1] test: switch on pretest_clean routine
  2019-04-04  6:11 [tarantool-patches] [PATCH v1] test: switch on pretest_clean routine avtikhon
@ 2019-04-07  7:08 ` Alexander Turenko
  0 siblings, 0 replies; 3+ messages in thread
From: Alexander Turenko @ 2019-04-07  7:08 UTC (permalink / raw)
  To: avtikhon; +Cc: tarantool-patches

Removed the flag from python tests and unit tests (it does not do
anything in these cases, see the description in test-run/README.md).

There was review [1] and it seems some comments are still actual.
However I tried to implement that myself and was dissatisfied with the
result, because of the following reasons:

- much code of tests moves around w/o visible reasons;
- this way disallows usage of functions from an instance file in tests
  w/o, again, visible reasons; it obligates a developer to have a
  separate file for helper functions to reuse them across tests or copy
  them to each test (and they will reside in result files also).

So I decided to implement user-provided list of protected globals [2]
and use it here.

Described how the option works in the commit message and mentioned that
the issue has an example of a problem that is beat with this option.

Pushed to master and 2.1.

[1]: https://www.freelists.org/post/tarantool-patches/test-switched-on-pretest-clean-routine,1
[2]: https://github.com/tarantool/test-run/pull/153

WBR, Alexander Turenko.

On Thu, Apr 04, 2019 at 09:11:01AM +0300, avtikhon wrote:
> Flag 'pretest_clean = True' at the suite.ini file switches on
> pretest_clean routine at the 'test-run' which helps to cleanup
> the test environment before test start. This option that do
> exactly what sqltester had been doing: when the option enabled
> test-run removes *.{xlog,snap} files before run a 'core = app'
> test. The only difference that now these files will be removed
> for every test in sql-tap test suite, not only for ones that
> use sqltester. Also it removes the global functions in box suite
> before each test, that is why they were moved at the test_helpers
> module.
> ---
> 
> Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-3863-pretest-clean
> Issue: https://github.com/tarantool/tarantool/issues/4094

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tarantool-patches] [PATCH v1] test: switch on pretest_clean routine
@ 2019-04-03 10:21 avtikhon
  0 siblings, 0 replies; 3+ messages in thread
From: avtikhon @ 2019-04-03 10:21 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: avtikhon, tarantool-patches

Switched on pretest_clean routine which helps to cleanup
the test environment before test start. Also moved the global
functions in box suite into the test_helpers module, to make
it possible to use it in each of the test while global functions
are removing with pretest_clean routine.
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-3863-pretest-clean
Issue: https://github.com/tarantool/tarantool/issues/4094

 test/app-tap/suite.ini                        |  1 +
 test/app/suite.ini                            |  1 +
 test/box-py/suite.ini                         |  1 +
 test/box-tap/suite.ini                        |  1 +
 test/box/admin.result                         |  5 +-
 test/box/admin.test.lua                       |  3 +-
 test/box/box.lua                              | 29 -----------
 test/box/cfg.result                           |  7 ++-
 test/box/cfg.test.lua                         |  6 ++-
 test/box/lua/test_helpers.lua                 | 32 ++++++++++++
 test/box/sql.result                           | 50 +++++++++++--------
 test/box/sql.test.lua                         | 46 +++++++++--------
 test/box/suite.ini                            |  3 +-
 test/engine/suite.ini                         |  1 +
 test/engine_long/delete_insert.result         |  5 +-
 test/engine_long/delete_insert.test.lua       |  5 +-
 test/engine_long/delete_replace_update.result | 13 +++--
 .../delete_replace_update.test.lua            | 12 +++--
 test/engine_long/suite.ini                    |  1 +
 test/engine_long/suite.lua                    |  7 ++-
 test/long_run-py/suite.ini                    |  1 +
 test/luajit-tap/suite.ini                     |  1 +
 test/replication-py/suite.ini                 |  1 +
 test/replication/suite.ini                    |  1 +
 test/sql/suite.ini                            |  1 +
 test/unit/suite.ini                           |  1 +
 test/vinyl/suite.ini                          |  1 +
 test/wal_off/suite.ini                        |  1 +
 test/xlog-py/suite.ini                        |  1 +
 test/xlog/suite.ini                           |  1 +
 30 files changed, 145 insertions(+), 94 deletions(-)
 create mode 100644 test/box/lua/test_helpers.lua

diff --git a/test/app-tap/suite.ini b/test/app-tap/suite.ini
index 86af82637..9629dfad5 100644
--- a/test/app-tap/suite.ini
+++ b/test/app-tap/suite.ini
@@ -3,3 +3,4 @@ core = app
 description = application server tests (TAP)
 lua_libs = lua/require_mod.lua lua/serializer_test.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/app/suite.ini b/test/app/suite.ini
index 7f3c0a8f5..4f9e51550 100644
--- a/test/app/suite.ini
+++ b/test/app/suite.ini
@@ -5,3 +5,4 @@ script = app.lua
 lua_libs = lua/fiber.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/box-py/suite.ini b/test/box-py/suite.ini
index 18737e48f..fc75362e2 100644
--- a/test/box-py/suite.ini
+++ b/test/box-py/suite.ini
@@ -5,3 +5,4 @@ script = box.lua
 lua_libs = lua/fiber.lua lua/fifo.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/box-tap/suite.ini b/test/box-tap/suite.ini
index 50dc1f435..b3ccf2e6f 100644
--- a/test/box-tap/suite.ini
+++ b/test/box-tap/suite.ini
@@ -2,3 +2,4 @@
 core = app
 description = Database tests with #! using TAP
 is_parallel = True
+pretest_clean = True
diff --git a/test/box/admin.result b/test/box/admin.result
index 53ced2fcc..750050d20 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -24,7 +24,10 @@ help()
       \help                      -- show this screen
       \quit                      -- quit interactive console
 ...
-cfg_filter(box.cfg)
+test_helpers = require('test_helpers')
+---
+...
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
diff --git a/test/box/admin.test.lua b/test/box/admin.test.lua
index 4e7a78f5b..353afea9c 100644
--- a/test/box/admin.test.lua
+++ b/test/box/admin.test.lua
@@ -6,7 +6,8 @@ space = box.schema.space.create('tweedledum')
 index = space:create_index('primary')
 
 help()
-cfg_filter(box.cfg)
+test_helpers = require('test_helpers')
+test_helpers.cfg_filter(box.cfg)
 space:insert{1, 'tuple'}
 box.snapshot()
 space:delete{1}
diff --git a/test/box/box.lua b/test/box/box.lua
index b3b10ffd4..dcd52284c 100644
--- a/test/box/box.lua
+++ b/test/box/box.lua
@@ -8,32 +8,3 @@ box.cfg{
 }
 
 require('console').listen(os.getenv('ADMIN'))
-
-local _hide = {
-    pid_file=1, log=1, listen=1, vinyl_dir=1,
-    memtx_dir=1, wal_dir=1,
-    memtx_max_tuple_size=1, memtx_min_tuple_size=1
-}
-
-function cfg_filter(data)
-    if type(data)~='table' then return data end
-    local keys,k,_ = {}
-    for k in pairs(data) do
-        table.insert(keys, k)
-    end
-    table.sort(keys)
-    local result = {}
-    for _,k in pairs(keys) do
-        table.insert(result, {k, _hide[k] and '<hidden>' or cfg_filter(data[k])})
-    end
-    return result
-end
-
-function compare(a,b)
-    return a[1] < b[1]
-end
-
-function sorted(data)
-    table.sort(data, compare)
-    return data
-end
diff --git a/test/box/cfg.result b/test/box/cfg.result
index 66b02f591..e9b0aad1e 100644
--- a/test/box/cfg.result
+++ b/test/box/cfg.result
@@ -1,3 +1,6 @@
+test_helpers = require('test_helpers')
+---
+...
 env = require('test_run')
 ---
 ...
@@ -12,7 +15,7 @@ box.cfg.nosuchoption = 1
 ---
 - error: 'builtin/box/load_cfg.lua:<line>: Attempt to modify a read-only table'
 ...
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
@@ -111,7 +114,7 @@ cfg_filter(box.cfg)
 box.cfg()
 ---
 ...
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 ---
 - - - background
     - false
diff --git a/test/box/cfg.test.lua b/test/box/cfg.test.lua
index eddeab126..29eb8242d 100644
--- a/test/box/cfg.test.lua
+++ b/test/box/cfg.test.lua
@@ -1,11 +1,13 @@
+test_helpers = require('test_helpers')
+
 env = require('test_run')
 test_run = env.new()
 test_run:cmd("push filter '(error: .*)\\.lua:[0-9]+: ' to '\\1.lua:<line>: '")
 box.cfg.nosuchoption = 1
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 -- must be read-only
 box.cfg()
-cfg_filter(box.cfg)
+test_helpers.cfg_filter(box.cfg)
 
 -- check that cfg with unexpected parameter fails.
 box.cfg{sherlock = 'holmes'}
diff --git a/test/box/lua/test_helpers.lua b/test/box/lua/test_helpers.lua
new file mode 100644
index 000000000..bb231e73b
--- /dev/null
+++ b/test/box/lua/test_helpers.lua
@@ -0,0 +1,32 @@
+local test_helpers = {}
+
+local _hide = {
+    pid_file=1, log=1, listen=1, vinyl_dir=1,
+    memtx_dir=1, wal_dir=1,
+    memtx_max_tuple_size=1, memtx_min_tuple_size=1
+}
+
+function test_helpers.cfg_filter(data)
+    if type(data)~='table' then return data end
+    local keys,k,_ = {}
+    for k in pairs(data) do
+        table.insert(keys, k)
+    end
+    table.sort(keys)
+    local result = {}
+    for _,k in pairs(keys) do
+        table.insert(result, {k, _hide[k] and '<hidden>' or test_helpers.cfg_filter(data[k])})
+    end
+    return result
+end
+
+function compare(a,b)
+    return a[1] < b[1]
+end
+
+function test_helpers.sorted(data)
+    table.sort(data, compare)
+    return data
+end
+
+return test_helpers
diff --git a/test/box/sql.result b/test/box/sql.result
index 78dc47167..c10434986 100644
--- a/test/box/sql.result
+++ b/test/box/sql.result
@@ -227,6 +227,9 @@ space = nil
 net_box = require('net.box')
 ---
 ...
+test_helpers = require('test_helpers')
+---
+...
 -- Prepare spaces
 box.schema.user.create('test', { password = 'test' })
 ---
@@ -275,7 +278,7 @@ space:insert{'Kytes', 'Tomas'}
 ---
 - ['Kytes', 'Tomas']
 ...
-sorted(space.index.secondary:select('Richard'))
+test_helpers.sorted(space.index.secondary:select('Richard'))
 ---
 - - ['Doe', 'Richard']
   - ['Roe', 'Richard']
@@ -284,7 +287,7 @@ sorted(space.index.secondary:select('Richard'))
 -- A test case for Bug#729879
 -- "Zero limit is treated the same as no limit"
 -- https://bugs.launchpad.net/tarantool/+bug/729879
-sorted(space.index.secondary:select('Richard', { limit = 0 }))
+test_helpers.sorted(space.index.secondary:select('Richard', { limit = 0 }))
 ---
 - []
 ...
@@ -301,7 +304,7 @@ space:insert{'Britney'}
 ---
 - error: Tuple field 2 required by space format is missing
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
@@ -309,7 +312,7 @@ space:insert{'Stephanie'}
 ---
 - error: Tuple field 2 required by space format is missing
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
@@ -321,11 +324,11 @@ space:select{'Spears'}
 ---
 - - ['Spears', 'Britney']
 ...
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 ---
 - []
 ...
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 ---
 - - ['Spears', 'Britney']
 ...
@@ -385,7 +388,7 @@ space:select{'key3'}
 ---
 - - ['key3', 'part1', 'part2_b']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - ['key1', 'part1', 'part2']
   - ['key2', 'part1', 'part2_a']
@@ -418,7 +421,7 @@ space:select{'key3'}
 ---
 - - ['key3', 'part1', 'part2_b']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - ['key1', 'part1', 'part2']
   - ['key2', 'part1', 'part2_a']
@@ -492,33 +495,33 @@ space:select{21234567}
 ---
 - - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
   - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part1_a'))
+test_helpers.sorted(space.index.secondary:select('part1_a'))
 ---
 - - [31234567, 'part1_a', 'part2']
   - [41234567, 'part1_a', 'part2_a']
 ...
-sorted(space.index.secondary:select('part_none'))
+test_helpers.sorted(space.index.secondary:select('part_none'))
 ---
 - []
 ...
-sorted(s.index[1]:select({'part1', 'part2'}))
+test_helpers.sorted(s.index[1]:select({'part1', 'part2'}))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
 ...
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 ---
 - - [1234567, 'part1', 'part2']
   - [11234567, 'part1', 'part2']
   - [21234567, 'part1', 'part2_a']
 ...
-sorted(space.index.secondary:select('part2'))
+test_helpers.sorted(space.index.secondary:select('part2'))
 ---
 - []
 ...
@@ -593,19 +596,22 @@ s = box.space.tweedledum
 ---
 ...
 -- Bug#929654 - secondary hash index is not built with build_indexes()
-sorted(space.index.secondary:select('hello'))
+test_helpers = require('test_helpers')
+---
+...
+test_helpers.sorted(space.index.secondary:select('hello'))
 ---
 - - [1, 'hello']
 ...
-sorted(space.index.secondary:select('brave'))
+test_helpers.sorted(space.index.secondary:select('brave'))
 ---
 - - [2, 'brave']
 ...
-sorted(space.index.secondary:select('new'))
+test_helpers.sorted(space.index.secondary:select('new'))
 ---
 - - [3, 'new']
 ...
-sorted(space.index.secondary:select('world'))
+test_helpers.sorted(space.index.secondary:select('world'))
 ---
 - - [4, 'world']
 ...
@@ -629,7 +635,7 @@ space:select{'Spears'}
 ---
 - - ['Spears', 'Britney']
 ...
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 ---
 - - ['Spears', 'Britney']
 ...
@@ -712,7 +718,7 @@ space:insert{15, 'duplicate three'}
 ---
 - [15, 'duplicate three']
 ...
-sorted(space.index.secondary:select('duplicate one'))
+test_helpers.sorted(space.index.secondary:select('duplicate one'))
 ---
 - - [1, 'duplicate one']
   - [2, 'duplicate one']
@@ -720,7 +726,7 @@ sorted(space.index.secondary:select('duplicate one'))
   - [4, 'duplicate one']
   - [5, 'duplicate one']
 ...
-sorted(space.index.secondary:select('duplicate two'))
+test_helpers.sorted(space.index.secondary:select('duplicate two'))
 ---
 - - [6, 'duplicate two']
   - [7, 'duplicate two']
@@ -728,7 +734,7 @@ sorted(space.index.secondary:select('duplicate two'))
   - [9, 'duplicate two']
   - [10, 'duplicate two']
 ...
-sorted(space.index.secondary:select('duplicate three'))
+test_helpers.sorted(space.index.secondary:select('duplicate three'))
 ---
 - - [11, 'duplicate three']
   - [12, 'duplicate three']
diff --git a/test/box/sql.test.lua b/test/box/sql.test.lua
index 3d2a99b74..9db701142 100644
--- a/test/box/sql.test.lua
+++ b/test/box/sql.test.lua
@@ -90,6 +90,7 @@ box.space.test1:drop()
 box.schema.user.drop('test')
 space = nil
 net_box = require('net.box')
+test_helpers = require('test_helpers')
 
 -- Prepare spaces
 box.schema.user.create('test', { password = 'test' })
@@ -110,13 +111,13 @@ space:insert{'Roe', 'Richard'}
 space:insert{'Woe', 'Richard'}
 space:insert{'Major', 'Tomas'}
 space:insert{'Kytes', 'Tomas'}
-sorted(space.index.secondary:select('Richard'))
+test_helpers.sorted(space.index.secondary:select('Richard'))
 
 
 -- A test case for Bug#729879
 -- "Zero limit is treated the same as no limit"
 -- https://bugs.launchpad.net/tarantool/+bug/729879
-sorted(space.index.secondary:select('Richard', { limit = 0 }))
+test_helpers.sorted(space.index.secondary:select('Richard', { limit = 0 }))
 s:truncate()
 
 
@@ -128,13 +129,13 @@ s:truncate()
 -- get away with it.
 
 space:insert{'Britney'}
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 space:insert{'Stephanie'}
-sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
 space:insert{'Spears', 'Britney'}
 space:select{'Spears'}
-sorted(space.index.secondary:select('Anything'))
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Anything'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 
 s.index[0]:select('Spears', { limit = 100, iterator = 'GE' })
 s.index[1]:select('Britney', { limit = 100, iterator = 'GE' })
@@ -156,7 +157,7 @@ s.index[1]:select{}
 space:select{'key1'}
 space:select{'key2'}
 space:select{'key3'}
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 
 s.index[1]:select('part1', { limit = 100, iterator = 'GE' })
 s.index[0]:select('key2', { limit = 100, iterator = 'GE' })
@@ -164,7 +165,7 @@ s.index[1]:select({ 'part1', 'part2_a' }, { limit = 1, iterator = 'GE' })
 space:select{'key1'}
 space:select{'key2'}
 space:select{'key3'}
-sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1'))
 
 space:delete('key1')
 space:delete('key2')
@@ -188,14 +189,14 @@ l
 space:select{1234567}
 space:select{11234567}
 space:select{21234567}
-sorted(space.index.secondary:select('part1'))
-sorted(space.index.secondary:select('part1_a'))
-sorted(space.index.secondary:select('part_none'))
+test_helpers.sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part1_a'))
+test_helpers.sorted(space.index.secondary:select('part_none'))
 
-sorted(s.index[1]:select({'part1', 'part2'}))
+test_helpers.sorted(s.index[1]:select({'part1', 'part2'}))
 
-sorted(space.index.secondary:select('part1'))
-sorted(space.index.secondary:select('part2'))
+test_helpers.sorted(space.index.secondary:select('part1'))
+test_helpers.sorted(space.index.secondary:select('part2'))
 
 -- cleanup
 space:delete(1234567)
@@ -226,10 +227,11 @@ space = conn.space.tweedledum
 s = box.space.tweedledum
 
 -- Bug#929654 - secondary hash index is not built with build_indexes()
-sorted(space.index.secondary:select('hello'))
-sorted(space.index.secondary:select('brave'))
-sorted(space.index.secondary:select('new'))
-sorted(space.index.secondary:select('world'))
+test_helpers = require('test_helpers')
+test_helpers.sorted(space.index.secondary:select('hello'))
+test_helpers.sorted(space.index.secondary:select('brave'))
+test_helpers.sorted(space.index.secondary:select('new'))
+test_helpers.sorted(space.index.secondary:select('world'))
 s:truncate()
 
 -- A test case for: http://bugs.launchpad.net/bugs/735140
@@ -240,7 +242,7 @@ s.index.secondary:alter{type = 'tree', unique = false}
 
 space:insert{'Spears', 'Britney'}
 space:select{'Spears'}
-sorted(space.index.secondary:select('Britney'))
+test_helpers.sorted(space.index.secondary:select('Britney'))
 -- try to insert the incoplete tuple
 space:replace{'Spears'}
 -- check that nothing has been updated
@@ -268,9 +270,9 @@ space:insert{14, 'duplicate three'}
 space:insert{15, 'duplicate three'}
 
 
-sorted(space.index.secondary:select('duplicate one'))
-sorted(space.index.secondary:select('duplicate two'))
-sorted(space.index.secondary:select('duplicate three'))
+test_helpers.sorted(space.index.secondary:select('duplicate one'))
+test_helpers.sorted(space.index.secondary:select('duplicate two'))
+test_helpers.sorted(space.index.secondary:select('duplicate three'))
 
 space:delete(1)
 space:delete(2)
diff --git a/test/box/suite.ini b/test/box/suite.ini
index fee1c40b4..ee89dd64b 100644
--- a/test/box/suite.ini
+++ b/test/box/suite.ini
@@ -4,6 +4,7 @@ description = Database tests
 script = box.lua
 disabled = rtree_errinj.test.lua tuple_bench.test.lua
 release_disabled = errinj.test.lua errinj_index.test.lua rtree_errinj.test.lua upsert_errinj.test.lua iproto_stress.test.lua
-lua_libs = lua/fifo.lua lua/utils.lua lua/bitset.lua lua/index_random_test.lua lua/push.lua lua/identifier.lua
+lua_libs = lua/test_helpers.lua lua/fifo.lua lua/utils.lua lua/bitset.lua lua/index_random_test.lua lua/push.lua lua/identifier.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine/suite.ini b/test/engine/suite.ini
index 3db02ab6f..d79efa659 100644
--- a/test/engine/suite.ini
+++ b/test/engine/suite.ini
@@ -8,3 +8,4 @@ config = engine.cfg
 #disabled = replica_join.test.lua
 lua_libs = conflict.lua ../box/lua/utils.lua ../box/lua/push.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine_long/delete_insert.result b/test/engine_long/delete_insert.result
index b1d504271..2cc46486a 100644
--- a/test/engine_long/delete_insert.result
+++ b/test/engine_long/delete_insert.result
@@ -1,3 +1,6 @@
+el_mod = require("suite")
+---
+...
 test_run = require('test_run')
 ---
 ...
@@ -13,7 +16,7 @@ iterations = 100000
 math.randomseed(1)
 ---
 ...
-delete_insert(engine, iterations)
+el_mod.delete_insert(engine, iterations)
 ---
 - - 100000
   - IAKGPQANAOSLARIFIBKB
diff --git a/test/engine_long/delete_insert.test.lua b/test/engine_long/delete_insert.test.lua
index 275aaa23e..83119cf14 100644
--- a/test/engine_long/delete_insert.test.lua
+++ b/test/engine_long/delete_insert.test.lua
@@ -1,6 +1,9 @@
+el_mod = require("suite")
+
 test_run = require('test_run')
 inspector = test_run.new()
 engine = inspector:get_cfg('engine')
 iterations = 100000
+
 math.randomseed(1)
-delete_insert(engine, iterations)
+el_mod.delete_insert(engine, iterations)
diff --git a/test/engine_long/delete_replace_update.result b/test/engine_long/delete_replace_update.result
index 66cb9c82c..b75091945 100644
--- a/test/engine_long/delete_replace_update.result
+++ b/test/engine_long/delete_replace_update.result
@@ -1,3 +1,6 @@
+el_mod = require("suite")
+---
+...
 engine_name = 'memtx'
 ---
 ...
@@ -7,7 +10,7 @@ iterations = 100000
 math.randomseed(1)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -17,7 +20,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(2)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -27,7 +30,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(3)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 1
@@ -37,7 +40,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(4)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
@@ -47,7 +50,7 @@ delete_replace_update(engine_name, iterations)
 math.randomseed(5)
 ---
 ...
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 ---
 - - 100000
   - 3
diff --git a/test/engine_long/delete_replace_update.test.lua b/test/engine_long/delete_replace_update.test.lua
index 466b8f007..004597b15 100644
--- a/test/engine_long/delete_replace_update.test.lua
+++ b/test/engine_long/delete_replace_update.test.lua
@@ -1,17 +1,19 @@
+el_mod = require("suite")
+
 engine_name = 'memtx'
 iterations = 100000
 
 math.randomseed(1)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(2)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(3)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(4)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
 
 math.randomseed(5)
-delete_replace_update(engine_name, iterations)
+el_mod.delete_replace_update(engine_name, iterations)
diff --git a/test/engine_long/suite.ini b/test/engine_long/suite.ini
index 66df26715..2447344fb 100644
--- a/test/engine_long/suite.ini
+++ b/test/engine_long/suite.ini
@@ -7,3 +7,4 @@ lua_libs = suite.lua
 use_unix_sockets = True
 config = engine.cfg
 is_parallel = True
+pretest_clean = True
diff --git a/test/engine_long/suite.lua b/test/engine_long/suite.lua
index 464138db1..4db885031 100644
--- a/test/engine_long/suite.lua
+++ b/test/engine_long/suite.lua
@@ -1,3 +1,4 @@
+local engine_long_module = {}
 
 function string_function()
     local random_number
@@ -10,7 +11,7 @@ function string_function()
     return random_string
 end
 
-function delete_replace_update(engine_name, iterations)
+function engine_long_module.delete_replace_update(engine_name, iterations)
     local string_value
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
@@ -69,7 +70,7 @@ function delete_replace_update(engine_name, iterations)
     return {counter, random_number, string_value_2, string_value_3}
 end
 
-function delete_insert(engine_name, iterations)
+function engine_long_module.delete_insert(engine_name, iterations)
     local string_value
     if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
         box.space.tester:drop()
@@ -107,3 +108,5 @@ function delete_insert(engine_name, iterations)
     box.space.tester:drop()
     return {counter, string_value_2}
 end
+
+return engine_long_module
diff --git a/test/long_run-py/suite.ini b/test/long_run-py/suite.ini
index 9050f9b77..45e825b89 100644
--- a/test/long_run-py/suite.ini
+++ b/test/long_run-py/suite.ini
@@ -8,3 +8,4 @@ release_disabled =
 lua_libs = suite.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/luajit-tap/suite.ini b/test/luajit-tap/suite.ini
index 80899270e..3e860c9ac 100644
--- a/test/luajit-tap/suite.ini
+++ b/test/luajit-tap/suite.ini
@@ -2,3 +2,4 @@
 core = app
 description = Luajit tests
 is_parallel = True
+pretest_clean = True
diff --git a/test/replication-py/suite.ini b/test/replication-py/suite.ini
index df2dd8ef0..2a7b31fb6 100644
--- a/test/replication-py/suite.ini
+++ b/test/replication-py/suite.ini
@@ -3,3 +3,4 @@ core = tarantool
 script =  master.lua
 description = tarantool/box, replication
 is_parallel = True
+pretest_clean = True
diff --git a/test/replication/suite.ini b/test/replication/suite.ini
index dd5b01405..0ca85933b 100644
--- a/test/replication/suite.ini
+++ b/test/replication/suite.ini
@@ -9,3 +9,4 @@ lua_libs = lua/fast_replica.lua lua/rlimit.lua
 use_unix_sockets = True
 long_run = prune.test.lua
 is_parallel = True
+pretest_clean = True
diff --git a/test/sql/suite.ini b/test/sql/suite.ini
index bfe0fa063..ebaf81a53 100644
--- a/test/sql/suite.ini
+++ b/test/sql/suite.ini
@@ -8,3 +8,4 @@ is_parallel = True
 lua_libs = lua/sql_tokenizer.lua
 release_disabled = errinj.test.lua view_delayed_wal.test.lua sql-debug.test.lua
 disabled = sql-statN-index-drop.test.lua
+pretest_clean = True
diff --git a/test/unit/suite.ini b/test/unit/suite.ini
index 75c80ece1..df9b458ee 100644
--- a/test/unit/suite.ini
+++ b/test/unit/suite.ini
@@ -2,3 +2,4 @@
 core = unittest
 description = unit tests
 is_parallel = True
+pretest_clean = True
diff --git a/test/vinyl/suite.ini b/test/vinyl/suite.ini
index d2a194d85..3612cf44b 100644
--- a/test/vinyl/suite.ini
+++ b/test/vinyl/suite.ini
@@ -9,3 +9,4 @@ use_unix_sockets = True
 long_run = stress.test.lua large.test.lua write_iterator_rand.test.lua dump_stress.test.lua select_consistency.test.lua throttle.test.lua
 is_parallel = False
 disabled = upgrade.test.lua
+pretest_clean = True
diff --git a/test/wal_off/suite.ini b/test/wal_off/suite.ini
index bd3a349db..679104f82 100644
--- a/test/wal_off/suite.ini
+++ b/test/wal_off/suite.ini
@@ -4,3 +4,4 @@ script = wal.lua
 description = tarantool/box, wal_mode = none
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/xlog-py/suite.ini b/test/xlog-py/suite.ini
index 18737e48f..fc75362e2 100644
--- a/test/xlog-py/suite.ini
+++ b/test/xlog-py/suite.ini
@@ -5,3 +5,4 @@ script = box.lua
 lua_libs = lua/fiber.lua lua/fifo.lua
 use_unix_sockets = True
 is_parallel = True
+pretest_clean = True
diff --git a/test/xlog/suite.ini b/test/xlog/suite.ini
index 4043f3700..06cfbb068 100644
--- a/test/xlog/suite.ini
+++ b/test/xlog/suite.ini
@@ -9,3 +9,4 @@ config = suite.cfg
 use_unix_sockets = True
 long_run = snap_io_rate.test.lua
 is_parallel = True
+pretest_clean = True
-- 
2.17.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-07  7:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04  6:11 [tarantool-patches] [PATCH v1] test: switch on pretest_clean routine avtikhon
2019-04-07  7:08 ` [tarantool-patches] " Alexander Turenko
  -- strict thread matches above, loose matches on Subject: below --
2019-04-03 10:21 [tarantool-patches] " avtikhon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox