From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 554D84696C3 for ; Wed, 11 Mar 2020 12:14:01 +0300 (MSK) Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1jBxRA-0003so-Uq for tarantool-patches@dev.tarantool.org; Wed, 11 Mar 2020 12:14:01 +0300 From: Chris Sosnin Date: Wed, 11 Mar 2020 12:13:59 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v3 1/2] test: introduce iproto_request helper function List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org It is needed for performing iproto tests in Lua. Needed for #4769 --- test/box/box.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/box/box.lua b/test/box/box.lua index 2a8e0e4fa..6fad07015 100644 --- a/test/box/box.lua +++ b/test/box/box.lua @@ -1,6 +1,8 @@ #!/usr/bin/env tarantool os = require('os') +local msgpack = require('msgpack') + box.cfg{ listen = os.getenv("LISTEN"), memtx_memory = 107374182, @@ -38,4 +40,22 @@ function sorted(data) return data end -_G.protected_globals = {'cfg_filter', 'sorted'} +function iproto_request(socket, query_header, query_body) + local header = msgpack.encode(query_header) + local body = msgpack.encode(query_body) + local size = msgpack.encode(header:len() + body:len()) + assert(socket:write(size .. header .. body) ~= nil, + 'Failed to send request') + size = socket:read(5) + assert(size ~= nil, 'Failed to read response') + size = msgpack.decode(size) + local response = socket:read(size) + local header, header_len = msgpack.decode(response) + body = msgpack.decode(response:sub(header_len)) + return { + ['header'] = header, + ['body'] = body, + } +end + +_G.protected_globals = {'cfg_filter', 'sorted', 'iproto_request'} -- 2.21.1 (Apple Git-122.3)