[Tarantool-patches] [PATCH 14/19] Fix luacheck warnings in test/vinyl

sergeyb at tarantool.org sergeyb at tarantool.org
Thu Jul 16 17:11:46 MSK 2020


From: Sergey Bronnikov <sergeyb at tarantool.org>

Part of #4681

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Reviewed-by: Igor Munkin <imun at tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Co-authored-by: Igor Munkin <imun at tarantool.org>
---
 .luacheckrc                 |  2 +-
 test/vinyl/large.lua        |  3 +--
 test/vinyl/stress.lua       | 22 +++++++++++-----------
 test/vinyl/txn_proxy.lua    |  6 +++---
 test/vinyl/upgrade/fill.lua |  8 ++++----
 test/vinyl/vinyl.lua        | 17 -----------------
 6 files changed, 20 insertions(+), 38 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index fd0c5c54a..aa79622d6 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -47,7 +47,7 @@ exclude_files = {
     "test/sql/*.test.lua",
     "test/swim/*.test.lua",
     "test/var/**/*.lua",
-    "test/vinyl/**/*.lua",
+    "test/vinyl/*.test.lua",
     "test/wal_off/*.lua",
     "test/xlog/**/*.lua",
     "test/xlog-py/**/*.lua",
diff --git a/test/vinyl/large.lua b/test/vinyl/large.lua
index e10e94c1a..a997aec7e 100644
--- a/test/vinyl/large.lua
+++ b/test/vinyl/large.lua
@@ -1,5 +1,4 @@
-fiber = require('fiber')
-digest = require('digest')
+local digest = require('digest')
 
 local PAGE_SIZE = 1024
 local RANGE_SIZE = 64 * PAGE_SIZE
diff --git a/test/vinyl/stress.lua b/test/vinyl/stress.lua
index 5e8d89795..15a999393 100644
--- a/test/vinyl/stress.lua
+++ b/test/vinyl/stress.lua
@@ -33,8 +33,8 @@ local spaces = {box.space.s1, box.space.s2, box.space.s3, box.space.s4,
 local max_data_size = box.cfg.vinyl_page_size * 1.5
 
 local function t1(ch, time_limit)
-    local t1 = fiber.time()
-    while fiber.time() - t1 < time_limit do
+    local time = fiber.time()
+    while fiber.time() - time < time_limit do
         local k = math.random(10000)
         local t = math.random(80)
         local data = string.char(math.random(string.byte('Z') - string.byte('A')) + string.byte('A') - 1)
@@ -56,13 +56,13 @@ local function t1(ch, time_limit)
 end;
 
 local function t2(ch, time_limit)
-    local t1 = fiber.time()
-    while fiber.time() - t1 < time_limit do
+    local time = fiber.time()
+    while fiber.time() - time < time_limit do
         local k = math.random(10000)
         local t = math.random(16)
         local space = spaces[math.fmod(t, #spaces) + 1]
         if t < 12 then
-            local l = space:get({k})
+            space:get({k})
         else
             space:delete({k})
         end
@@ -71,9 +71,9 @@ local function t2(ch, time_limit)
 end;
 
 local function t3(ch, time_limit)
-    local t1 = fiber.time()
+    local time = fiber.time()
     local i = 0
-    while fiber.time() - t1 < time_limit do
+    while fiber.time() - time < time_limit do
         i = i + 1
         local k = math.random(10000)
         local t = math.random(20)
@@ -99,19 +99,19 @@ local function stress(time_limit)
 
     math.randomseed(os.time());
 
-    for i = 1, 6 do
+    for _ = 1, 6 do
         fiber.create(t1, ch, time_limit)
     end;
 
-    for i = 1, 6 do
+    for _ = 1, 6 do
         fiber.create(t2, ch, time_limit)
     end;
 
-    for i = 1, 4 do
+    for _ = 1, 4 do
         fiber.create(t3, ch, time_limit)
     end;
 
-    for i = 1, 16 do
+    for _ = 1, 16 do
         ch:get()
     end;
 end
diff --git a/test/vinyl/txn_proxy.lua b/test/vinyl/txn_proxy.lua
index 7a4d0b865..15b0e4add 100644
--- a/test/vinyl/txn_proxy.lua
+++ b/test/vinyl/txn_proxy.lua
@@ -1,11 +1,11 @@
--- A fiber can't use multiple transactions simultaneously;  
+-- A fiber can't use multiple transactions simultaneously;
 -- i.e. [fiber] --? [transaction] in UML parlor.
 --
 -- This module provides a simple transaction proxy facility
--- to control multiple transactions at once. A proxy executes 
+-- to control multiple transactions at once. A proxy executes
 -- statements in a worker fiber in order to overcome
 -- "one transaction per fiber" limitation.
--- 
+--
 -- Ex:
 -- proxy = require('txn_proxy').new()
 -- proxy:begin()
diff --git a/test/vinyl/upgrade/fill.lua b/test/vinyl/upgrade/fill.lua
index 547777330..0164b9316 100644
--- a/test/vinyl/upgrade/fill.lua
+++ b/test/vinyl/upgrade/fill.lua
@@ -2,11 +2,11 @@
 -- This script generates a vinyl metadata log
 -- containing all possible record types.
 --
-fiber = require 'fiber'
+local fiber = require 'fiber'
 
 box.cfg{vinyl_memory = 1024 * 1024, vinyl_timeout = 1e-9, checkpoint_count = 1}
 
-dump_trigger = box.schema.space.create('dump_trigger', {engine = 'vinyl'})
+local dump_trigger = box.schema.space.create('dump_trigger', {engine = 'vinyl'})
 dump_trigger:create_index('pk', {run_count_per_level = 1})
 
 -- Trigger dump of all indexes and wait for it to finish.
@@ -15,7 +15,7 @@ dump_trigger:create_index('pk', {run_count_per_level = 1})
 -- to trigger system-wide memory dump, it is enough to insert a
 -- huge tuple into one space.
 --
-function dump()
+local function dump()
     local pad = string.rep('x', box.cfg.vinyl_memory / 2)
     dump_trigger:replace{1, pad}
     -- Must fail due to quota timeout, but still trigger dump.
@@ -38,7 +38,7 @@ end
 --   VY_LOG_CREATE_INDEX
 --   VY_LOG_INSERT_RANGE
 --
-s = box.schema.space.create('test', {engine = 'vinyl'})
+local s = box.schema.space.create('test', {engine = 'vinyl'})
 s:create_index('i1', {parts = {1, 'unsigned'}, run_count_per_level = 1})
 s:create_index('i2', {parts = {2, 'string'},   run_count_per_level = 2})
 
diff --git a/test/vinyl/vinyl.lua b/test/vinyl/vinyl.lua
index 31307f4bc..1d313b4e4 100644
--- a/test/vinyl/vinyl.lua
+++ b/test/vinyl/vinyl.lua
@@ -15,21 +15,4 @@ box.cfg {
     vinyl_max_tuple_size = 1024 * 1024 * 6,
 }
 
-function box_info_sort(data)
-    if type(data)~='table' then
-        return data
-    end
-    local keys = {}
-    for k in pairs(data) do
-        table.insert(keys, k)
-    end
-    table.sort(keys)
-    local result = {}
-    for _,k in pairs(keys) do
-        local v = data[k]
-        table.insert(result, {[k] = box_info_sort(v) })
-    end
-    return result
-end
-
 require('console').listen(os.getenv('ADMIN'))
-- 
2.26.2



More information about the Tarantool-patches mailing list