[Tarantool-patches] [PATCH] netbox: fix empty error message
Olga Arkhangelskaia
arkholga at tarantool.org
Mon Jun 22 21:34:33 MSK 2020
When the connection was not established yet netbox reported empty error
while executing a remote request.
Closes #4787
---
Branch OKriw/gh-4787-netbox-reports-empty-error
src/box/lua/net_box.lua | 6 ++--
test/app/gh-4787-netbox-empty-errmsg.result | 34 +++++++++++++++++++
test/app/gh-4787-netbox-empty-errmsg.test.lua | 15 ++++++++
3 files changed, 53 insertions(+), 2 deletions(-)
create mode 100644 test/app/gh-4787-netbox-empty-errmsg.result
create mode 100755 test/app/gh-4787-netbox-empty-errmsg.test.lua
diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 9560bfdd4..6774729b4 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -541,8 +541,10 @@ local function create_transport(host, port, user, password, callback,
local function perform_async_request(buffer, skip_header, method, on_push,
on_push_ctx, request_ctx, ...)
if state ~= 'active' and state ~= 'fetch_schema' then
- return nil, box.error.new({code = last_errno or E_NO_CONNECTION,
- reason = last_error})
+ return nil, box.error.new({code = last_error or E_NO_CONNECTION,
+ reason = last_error or
+ string.format("connection is not eshatblished, state: %s",
+ state)})
end
-- alert worker to notify it of the queued outgoing data;
-- if the buffer wasn't empty, assume the worker was already alerted
diff --git a/test/app/gh-4787-netbox-empty-errmsg.result b/test/app/gh-4787-netbox-empty-errmsg.result
new file mode 100644
index 000000000..9e14cfb19
--- /dev/null
+++ b/test/app/gh-4787-netbox-empty-errmsg.result
@@ -0,0 +1,34 @@
+-- test-run result file version 2
+netbox = require('net.box')
+ | ---
+ | ...
+--
+--gh-4787:netbox reported empty error message while executing remote call
+--
+box.schema.user.grant('guest', 'execute', 'universe')
+ | ---
+ | ...
+ok, err = nil
+ | ---
+ | ...
+-- Due to race when wait_connected = false, run whole block to get an error
+do \
+ c = netbox.connect(box.cfg.listen, {wait_connected = false}) \
+ ok, err = pcall(c.call, c, 'any', {}, {is_async = true}) \
+end
+ | ---
+ | ...
+err ~= nil
+ | ---
+ | - true
+ | ...
+err:unpack().message ~= nil
+ | ---
+ | - true
+ | ...
+c:close()
+ | ---
+ | ...
+box.schema.user.revoke('guest', 'read,write,execute,create', 'universe')
+ | ---
+ | ...
diff --git a/test/app/gh-4787-netbox-empty-errmsg.test.lua b/test/app/gh-4787-netbox-empty-errmsg.test.lua
new file mode 100755
index 000000000..2949f16ea
--- /dev/null
+++ b/test/app/gh-4787-netbox-empty-errmsg.test.lua
@@ -0,0 +1,15 @@
+netbox = require('net.box')
+--
+--gh-4787:netbox reported empty error message while executing remote call
+--
+box.schema.user.grant('guest', 'execute', 'universe')
+ok, err = nil
+-- Due to race when wait_connected = false, run whole block to get an error
+do \
+ c = netbox.connect(box.cfg.listen, {wait_connected = false}) \
+ ok, err = pcall(c.call, c, 'any', {}, {is_async = true}) \
+end
+err ~= nil
+err:unpack().message ~= nil
+c:close()
+box.schema.user.revoke('guest', 'read,write,execute,create', 'universe')
--
2.20.1 (Apple Git-117)
More information about the Tarantool-patches
mailing list