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 813AA6EC7F; Fri, 23 Jul 2021 14:11:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 813AA6EC7F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627038663; bh=DaiwbafSLoOalzCL7wPmQKiesMW6dIJb7Z14XS4zlU0=; 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=SLvGUYTm5UHT7WubgHSD5TmfPxav/cMUFKgVOaBG2vyg6D9tInKwqC5T9NG6Bf06B PaKLm9/vbXhk3f4z6TSsHmwmYIV8axtOzaD/Mah2M02aE2OjDgCpI3KQA+wkAUjbRz ud2YZ3EAdqasfGbQSQXDj1UU7GNr2omSz2faapns= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 700236F3C3 for ; Fri, 23 Jul 2021 14:07:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 700236F3C3 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1m6t1j-0004dl-Uw; Fri, 23 Jul 2021 14:07:36 +0300 To: tarantool-patches@dev.tarantool.org Date: Fri, 23 Jul 2021 14:07:17 +0300 Message-Id: <9faa7f22d3f267c09262d178042b88b5c04f7edd.1627024646.git.vdavydov@tarantool.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-174C08C4: 5188C02AEC42908C481ED7ADC579193296BBA28369E3F2D2713F3D5F7D406D31BCF678C7329BA986 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD941C43E597735A9C3D3726AD0AC8C7907896201F0AD2BBAE8182A05F538085040ECBF6B9C7E34500965F882499F2C367C6F6587294834146CBD85B9CC454A1FE0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72FFC9A718DD021A9EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D08E1E5B2BD3D3B78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8558C6A828DAE7CCAF020449A9ECDCB2F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6753C3A5E0A5AB5B7089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 8BD88D57C5CADBC8B2710865C3867510450EA3B85B19CCCD05F95F36B1DCCA417EBAD7E00A735C6D7A059B4337C5CCEC3A75A470526870D743E34F4BAF9A561B16EB5DE968479BF52965CEFAE0DF35E316CF367659D795C0D510B2CAAF97A1FB6774DC0CEEA7072C9C2B6934AE262D3EE7EAB7254005DCEDBA857097D985AEC5 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B222596F62B8FA973EF2228AE342454D5E28CE9408A0C2FFE4121DEC2CBB4763871C63497A5F1FE1D7E09C32AA3244C6806229D3D79BC002A3D7E57134C049FE8FBBEFAE1C4874C729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXiEX0g4jkpDtTFCOiSuKvvV X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DC1733388C3BAC674CDF6A75C311EBB23274CEFED1673C562683ABF942079399BFB559BB5D741EB966A65DFF43FF7BE03240331F90058701C67EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 07/20] net.box: use integer id instead of method name 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: Vladimir Davydov via Tarantool-patches Reply-To: Vladimir Davydov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" We need this to port performance-critical parts of net.box to C, where it's easier and more efficient to look up encoders/decoders by integer id rather than by string method name. --- src/box/lua/net_box.lua | 158 +++++++++++------- test/box/access.result | 24 ++- test/box/access.test.lua | 20 ++- ...net.box_console_connections_gh-2677.result | 2 +- ...t.box_console_connections_gh-2677.test.lua | 2 +- .../net.box_incorrect_iterator_gh-841.result | 9 +- ...net.box_incorrect_iterator_gh-841.test.lua | 9 +- test/box/net.box_iproto_hangs_gh-3464.result | 2 +- .../box/net.box_iproto_hangs_gh-3464.test.lua | 2 +- .../net.box_long-poll_input_gh-3400.result | 13 +- .../net.box_long-poll_input_gh-3400.test.lua | 8 +- 11 files changed, 161 insertions(+), 88 deletions(-) diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index 0ac0c0375a45..76cfd40e3bee 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -51,6 +51,27 @@ local E_TIMEOUT = box.error.TIMEOUT local E_PROC_LUA = box.error.PROC_LUA local E_NO_SUCH_SPACE = box.error.NO_SUCH_SPACE +-- Method types used internally by net.box. +local M_PING = 0 +local M_CALL_16 = 1 +local M_CALL_17 = 2 +local M_EVAL = 3 +local M_INSERT = 4 +local M_REPLACE = 5 +local M_DELETE = 6 +local M_UPDATE = 7 +local M_UPSERT = 8 +local M_SELECT = 9 +local M_EXECUTE = 10 +local M_PREPARE = 11 +local M_UNPREPARE = 12 +local M_GET = 13 +local M_MIN = 14 +local M_MAX = 15 +local M_COUNT = 16 +-- Injects raw data into connection. Used by console and tests. +local M_INJECT = 17 + ffi.cdef[[ struct error * error_unpack_unsafe(const char **data); @@ -91,25 +112,24 @@ local function version_at_least(peer_version_id, major, minor, patch) end local method_encoder = { - ping = internal.encode_ping, - call_16 = internal.encode_call_16, - call_17 = internal.encode_call, - eval = internal.encode_eval, - insert = internal.encode_insert, - replace = internal.encode_replace, - delete = internal.encode_delete, - update = internal.encode_update, - upsert = internal.encode_upsert, - select = internal.encode_select, - execute = internal.encode_execute, - prepare = internal.encode_prepare, - unprepare = internal.encode_prepare, - get = internal.encode_select, - min = internal.encode_select, - max = internal.encode_select, - count = internal.encode_call, - -- inject raw data into connection, used by console and tests - inject = function(buf, id, bytes) -- luacheck: no unused args + [M_PING] = internal.encode_ping, + [M_CALL_16] = internal.encode_call_16, + [M_CALL_17] = internal.encode_call, + [M_EVAL] = internal.encode_eval, + [M_INSERT] = internal.encode_insert, + [M_REPLACE] = internal.encode_replace, + [M_DELETE] = internal.encode_delete, + [M_UPDATE] = internal.encode_update, + [M_UPSERT] = internal.encode_upsert, + [M_SELECT] = internal.encode_select, + [M_EXECUTE] = internal.encode_execute, + [M_PREPARE] = internal.encode_prepare, + [M_UNPREPARE] = internal.encode_prepare, + [M_GET] = internal.encode_select, + [M_MIN] = internal.encode_select, + [M_MAX] = internal.encode_select, + [M_COUNT] = internal.encode_call, + [M_INJECT] = function(buf, id, bytes) -- luacheck: no unused args local ptr = buf:reserve(#bytes) ffi.copy(ptr, bytes, #bytes) buf.wpos = ptr + #bytes @@ -117,24 +137,24 @@ local method_encoder = { } local method_decoder = { - ping = decode_nil, - call_16 = internal.decode_select, - call_17 = decode_data, - eval = decode_data, - insert = decode_tuple, - replace = decode_tuple, - delete = decode_tuple, - update = decode_tuple, - upsert = decode_nil, - select = internal.decode_select, - execute = internal.decode_execute, - prepare = internal.decode_prepare, - unprepare = decode_nil, - get = decode_tuple, - min = decode_tuple, - max = decode_tuple, - count = decode_count, - inject = decode_data, + [M_PING] = decode_nil, + [M_CALL_16] = internal.decode_select, + [M_CALL_17] = decode_data, + [M_EVAL] = decode_data, + [M_INSERT] = decode_tuple, + [M_REPLACE] = decode_tuple, + [M_DELETE] = decode_tuple, + [M_UPDATE] = decode_tuple, + [M_UPSERT] = decode_nil, + [M_SELECT] = internal.decode_select, + [M_EXECUTE] = internal.decode_execute, + [M_PREPARE] = internal.decode_prepare, + [M_UNPREPARE] = decode_nil, + [M_GET] = decode_tuple, + [M_MIN] = decode_tuple, + [M_MAX] = decode_tuple, + [M_COUNT] = decode_count, + [M_INJECT] = decode_data, } local function decode_error(raw_data) @@ -1208,7 +1228,7 @@ end function remote_methods:ping(opts) check_remote_arg(self, 'ping') - return (pcall(self._request, self, 'ping', opts)) + return (pcall(self._request, self, M_PING, opts)) end function remote_methods:reload_schema() @@ -1219,14 +1239,14 @@ end -- @deprecated since 1.7.4 function remote_methods:call_16(func_name, ...) check_remote_arg(self, 'call') - return (self:_request('call_16', nil, nil, tostring(func_name), {...})) + return (self:_request(M_CALL_16, nil, nil, tostring(func_name), {...})) end function remote_methods:call(func_name, args, opts) check_remote_arg(self, 'call') check_call_args(args) args = args or {} - local res = self:_request('call_17', opts, nil, tostring(func_name), args) + local res = self:_request(M_CALL_17, opts, nil, tostring(func_name), args) if type(res) ~= 'table' or opts and opts.is_async then return res end @@ -1236,14 +1256,14 @@ end -- @deprecated since 1.7.4 function remote_methods:eval_16(code, ...) check_remote_arg(self, 'eval') - return unpack((self:_request('eval', nil, nil, code, {...}))) + return unpack((self:_request(M_EVAL, nil, nil, code, {...}))) end function remote_methods:eval(code, args, opts) check_remote_arg(self, 'eval') check_eval_args(args) args = args or {} - local res = self:_request('eval', opts, nil, code, args) + local res = self:_request(M_EVAL, opts, nil, code, args) if type(res) ~= 'table' or opts and opts.is_async then return res end @@ -1255,7 +1275,7 @@ function remote_methods:execute(query, parameters, sql_opts, netbox_opts) if sql_opts ~= nil then box.error(box.error.UNSUPPORTED, "execute", "options") end - return self:_request('execute', netbox_opts, nil, query, parameters or {}, + return self:_request(M_EXECUTE, netbox_opts, nil, query, parameters or {}, sql_opts or {}) end @@ -1267,7 +1287,7 @@ function remote_methods:prepare(query, parameters, sql_opts, netbox_opts) -- lua if sql_opts ~= nil then box.error(box.error.UNSUPPORTED, "prepare", "options") end - return self:_request('prepare', netbox_opts, nil, query) + return self:_request(M_PREPARE, netbox_opts, nil, query) end function remote_methods:unprepare(query, parameters, sql_opts, netbox_opts) @@ -1278,7 +1298,7 @@ function remote_methods:unprepare(query, parameters, sql_opts, netbox_opts) if sql_opts ~= nil then box.error(box.error.UNSUPPORTED, "unprepare", "options") end - return self:_request('unprepare', netbox_opts, nil, query, parameters or {}, + return self:_request(M_UNPREPARE, netbox_opts, nil, query, parameters or {}, sql_opts or {}) end @@ -1436,11 +1456,11 @@ function console_methods:eval(line, timeout) end if self.protocol == 'Binary' then local loader = 'return require("console").eval(...)' - res, err = pr(timeout, nil, false, 'eval', nil, nil, nil, loader, + res, err = pr(timeout, nil, false, M_EVAL, nil, nil, nil, loader, {line}) else assert(self.protocol == 'Lua console') - res, err = pr(timeout, nil, false, 'inject', nil, nil, nil, + res, err = pr(timeout, nil, false, M_INJECT, nil, nil, nil, line..'$EOF$\n') end if err then @@ -1460,12 +1480,14 @@ space_metatable = function(remote) function methods:insert(tuple, opts) check_space_arg(self, 'insert') - return remote:_request('insert', opts, self._format_cdata, self.id, tuple) + return remote:_request(M_INSERT, opts, self._format_cdata, self.id, + tuple) end function methods:replace(tuple, opts) check_space_arg(self, 'replace') - return remote:_request('replace', opts, self._format_cdata, self.id, tuple) + return remote:_request(M_REPLACE, opts, self._format_cdata, self.id, + tuple) end function methods:select(key, opts) @@ -1485,8 +1507,8 @@ space_metatable = function(remote) function methods:upsert(key, oplist, opts) check_space_arg(self, 'upsert') - return nothing_or_data(remote:_request('upsert', opts, nil, self.id, key, - oplist)) + return nothing_or_data(remote:_request(M_UPSERT, opts, nil, self.id, + key, oplist)) end function methods:get(key, opts) @@ -1515,7 +1537,7 @@ index_metatable = function(remote) local iterator = check_iterator_type(opts, key_is_nil) local offset = tonumber(opts and opts.offset) or 0 local limit = tonumber(opts and opts.limit) or 0xFFFFFFFF - return (remote:_request('select', opts, self.space._format_cdata, + return (remote:_request(M_SELECT, opts, self.space._format_cdata, self.space.id, self.id, iterator, offset, limit, key)) end @@ -1525,7 +1547,7 @@ index_metatable = function(remote) if opts and opts.buffer then error("index:get() doesn't support `buffer` argument") end - return nothing_or_data(remote:_request('get', opts, + return nothing_or_data(remote:_request(M_GET, opts, self.space._format_cdata, self.space.id, self.id, box.index.EQ, 0, 2, key)) @@ -1536,7 +1558,7 @@ index_metatable = function(remote) if opts and opts.buffer then error("index:min() doesn't support `buffer` argument") end - return nothing_or_data(remote:_request('min', opts, + return nothing_or_data(remote:_request(M_MIN, opts, self.space._format_cdata, self.space.id, self.id, box.index.GE, 0, 1, key)) @@ -1547,7 +1569,7 @@ index_metatable = function(remote) if opts and opts.buffer then error("index:max() doesn't support `buffer` argument") end - return nothing_or_data(remote:_request('max', opts, + return nothing_or_data(remote:_request(M_MAX, opts, self.space._format_cdata, self.space.id, self.id, box.index.LE, 0, 1, key)) @@ -1560,19 +1582,19 @@ index_metatable = function(remote) end local code = string.format('box.space.%s.index.%s:count', self.space.name, self.name) - return remote:_request('count', opts, nil, code, { key, opts }) + return remote:_request(M_COUNT, opts, nil, code, { key, opts }) end function methods:delete(key, opts) check_index_arg(self, 'delete') - return nothing_or_data(remote:_request('delete', opts, + return nothing_or_data(remote:_request(M_DELETE, opts, self.space._format_cdata, self.space.id, self.id, key)) end function methods:update(key, oplist, opts) check_index_arg(self, 'update') - return nothing_or_data(remote:_request('update', opts, + return nothing_or_data(remote:_request(M_UPDATE, opts, self.space._format_cdata, self.space.id, self.id, key, oplist)) @@ -1587,6 +1609,26 @@ local this_module = { new = connect, -- Tarantool < 1.7.1 compatibility, wrap = wrap, establish_connection = establish_connection, + _method = { -- for tests + ping = M_PING, + call_16 = M_CALL_16, + call_17 = M_CALL_17, + eval = M_EVAL, + insert = M_INSERT, + replace = M_REPLACE, + delete = M_DELETE, + update = M_UPDATE, + upsert = M_UPSERT, + select = M_SELECT, + execute = M_EXECUTE, + prepare = M_PREPARE, + unprepare = M_UNPREPARE, + get = M_GET, + min = M_MIN, + max = M_MAX, + count = M_COUNT, + inject = M_INJECT, + } } function this_module.timeout(timeout, ...) diff --git a/test/box/access.result b/test/box/access.result index 1a8730f1a2d9..712cd68f84fd 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -4,6 +4,9 @@ env = require('test_run') test_run = env.new() --- ... +net = require('net.box') +--- +... session = box.session --- ... @@ -304,7 +307,7 @@ LISTEN ~= nil --- - true ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service) +c = net.connect(LISTEN.host, LISTEN.service) --- ... c:call('nosuchfunction') @@ -350,6 +353,9 @@ box.snapshot() - ok ... test_run:cmd('restart server default') +net = require('net.box') +--- +... box.schema.user.drop('testus') --- ... @@ -899,18 +905,18 @@ box.schema.func.drop(name) LISTEN = require('uri').parse(box.cfg.listen) --- ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service) +c = net.connect(LISTEN.host, LISTEN.service) --- ... -c:_request("select", nil, nil, 1, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c:_request(net._method.select, nil, nil, 1, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) --- - error: Space '1' does not exist ... -c:_request("select", nil, nil, 65537, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c:_request(net._method.select, nil, nil, 65537, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) --- - error: Space '65537' does not exist ... -c:_request("select", nil, nil, 4294967295, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c:_request(net._method.select, nil, nil, 4294967295, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) --- - error: Space '4294967295' does not exist ... @@ -1124,7 +1130,7 @@ session.su("test") --- - error: Session access to universe '' is denied for user 'test' ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test", password="pass"}) --- ... c.state @@ -1320,7 +1326,7 @@ euid, auid box.session.su("admin") --- ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) --- ... function func() end @@ -1379,7 +1385,7 @@ box.session.su("admin") box.schema.user.revoke("test_user", "session", "universe") --- ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) --- ... obj_type, obj_name, op_type @@ -1834,7 +1840,7 @@ seq = box.schema.sequence.create("test") box.schema.func.create("func") --- ... -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user='tester', password = '123'}) +c = net.connect(LISTEN.host, LISTEN.service, {user='tester', password = '123'}) --- ... box.session.su("tester", s.select, s) diff --git a/test/box/access.test.lua b/test/box/access.test.lua index 2bf772b7b38e..6060475d1426 100644 --- a/test/box/access.test.lua +++ b/test/box/access.test.lua @@ -1,5 +1,6 @@ env = require('test_run') test_run = env.new() +net = require('net.box') session = box.session -- user id for a Lua session is admin - 1 @@ -138,7 +139,7 @@ box.schema.user.drop('Петя_Иванов') -- gh-300: misleading error message if a function does not exist LISTEN = require('uri').parse(box.cfg.listen) LISTEN ~= nil -c = (require 'net.box').connect(LISTEN.host, LISTEN.service) +c = net.connect(LISTEN.host, LISTEN.service) c:call('nosuchfunction') function nosuchfunction() end @@ -155,6 +156,7 @@ box.schema.user.grant('testus', 'write', 'space', 'admin_space') s:drop() box.snapshot() test_run:cmd('restart server default') +net = require('net.box') box.schema.user.drop('testus') -- ------------------------------------------------------------ -- a test case for gh-289 @@ -348,10 +350,10 @@ box.schema.func.drop(name) -- Verify that when trying to access a non-existing or -- very large space id, no crash occurs. LISTEN = require('uri').parse(box.cfg.listen) -c = (require 'net.box').connect(LISTEN.host, LISTEN.service) -c:_request("select", nil, nil, 1, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) -c:_request("select", nil, nil, 65537, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) -c:_request("select", nil, nil, 4294967295, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c = net.connect(LISTEN.host, LISTEN.service) +c:_request(net._method.select, nil, nil, 1, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c:_request(net._method.select, nil, nil, 65537, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) +c:_request(net._method.select, nil, nil, 4294967295, box.index.EQ, 0, 0, 0xFFFFFFFF, {}) c:close() session = box.session @@ -429,7 +431,7 @@ box.schema.user.disable("test") -- test double disable is a no op box.schema.user.disable("test") session.su("test") -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test", password="pass"}) c.state c.error @@ -499,7 +501,7 @@ seq:set(1) obj_type, obj_name, op_type euid, auid box.session.su("admin") -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) function func() end st, e = pcall(c.call, c, func) obj_type, op_type @@ -514,7 +516,7 @@ obj_type, obj_name, op_type euid, auid box.session.su("admin") box.schema.user.revoke("test_user", "session", "universe") -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) +c = net.connect(LISTEN.host, LISTEN.service, {user="test_user", password="pass"}) obj_type, obj_name, op_type euid, auid box.session.on_access_denied(nil, access_denied_trigger) @@ -710,7 +712,7 @@ s = box.schema.space.create("test") _ = s:create_index("primary", {parts={1, "unsigned"}}) seq = box.schema.sequence.create("test") box.schema.func.create("func") -c = (require 'net.box').connect(LISTEN.host, LISTEN.service, {user='tester', password = '123'}) +c = net.connect(LISTEN.host, LISTEN.service, {user='tester', password = '123'}) box.session.su("tester", s.select, s) box.session.su("tester", seq.set, seq, 1) diff --git a/test/box/net.box_console_connections_gh-2677.result b/test/box/net.box_console_connections_gh-2677.result index c9116e5d487a..f45aa0b56646 100644 --- a/test/box/net.box_console_connections_gh-2677.result +++ b/test/box/net.box_console_connections_gh-2677.result @@ -74,7 +74,7 @@ c.space.test:delete{1} -- -- Break a connection to test reconnect_after. -- -_ = c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') +_ = c._transport.perform_request(nil, nil, false, net._method.inject, nil, nil, nil, '\x80') --- ... while not c:is_connected() do fiber.sleep(0.01) end diff --git a/test/box/net.box_console_connections_gh-2677.test.lua b/test/box/net.box_console_connections_gh-2677.test.lua index c6c9ea84677d..40d099e708a3 100644 --- a/test/box/net.box_console_connections_gh-2677.test.lua +++ b/test/box/net.box_console_connections_gh-2677.test.lua @@ -30,7 +30,7 @@ c.space.test:delete{1} -- -- Break a connection to test reconnect_after. -- -_ = c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') +_ = c._transport.perform_request(nil, nil, false, net._method.inject, nil, nil, nil, '\x80') while not c:is_connected() do fiber.sleep(0.01) end c:ping() diff --git a/test/box/net.box_incorrect_iterator_gh-841.result b/test/box/net.box_incorrect_iterator_gh-841.result index debfd3e4cf39..fbd2a7700e5b 100644 --- a/test/box/net.box_incorrect_iterator_gh-841.result +++ b/test/box/net.box_incorrect_iterator_gh-841.result @@ -16,11 +16,14 @@ test_run:cmd("setopt delimiter ';'") - true ... function x_select(cn, space_id, index_id, iterator, offset, limit, key, opts) - local ret = cn:_request('select', opts, nil, space_id, index_id, iterator, - offset, limit, key) + local ret = cn:_request(remote._method.select, opts, nil, space_id, + index_id, iterator, offset, limit, key) return ret end -function x_fatal(cn) cn._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') end +function x_fatal(cn) + cn._transport.perform_request(nil, nil, false, remote._method.inject, + nil, nil, nil, '\x80') +end test_run:cmd("setopt delimiter ''"); --- ... diff --git a/test/box/net.box_incorrect_iterator_gh-841.test.lua b/test/box/net.box_incorrect_iterator_gh-841.test.lua index cd431a57a46a..1d24f9f56a9b 100644 --- a/test/box/net.box_incorrect_iterator_gh-841.test.lua +++ b/test/box/net.box_incorrect_iterator_gh-841.test.lua @@ -5,11 +5,14 @@ test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua...\"]:: '") test_run:cmd("setopt delimiter ';'") function x_select(cn, space_id, index_id, iterator, offset, limit, key, opts) - local ret = cn:_request('select', opts, nil, space_id, index_id, iterator, - offset, limit, key) + local ret = cn:_request(remote._method.select, opts, nil, space_id, + index_id, iterator, offset, limit, key) return ret end -function x_fatal(cn) cn._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') end +function x_fatal(cn) + cn._transport.perform_request(nil, nil, false, remote._method.inject, + nil, nil, nil, '\x80') +end test_run:cmd("setopt delimiter ''"); LISTEN = require('uri').parse(box.cfg.listen) diff --git a/test/box/net.box_iproto_hangs_gh-3464.result b/test/box/net.box_iproto_hangs_gh-3464.result index d425bf78c3ed..3b5458c9a251 100644 --- a/test/box/net.box_iproto_hangs_gh-3464.result +++ b/test/box/net.box_iproto_hangs_gh-3464.result @@ -17,7 +17,7 @@ c = net:connect(box.cfg.listen) data = msgpack.encode(18400000000000000000)..'aaaaaaa' --- ... -c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, data) +c._transport.perform_request(nil, nil, false, net._method.inject, nil, nil, nil, data) --- - null - Peer closed diff --git a/test/box/net.box_iproto_hangs_gh-3464.test.lua b/test/box/net.box_iproto_hangs_gh-3464.test.lua index 77551e415c1f..a7c41ae7680a 100644 --- a/test/box/net.box_iproto_hangs_gh-3464.test.lua +++ b/test/box/net.box_iproto_hangs_gh-3464.test.lua @@ -8,6 +8,6 @@ net = require('net.box') -- c = net:connect(box.cfg.listen) data = msgpack.encode(18400000000000000000)..'aaaaaaa' -c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, data) +c._transport.perform_request(nil, nil, false, net._method.inject, nil, nil, nil, data) c:close() test_run:grep_log('default', 'too big packet size in the header') ~= nil diff --git a/test/box/net.box_long-poll_input_gh-3400.result b/test/box/net.box_long-poll_input_gh-3400.result index 062bd563a20a..52df89d533e9 100644 --- a/test/box/net.box_long-poll_input_gh-3400.result +++ b/test/box/net.box_long-poll_input_gh-3400.result @@ -1,3 +1,6 @@ +test_run = require('test_run').new() +--- +... fiber = require 'fiber' --- ... @@ -24,7 +27,15 @@ c:ping() -- new attempts to read any data - the connection is closed -- already. -- -f = fiber.create(c._transport.perform_request, nil, nil, false, 'call_17', nil, nil, nil, 'long', {}) c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') +test_run:cmd("setopt delimiter ';'") +--- +- true +... +f = fiber.create(c._transport.perform_request, nil, nil, false, + net._method.call_17, nil, nil, nil, 'long', {}) +c._transport.perform_request(nil, nil, false, net._method.inject, + nil, nil, nil, '\x80') +test_run:cmd("setopt delimiter ''"); --- ... while f:status() ~= 'dead' do fiber.sleep(0.01) end diff --git a/test/box/net.box_long-poll_input_gh-3400.test.lua b/test/box/net.box_long-poll_input_gh-3400.test.lua index bc9db1e69af2..99e821a128b6 100644 --- a/test/box/net.box_long-poll_input_gh-3400.test.lua +++ b/test/box/net.box_long-poll_input_gh-3400.test.lua @@ -1,3 +1,4 @@ +test_run = require('test_run').new() fiber = require 'fiber' net = require('net.box') @@ -14,6 +15,11 @@ c:ping() -- new attempts to read any data - the connection is closed -- already. -- -f = fiber.create(c._transport.perform_request, nil, nil, false, 'call_17', nil, nil, nil, 'long', {}) c._transport.perform_request(nil, nil, false, 'inject', nil, nil, nil, '\x80') +test_run:cmd("setopt delimiter ';'") +f = fiber.create(c._transport.perform_request, nil, nil, false, + net._method.call_17, nil, nil, nil, 'long', {}) +c._transport.perform_request(nil, nil, false, net._method.inject, + nil, nil, nil, '\x80') +test_run:cmd("setopt delimiter ''"); while f:status() ~= 'dead' do fiber.sleep(0.01) end c:close() -- 2.25.1