[Tarantool-patches] [PATCH 07/20] net.box: use integer id instead of method name

Vladimir Davydov vdavydov at tarantool.org
Fri Jul 23 14:07:17 MSK 2021


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...\"]:<line>: '")
 
 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



More information about the Tarantool-patches mailing list