From f30a343a2dd96b69c0d48645138efcd766f9ffe4 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 12 Mar 2024 14:32:49 +0300 Subject: [PATCH] test: check count erroneous early exit The test was missing from PR #419, which had solved the original issue. Follows #418 --- test/integration/count_test.lua | 15 +++++++++++++++ test/integration/read_scenario.lua | 10 +++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/test/integration/count_test.lua b/test/integration/count_test.lua index a4014423..5047bd5f 100644 --- a/test/integration/count_test.lua +++ b/test/integration/count_test.lua @@ -3,6 +3,7 @@ local clock = require('clock') local t = require('luatest') local helpers = require('test.helper') +local read_scenario = require('test.integration.read_scenario') local pgroup = t.group('count', helpers.backend_matrix({ {engine = 'memtx'}, @@ -867,3 +868,17 @@ pgroup.test_count_force_map_call = function(g) t.assert_equals(err, nil) t.assert_equals(result, 2) end + +pgroup.test_gh_418_count_with_secondary_noneq_index_condition = function(g) + local read = function(cg, space, conditions, opts) + opts = table.deepcopy(opts) or {} + opts.mode = 'write' + + local resp, err = cg.cluster.main_server:call('crud.count', {space, conditions, opts}) + t.assert_equals(err, nil) + + return resp + end + + read_scenario.gh_418_read_with_secondary_noneq_index_condition(g, read) +end diff --git a/test/integration/read_scenario.lua b/test/integration/read_scenario.lua index 7adc2cfd..ff0e2462 100644 --- a/test/integration/read_scenario.lua +++ b/test/integration/read_scenario.lua @@ -1,4 +1,4 @@ --- crud.select/crud.pairs/readview:select/readview:pairs +-- crud.select/crud.pairs/crud.count/readview:select/readview:pairs -- have a lot of common scenarios, which are mostly tested with -- four nearly identical copypasted test functions now. -- This approach is expected to improve it at least for new test cases. @@ -48,13 +48,17 @@ local function gh_418_read_with_secondary_noneq_index_condition(cg, read) -- iterator had erroneously expected tuples to be sorted by `last_login` -- index while iterating on `city` index. Before the issue had beed fixed, -- user had received only one record instead of two. - local objects = read(cg, + local result = read(cg, 'logins', {{'=', 'city', 'Tatsumi Port Island'}, {'<=', 'last_login', 42}}, {bucket_id = PINNED_BUCKET_NO} ) - t.assert_equals(objects, {expected_objects[1], expected_objects[3]}) + if type(result) == 'number' then -- crud.count + t.assert_equals(result, 2) + else + t.assert_equals(result, {expected_objects[1], expected_objects[3]}) + end end return {