diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index 17cb0c98602a4dd280960bea3d726a15cf0934af..2f2a936772a3e79a5b5fdba7fceab743dde2d4b1 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -941,29 +941,34 @@ local remote_methods = { setmetatable(remote, { __index = remote_methods }) -box.ping = function() return true end -box.close = function() return true end -box.wait_connected = function() return true end -box.call = function(_box, proc_name, ...) - local proc = { package.loaded['box.internal'].call_loadproc(proc_name) } - local result - if #proc == 2 then - result = { proc[1](proc[2], ...) } - else - result = { proc[1](...) } - end +remote.self = { + ping = function() return true end, + close = function() end, + timeout = function(self) return self end, + wait_connected = function(self) return true end, + call = function(_box, proc_name, ...) + local proc = { package.loaded['box.internal'] + .call_loadproc(proc_name) } + local result + if #proc == 2 then + result = { proc[1](proc[2], ...) } + else + result = { proc[1](...) } + end - if #result == 1 and type(result[1]) == 'table' then - result = result[1] - end + if #result == 1 and type(result[1]) == 'table' then + result = result[1] + end - for i, v in pairs(result) do - result[i] = box.tuple.new(v) + for i, v in pairs(result) do + result[i] = box.tuple.new(v) + end + return result end - return result -end +} + +setmetatable(remote.self, { __index = box }) -box.timeout = function() return box end return remote diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index e02821b4c2cf9d267d8ca1d70ca6310065599d2d..f112b865d8d03267b5d1303b8264183cb2d395e2 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -320,7 +320,7 @@ cn:call('test_foo', 'a', 'b', 'c') - ['c'] ... -- call -box:call('test_foo', 'a', 'b', 'c') +remote.self:call('test_foo', 'a', 'b', 'c') --- - - [{'a': 1}] - [{'b': 2}] @@ -404,6 +404,18 @@ cn = remote:timeout(0.0000000001):new('127.0.0.1', port, { user = 'netbox', pass cn = remote:timeout(1):new('127.0.0.1', port, { user = 'netbox', password = '123' }) --- ... +remote.self:ping() +--- +- true +... +remote.self.space.net_box_test_space:select{234} +--- +- - [234, 1, 2, 3] +... +remote.self:timeout(123).space.net_box_test_space:select{234} +--- +- - [234, 1, 2, 3] +... -- cleanup database after tests space:drop() --- diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index faface25269a63a8f5999088bff9d1ac9cfd5bc3..953e964a5f95145af2d1d8a7085a1ee8d8ecce6e 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -117,7 +117,7 @@ cn:call('test_foo', 'a', 'b', 'c') -- call -box:call('test_foo', 'a', 'b', 'c') +remote.self:call('test_foo', 'a', 'b', 'c') cn:call('test_foo', 'a', 'b', 'c') -- auth @@ -149,6 +149,9 @@ cn:timeout(.01):call('ret_after', 1) cn = remote:timeout(0.0000000001):new('127.0.0.1', port, { user = 'netbox', password = '123' }) cn = remote:timeout(1):new('127.0.0.1', port, { user = 'netbox', password = '123' }) +remote.self:ping() +remote.self.space.net_box_test_space:select{234} +remote.self:timeout(123).space.net_box_test_space:select{234} -- cleanup database after tests space:drop()