Skip to content

Commit

Permalink
test: do not rely on replication in more read cases
Browse files Browse the repository at this point in the history
Some read cases were missing in #404, #406 and #408 test stabilization
commits. This patch updates missing read cases.

1. https://github.com/tarantool/crud/actions/runs/7322196516/job/19943422319

Follows #404
  • Loading branch information
DifferentialOrange committed Mar 22, 2024
1 parent 5b05d38 commit 01d31d2
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 79 deletions.
6 changes: 3 additions & 3 deletions test/doc/playground_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ end

local cases = {
test_select_customers = {
request = "crud.select('customers', {{'<=', 'age', 35}}, {first = 10})",
request = "crud.select('customers', {{'<=', 'age', 35}}, {first = 10, mode = 'write'})",
retval_1 = {
metadata = {
{name = 'id', type = 'unsigned'},
Expand All @@ -79,7 +79,7 @@ local cases = {
}
},
test_select_developers = {
request = "crud.select('developers', nil, {first = 6})",
request = "crud.select('developers', nil, {first = 6, mode = 'write'})",
retval_1 = {
metadata = {
{name = 'id', type = 'unsigned'},
Expand Down Expand Up @@ -117,7 +117,7 @@ local cases = {
test_error = {
request = [[
do
local res, err = crud.select('non_existent', nil, {first = 10})
local res, err = crud.select('non_existent', nil, {first = 10, mode = 'write'})
return res, err and err.err or nil
end
]],
Expand Down
80 changes: 50 additions & 30 deletions test/integration/borders_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,83 +26,103 @@ end)

pgroup.test_non_existent_space = function(g)
-- min
local result, err = g.cluster.main_server.net_box:call(
'crud.min', {'non_existent_space'}
)
local result, err = g.cluster.main_server.net_box:call('crud.min', {
'non_existent_space',
nil,
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Space \"non_existent_space\" doesn't exist")

-- max
local result, err = g.cluster.main_server.net_box:call(
'crud.max', {'non_existent_space'}
)
local result, err = g.cluster.main_server.net_box:call('crud.max', {
'non_existent_space',
nil,
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Space \"non_existent_space\" doesn't exist")
end

pgroup.test_non_existent_index = function(g)
-- min
local result, err = g.cluster.main_server.net_box:call(
'crud.min', {'customers', 'non_existent_index'}
)
local result, err = g.cluster.main_server.net_box:call('crud.min', {
'customers',
'non_existent_index',
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Index \"non_existent_index\" of space \"customers\" doesn't exist")

local result, err = g.cluster.main_server.net_box:call(
'crud.min', {'customers', 13}
)
local result, err = g.cluster.main_server.net_box:call('crud.min', {
'customers',
13,
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Index \"13\" of space \"customers\" doesn't exist")

-- max
local result, err = g.cluster.main_server.net_box:call(
'crud.max', {'customers', 'non_existent_index'}
)
local result, err = g.cluster.main_server.net_box:call('crud.max', {
'customers',
'non_existent_index',
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Index \"non_existent_index\" of space \"customers\" doesn't exist")

local result, err = g.cluster.main_server.net_box:call(
'crud.max', {'customers', 13}
)
local result, err = g.cluster.main_server.net_box:call('crud.max', {
'customers',
13,
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Index \"13\" of space \"customers\" doesn't exist")
end

pgroup.test_empty_space = function(g)
-- min
local result, err = g.cluster.main_server.net_box:call(
'crud.min', {'customers'}
)
local result, err = g.cluster.main_server.net_box:call('crud.min', {
'customers',
nil,
{mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(#result.rows, 0)

-- min by age index with fields
local result, err = g.cluster.main_server.net_box:call(
'crud.min', {'customers', 'age_index', {fields = {'name'}}}
)
local result, err = g.cluster.main_server.net_box:call('crud.min', {
'customers',
'age_index',
{fields = {'name'}, mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(#result.rows, 0)

-- max
local result, err = g.cluster.main_server.net_box:call(
'crud.max', {'customers'}
)
local result, err = g.cluster.main_server.net_box:call('crud.max', {
'customers',
nil,
{mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(#result.rows, 0)

-- max by age index with fields
local result, err = g.cluster.main_server.net_box:call(
'crud.max', {'customers', 'age_index', {fields = {'name'}}}
)
local result, err = g.cluster.main_server.net_box:call('crud.max', {
'customers',
'age_index',
{fields = {'name'}, mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(#result.rows, 0)
Expand Down
36 changes: 25 additions & 11 deletions test/integration/count_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ pgroup.before_each(function(g)
end)

pgroup.test_count_non_existent_space = function(g)
local result, err = g.cluster.main_server.net_box:call('crud.count', {'non_existent_space', nil, {fullscan = true}})
local result, err = g.cluster.main_server.net_box:call('crud.count', {
'non_existent_space',
nil,
{fullscan = true, mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Space \"non_existent_space\" doesn't exist")
end

pgroup.test_count_empty_space = function(g)
local result, err = g.cluster.main_server.net_box:call('crud.count', {'customers', nil, {fullscan = true}})
local result, err = g.cluster.main_server.net_box:call('crud.count', {
'customers',
nil,
{fullscan = true, mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(result, 0)
Expand All @@ -51,9 +59,11 @@ pgroup.test_not_valid_value_type = function(g)
{'==', 'id', 'not_number'}
}

local result, err = g.cluster.main_server.net_box:call('crud.count',
{'customers', conditions}
)
local result, err = g.cluster.main_server.net_box:call('crud.count', {
'customers',
conditions,
{mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Supplied key type of part 0 does not match index part type: expected unsigned")
Expand All @@ -64,9 +74,11 @@ pgroup.test_not_valid_operation = function(g)
{{}, 'id', 5}
}

local result, err = g.cluster.main_server.net_box:call('crud.count',
{'customers', conditions, {fullscan = true}}
)
local result, err = g.cluster.main_server.net_box:call('crud.count', {
'customers',
conditions,
{fullscan = true, mode = 'write'},
})

t.assert_equals(result, nil)
t.assert_str_contains(err.err, "Failed to parse conditions")
Expand All @@ -77,9 +89,11 @@ pgroup.test_conditions_with_non_existed_field = function(g)
{'==', 'non_existed_field', 'value'}
}

local result, err = g.cluster.main_server.net_box:call('crud.count',
{'customers', conditions}
)
local result, err = g.cluster.main_server.net_box:call('crud.count', {
'customers',
conditions,
{mode = 'write'},
})

t.assert_equals(err, nil)
t.assert_equals(result, 0)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/pairs_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ pgroup.test_pairs_partial_result = function(g)
local conditions, fields = ...
local tuples = {}
for _, tuple in crud.pairs('customers', conditions, {fields = fields}) do
for _, tuple in crud.pairs('customers', conditions, {fields = fields, mode = 'write'}) do
table.insert(tuples, tuple)
end
Expand Down
8 changes: 6 additions & 2 deletions test/integration/select_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ end)
pgroup.test_non_existent_space = function(g)
-- insert
local obj, err = g.cluster.main_server.net_box:call('crud.select', {
'non_existent_space', nil, {fullscan = true},
'non_existent_space',
nil,
{fullscan = true, mode = 'write'},
})

t.assert_equals(obj, nil)
Expand All @@ -49,7 +51,9 @@ end

pgroup.test_select_no_index = function(g)
local obj, err = g.cluster.main_server.net_box:call('crud.select', {
'no_index_space', nil, {fullscan = true},
'no_index_space',
nil,
{fullscan = true, mode = 'write'},
})

t.assert_equals(obj, nil)
Expand Down
Loading

0 comments on commit 01d31d2

Please sign in to comment.