[Tarantool-patches] [PATCH v1 04/12] test: enable cleaning of a test environment

Alexander V. Tikhonov avtikhon at tarantool.org
Tue Nov 26 09:21:40 MSK 2019


From: Alexander Turenko <alexander.turenko at tarantool.org>

This commit enables pretest_clean test-run option on 'core = tarantool'
test suites with Lua tests and 'core = app' test suites. Consider #4094
for an example of a problem that is eliminated by this option.

For 'core = tarantool': this option drops non-system spaces, drops data
in system spaces and global variables to the initial state, unloads
packages except build-in ones.

For 'core = app': this option deletes xlog and snap files before run a
test.

test-run doesn't remove global variables that are listed in the
'protected_globals' global variable. Use it for, say, functions that are
defined in an instance file and called from tests.

Consider test-run/README.md for the information how exactly the option
works.

Removed unused cfg_filter() function from test/engine/box.lua.

Fixes #4094.

(cherry picked from commit 7474c14e9cdb4bae3ab073d375aa11e628e13aa5)
---
 test/app-tap/suite.ini     |  1 +
 test/app/suite.ini         |  1 +
 test/box-tap/suite.ini     |  1 +
 test/box/box.lua           |  4 +++-
 test/box/suite.ini         |  1 +
 test/engine/box.lua        | 21 ---------------------
 test/engine/suite.ini      |  1 +
 test/engine_long/suite.ini |  1 +
 test/engine_long/suite.lua |  5 +++--
 test/replication/suite.ini |  1 +
 test/vinyl/suite.ini       |  1 +
 test/wal_off/suite.ini     |  1 +
 test/xlog/suite.ini        |  1 +
 13 files changed, 16 insertions(+), 24 deletions(-)

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 134cba6d8..79432e29a 100644
--- a/test/app/suite.ini
+++ b/test/app/suite.ini
@@ -6,4 +6,5 @@ lua_libs = lua/fiber.lua
 use_unix_sockets = True
 use_unix_sockets_iproto = True
 is_parallel = True
+pretest_clean = True
 fragile = socket.test.lua ; gh-4426 gh-4451
diff --git a/test/box-tap/suite.ini b/test/box-tap/suite.ini
index d00e93e72..8d9e32d3f 100644
--- a/test/box-tap/suite.ini
+++ b/test/box-tap/suite.ini
@@ -2,5 +2,6 @@
 core = app
 description = Database tests with #! using TAP
 is_parallel = True
+pretest_clean = True
 fragile = cfg.test.lua     ; gh-4344
           key_def.test.lua ; gh-4252
diff --git a/test/box/box.lua b/test/box/box.lua
index b3b10ffd4..2a8e0e4fa 100644
--- a/test/box/box.lua
+++ b/test/box/box.lua
@@ -29,7 +29,7 @@ function cfg_filter(data)
     return result
 end
 
-function compare(a,b)
+local function compare(a,b)
     return a[1] < b[1]
 end
 
@@ -37,3 +37,5 @@ function sorted(data)
     table.sort(data, compare)
     return data
 end
+
+_G.protected_globals = {'cfg_filter', 'sorted'}
diff --git a/test/box/suite.ini b/test/box/suite.ini
index d636c45b3..6e8508188 100644
--- a/test/box/suite.ini
+++ b/test/box/suite.ini
@@ -8,6 +8,7 @@ lua_libs = lua/fifo.lua lua/utils.lua lua/bitset.lua lua/index_random_test.lua l
 use_unix_sockets = True
 use_unix_sockets_iproto = True
 is_parallel = True
+pretest_clean = True
 fragile = bitset.test.lua      ; gh-4095
           func_reload.test.lua ; gh-4425
           function1.test.lua   ; gh-4199
diff --git a/test/engine/box.lua b/test/engine/box.lua
index c68bd626c..b1a379daf 100644
--- a/test/engine/box.lua
+++ b/test/engine/box.lua
@@ -21,24 +21,3 @@ box.cfg{
 }
 
 require('console').listen(os.getenv('ADMIN'))
-
-_to_exclude = {
-    'pid_file', 'log', 'vinyl_dir',
-    'memtx_dir', 'wal_dir',
-    'memtx_min_tuple_size', 'memtx_max_tuple_size'
-}
-
-_exclude = {}
-for _, f in pairs(_to_exclude) do
-    _exclude[f] = 1
-end
-
-function cfg_filter(data)
-    local result = {}
-    for field, val in pairs(data) do
-        if _exclude[field] == nil then
-            result[field] = val
-        end
-    end
-    return result
-end
diff --git a/test/engine/suite.ini b/test/engine/suite.ini
index 7edd49ddc..7c260eea0 100644
--- a/test/engine/suite.ini
+++ b/test/engine/suite.ini
@@ -9,5 +9,6 @@ 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
 fragile = ddl.test.lua         ; gh-4353
           recover_wal.test.lua ; gh-3767
diff --git a/test/engine_long/suite.ini b/test/engine_long/suite.ini
index 0ebb7c9f8..97d869042 100644
--- a/test/engine_long/suite.ini
+++ b/test/engine_long/suite.ini
@@ -8,3 +8,4 @@ use_unix_sockets = True
 use_unix_sockets_iproto = 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..9ac2bff9f 100644
--- a/test/engine_long/suite.lua
+++ b/test/engine_long/suite.lua
@@ -1,5 +1,4 @@
-
-function string_function()
+local function string_function()
     local random_number
     local random_string
     random_string = ""
@@ -107,3 +106,5 @@ function delete_insert(engine_name, iterations)
     box.space.tester:drop()
     return {counter, string_value_2}
 end
+
+_G.protected_globals = {'delete_replace_update', 'delete_insert'}
diff --git a/test/replication/suite.ini b/test/replication/suite.ini
index d817f81a8..15dd05d25 100644
--- a/test/replication/suite.ini
+++ b/test/replication/suite.ini
@@ -10,6 +10,7 @@ use_unix_sockets = True
 use_unix_sockets_iproto = True
 long_run = prune.test.lua
 is_parallel = True
+pretest_clean = True
 fragile = errinj.test.lua            ; gh-3870
           join_vclock.test.lua       ; gh-4160
           long_row_timeout.test.lua  ; gh-4351
diff --git a/test/vinyl/suite.ini b/test/vinyl/suite.ini
index 90e326b46..1417d7156 100644
--- a/test/vinyl/suite.ini
+++ b/test/vinyl/suite.ini
@@ -9,6 +9,7 @@ use_unix_sockets = True
 use_unix_sockets_iproto = 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
+pretest_clean = True
 fragile = errinj.test.lua             ; gh-4346
           select_consistency.test.lua ; gh-4385
           throttle.test.lua           ; gh-4168
diff --git a/test/wal_off/suite.ini b/test/wal_off/suite.ini
index 10a02e999..14f531df7 100644
--- a/test/wal_off/suite.ini
+++ b/test/wal_off/suite.ini
@@ -5,4 +5,5 @@ description = tarantool/box, wal_mode = none
 use_unix_sockets = True
 use_unix_sockets_iproto = True
 is_parallel = True
+pretest_clean = True
 fragile = iterator_lt_gt.test.lua ; gh-3925
diff --git a/test/xlog/suite.ini b/test/xlog/suite.ini
index df54537ff..babf625ae 100644
--- a/test/xlog/suite.ini
+++ b/test/xlog/suite.ini
@@ -10,3 +10,4 @@ use_unix_sockets = True
 use_unix_sockets_iproto = True
 long_run = snap_io_rate.test.lua
 is_parallel = True
+pretest_clean = True
-- 
2.17.1



More information about the Tarantool-patches mailing list