From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 49EBC6465D; Thu, 21 Jan 2021 17:48:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 49EBC6465D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611240482; bh=Cq7BnsET7OHG5aMcg4L5Bu3Goe0nQ71V0DWsJ4Zxfhg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=hGN019W2TPgGv+A2wBmqBM8FuoxZP/Lpj8dlLqXhMIUrBRXZ2+SAPF5zIFmOSiUT9 Ckknhx9jmMZcIi8GnkpurK7COtRvnvHRv/vtunBZPwb0d/8p/PPqGRvxNoXEimll4b 2ny400+uNQXR3+FhSbTB2cprMECn9lt/zBqBAg3U= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id CB00ECC309 for ; Thu, 21 Jan 2021 17:47:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CB00ECC309 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1l2bFD-0004d3-UL; Thu, 21 Jan 2021 17:47:32 +0300 To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org Date: Thu, 21 Jan 2021 17:47:19 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9FAB20BF8F0759036E9D016CAEA9DE5625EC7EDBD8999FF7A182A05F538085040E7C9FF77DEA69699ED40836B2E2F7E422B63CBCEF4CB9318D745C274568017F7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE788AD3E9728F968ABEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CB87E27B59CE093D8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FCBF320FA984F2B761A1D7DAFB0D429FB2548AA7563FC1354D389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6D082881546D93491CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FCF8E90A1DD246484F75ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4931B544F03EFBC4D571337B709B3801B10C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F05F538519369F3743B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C2549B6A8B600A67A118D32601A1F8FCCFDC7C53B209213A69C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF6EA1BA7CA28B4A74699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B1FF97F6D0959A20DED1860EDDEC5989472E7C80710543D2F40D2092EBC15AEAAA4D6ADA51D79781D7E09C32AA3244C2E75E57CAEE2F0E03FB1F4CCF86F2E8024AF4FAF06DA24FD927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojYT//mZRaUegB34wJFzBDwg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822B484DD14B69BE6AB38590309C4958D43DD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v7 1/2] test: fix luacheck warnings in test/replication X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: sergeyb@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Sergey Bronnikov Closes #5461 Reviewed-by: Vladislav Shpilevoy Reviewed-by: Igor Munkin Co-authored-by: Vladislav Shpilevoy Co-authored-by: Igor Munkin --- .luacheckrc | 8 ++++- test/replication/lua/fast_replica.lua | 33 +++++++++++---------- test/replication/lua/rlimit.lua | 2 +- test/replication/master.lua | 2 +- test/replication/master_quorum.lua | 4 +-- test/replication/on_replace.lua | 6 ++-- test/replication/replica.lua | 4 +-- test/replication/replica_on_schema_init.lua | 4 +-- test/replication/replica_quorum.lua | 4 +-- 9 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index b427f6475..c8c54776e 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -36,7 +36,7 @@ exclude_files = { "test/engine/**/*.lua", "test/engine_long/**/*.lua", "test/luajit-tap/**/*.lua", - "test/replication/**/*.lua", + "test/replication/*.test.lua", "test/replication-py/**/*.lua", "test/sql/**/*.lua", "test/swim/**/*.lua", @@ -124,3 +124,9 @@ files["test/box-tap/extended_error.test.lua"] = { "forbidden_function", }, } +files["test/replication/replica_quorum.lua"] = { + globals = { + "INSTANCE_URI", + "nonexistent_uri", + }, +} diff --git a/test/replication/lua/fast_replica.lua b/test/replication/lua/fast_replica.lua index 8c772c41f..1e8603a3c 100644 --- a/test/replication/lua/fast_replica.lua +++ b/test/replication/lua/fast_replica.lua @@ -1,5 +1,5 @@ -function join(inspector, n) +local function join(inspector, n) local path = os.getenv('TARANTOOL_SRC_DIR') for i=1,n do local rid = tostring(i) @@ -7,13 +7,14 @@ function join(inspector, n) os.execute('cp '..path..'/test/replication/replica.lua ./tmp/replica'..rid..'.lua') os.execute('chmod +x ./tmp/replica'..rid..'.lua') local out_dir = box.cfg.wal_dir - inspector:cmd("create server replica"..rid.." with rpl_master=default, script='"..out_dir.."/../tmp/replica"..rid..".lua'") + inspector:cmd("create server replica"..rid.." with rpl_master=default, script='" + ..out_dir.."/../tmp/replica"..rid..".lua'") inspector:cmd("start server replica"..rid) end end -function call_all(callback) +local function call_all(callback) local all = box.space._cluster:select{} for _, tuple in pairs(all) do local id = tuple[1] @@ -23,54 +24,54 @@ function call_all(callback) end end -function unregister(inspector, id) +local function unregister(inspector, id) -- luacheck: no unused args box.space._cluster:delete{id} end -function start(inspector, id) +local function start(inspector, id) inspector:cmd('start server replica'..tostring(id - 1)) end -function stop(inspector, id) +local function stop(inspector, id) inspector:cmd('stop server replica'..tostring(id - 1)) end -function wait(inspector, id) +local function wait(inspector, id) inspector:wait_lsn('replica'..tostring(id - 1), 'default') end -function delete(inspector, id) +local function delete(inspector, id) inspector:cmd('stop server replica'..tostring(id - 1)) inspector:cmd('delete server replica'..tostring(id - 1)) end -function drop(inspector, id) +local function drop(inspector, id) unregister(inspector, id) delete(inspector, id) end -function start_all(inspector) +local function start_all(inspector) call_all(function (id) start(inspector, id) end) end -function stop_all(inspector) +local function stop_all(inspector) call_all(function (id) stop(inspector, id) end) end -function wait_all(inspector) +local function wait_all(inspector) call_all(function (id) wait(inspector, id) end) end -function drop_all(inspector) +local function drop_all(inspector) call_all(function (id) drop(inspector, id) end) end -function vclock_diff(left, right) +local function vclock_diff(left, right) local diff = 0 - for id, lsn in ipairs(left) do + for id, lsn in ipairs(left) do -- luacheck: no unused diff = diff + (right[id] or 0) - left[id] end - for id, lsn in ipairs(right) do + for id, lsn in ipairs(right) do -- luacheck: no unused if left[id] == nil then diff = diff + right[id] end diff --git a/test/replication/lua/rlimit.lua b/test/replication/lua/rlimit.lua index de9f86a35..1bd9e333f 100644 --- a/test/replication/lua/rlimit.lua +++ b/test/replication/lua/rlimit.lua @@ -1,5 +1,5 @@ -ffi = require('ffi') +local ffi = require('ffi') pcall(ffi.cdef, [[ typedef long rlim_t; struct rlimit { diff --git a/test/replication/master.lua b/test/replication/master.lua index e924b5495..b43bafd54 100644 --- a/test/replication/master.lua +++ b/test/replication/master.lua @@ -1,5 +1,5 @@ #!/usr/bin/env tarantool -os = require('os') +local os = require('os') box.cfg({ listen = os.getenv("LISTEN"), memtx_memory = 107374182, diff --git a/test/replication/master_quorum.lua b/test/replication/master_quorum.lua index 20f161cc0..8b7ddc5eb 100644 --- a/test/replication/master_quorum.lua +++ b/test/replication/master_quorum.lua @@ -26,8 +26,8 @@ box.cfg({ replication_timeout = TIMEOUT; }) -test_run = require('test_run').new() -engine = test_run:get_cfg('engine') +local test_run = require('test_run').new() +local engine = test_run:get_cfg('engine') box.once("bootstrap", function() box.schema.user.grant("guest", 'replication') diff --git a/test/replication/on_replace.lua b/test/replication/on_replace.lua index 71e63d3f9..df65832c4 100644 --- a/test/replication/on_replace.lua +++ b/test/replication/on_replace.lua @@ -15,9 +15,9 @@ end -- start console first require('console').listen(os.getenv('ADMIN')) -env = require('test_run') -test_run = env.new() -engine = test_run:get_cfg('engine') +local env = require('test_run') +local test_run = env.new() +local engine = test_run:get_cfg('engine') box.cfg({ listen = instance_uri(INSTANCE_ID); diff --git a/test/replication/replica.lua b/test/replication/replica.lua index 76949a568..d53671735 100644 --- a/test/replication/replica.lua +++ b/test/replication/replica.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool -repl_include_self = arg[1] and arg[1] == 'true' or false -repl_list = nil +local repl_include_self = arg[1] and arg[1] == 'true' or false +local repl_list if repl_include_self then repl_list = {os.getenv("MASTER"), os.getenv("LISTEN")} diff --git a/test/replication/replica_on_schema_init.lua b/test/replication/replica_on_schema_init.lua index 8a221681b..eb5a5c992 100644 --- a/test/replication/replica_on_schema_init.lua +++ b/test/replication/replica_on_schema_init.lua @@ -1,12 +1,12 @@ #!/usr/bin/env tarantool -function trig_local(old, new) +local function trig_local(old, new) -- luacheck: no unused args if new and new[3] == 'test_local' and new[6]['group_id'] ~= 1 then return new:update{{'=', 6, {group_id = 1}}} end end -function trig_engine(old, new) +local function trig_engine(old, new) -- luacheck: no unused args if new and new[3] == 'test_engine' and new[4] ~= 'vinyl' then return new:update{{'=', 4, 'vinyl'}} end diff --git a/test/replication/replica_quorum.lua b/test/replication/replica_quorum.lua index 8dfad8b6e..80886e1c4 100644 --- a/test/replication/replica_quorum.lua +++ b/test/replication/replica_quorum.lua @@ -5,9 +5,9 @@ local SOCKET_DIR = require('fio').cwd() local QUORUM = tonumber(arg[1]) local TIMEOUT = arg[2] and tonumber(arg[2]) or 0.1 local CONNECT_TIMEOUT = arg[3] and tonumber(arg[3]) or 10 -INSTANCE_URI = SOCKET_DIR .. '/replica_quorum.sock' +INSTANCE_URI = SOCKET_DIR .. '/replica_quorum.sock' -- luacheck: ignore -function nonexistent_uri(id) +function nonexistent_uri(id) -- luacheck: ignore return SOCKET_DIR .. '/replica_quorum' .. (1000 + id) .. '.sock' end -- 2.25.1