From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 3C94926D94 for ; Tue, 17 Jul 2018 07:41:50 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T_Rp7WmTQIBp for ; Tue, 17 Jul 2018 07:41:50 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id ED07D26D77 for ; Tue, 17 Jul 2018 07:41:49 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator Date: Tue, 17 Jul 2018 14:41:43 +0300 Message-Id: <7f6ffe078125bd2cb0523f245160236cfb403606.1531827189.git.kshcherbatov@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov Net.box didn't pass options containing iterator to server side. There were also invalid results for two :count tests in net.box.result file. Thanks @ademenev for contributing problem and help with problem locating. Closes #3262. --- Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3262-fix-netbox-index-count Issue: https://github.com/tarantool/tarantool/issues/3262 src/box/lua/net_box.lua | 2 +- test/box/net.box.result | 34 ++++++++++++++++++++++++++++++++-- test/box/net.box.test.lua | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index cf7b672..a5091ed 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -1093,7 +1093,7 @@ index_metatable = function(remote) end local code = string.format('box.space.%s.index.%s:count', self.space.name, self.name) - return remote:_request('call_16', opts, code, { key })[1][1] + return remote:_request('call_16', opts, code, { key, opts })[1][1] end function methods:delete(key, opts) diff --git a/test/box/net.box.result b/test/box/net.box.result index 21cff4a..ed14c4d 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -891,11 +891,11 @@ remote_pk:count({2}) ... remote_pk:count({2}, { timeout = 1.00, iterator = 'LE' }) --- -- 1 +- 3 ... remote_pk:count({2}, { iterator = 'LE'}) --- -- 1 +- 3 ... remote_pk:count({2}, { timeout = 1e-9, iterator = 'LE' }) --- @@ -949,6 +949,36 @@ remote_pk:max({2}) --- - [2] ... +-- +-- gh-3262: index:count() inconsistent results +-- +test_run:cmd("setopt delimiter ';'") +--- +- true +... +function do_count_test(min, it) + local r1 = remote_pk:count(min, {iterator = it} ) + local r2 = box.space.net_box_test_space.index.primary:count(min, {iterator = it} ) + local r3 = remote.self.space.net_box_test_space.index.primary:count(min, {iterator = it} ) + return r1 == r2 and r2 == r3 +end; +--- +... +data = remote_pk:select(); +--- +... +for _, v in pairs(data) do + local itrs = {'GE', 'GT', 'LE', 'LT' } + for _, it in pairs(itrs) do + assert(do_count_test(v[0], it) == true) + end +end; +--- +... +test_run:cmd("setopt delimiter ''"); +--- +- true +... _ = remote_space:delete({0}, { timeout = 1e-9 }) --- - error: Timeout exceeded diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 14fb6eb..0187aaf 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -347,6 +347,29 @@ remote_pk:max({0}, { timeout = 1.00 }) remote_pk:max({1}, { timeout = 1e-9 }) remote_pk:max({2}) +-- +-- gh-3262: index:count() inconsistent results +-- +test_run:cmd("setopt delimiter ';'") + +function do_count_test(min, it) + local r1 = remote_pk:count(min, {iterator = it} ) + local r2 = box.space.net_box_test_space.index.primary:count(min, {iterator = it} ) + local r3 = remote.self.space.net_box_test_space.index.primary:count(min, {iterator = it} ) + return r1 == r2 and r2 == r3 +end; + +data = remote_pk:select(); + +for _, v in pairs(data) do + local itrs = {'GE', 'GT', 'LE', 'LT' } + for _, it in pairs(itrs) do + assert(do_count_test(v[0], it) == true) + end +end; + +test_run:cmd("setopt delimiter ''"); + _ = remote_space:delete({0}, { timeout = 1e-9 }) _ = remote_pk:delete({0}, { timeout = 1.00 }) _ = remote_space:delete({1}, { timeout = 1.00 }) -- 2.7.4