From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (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 4745842F4AD for ; Mon, 22 Jun 2020 21:34:45 +0300 (MSK) From: Olga Arkhangelskaia Date: Mon, 22 Jun 2020 21:34:33 +0300 Message-Id: <20200622183433.64739-1-arkholga@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH] netbox: fix empty error message List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org Cc: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org 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)