Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator
Date: Tue, 17 Jul 2018 14:41:43 +0300	[thread overview]
Message-ID: <7f6ffe078125bd2cb0523f245160236cfb403606.1531827189.git.kshcherbatov@tarantool.org> (raw)

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

             reply	other threads:[~2018-07-17 11:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17 11:41 Kirill Shcherbatov [this message]
2018-07-17 21:44 ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-19 10:23 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f6ffe078125bd2cb0523f245160236cfb403606.1531827189.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v1 1/1] net.box: fix invalid index:count() with iterator' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox