Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-jukovec committed Oct 9, 2023
1 parent bc306c7 commit 3e6023b
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 98 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
matrix:
# We need 1.10.6 here to check that module works with
# old Tarantool versions that don't have "tuple-keydef"/"tuple-merger" support.
# We test old metrics with Tarantool 2.10 because since Tarantool 2.11.1
# it uses its own metrics package.
# We test old metrics with Cartridge 2.7.9 because since 2.8.0 it
# requires metrics 1.0.0.
tarantool-version: ["1.10.6", "1.10", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.10", "2.11"]
metrics-version: [""]
cartridge-version: ["2.8.0"]
Expand All @@ -24,12 +28,12 @@ jobs:
- tarantool-version: "2.7"
remove-merger: true
cartridge-version: "2.8.0"
- tarantool-version: "2.11"
- tarantool-version: "2.10"
metrics-version: "0.1.8"
cartridge-version: "2.8.0"
- tarantool-version: "2.11"
cartridge-version: "2.7.9"
- tarantool-version: "2.10"
metrics-version: "0.10.0"
cartridge-version: "2.8.0"
cartridge-version: "2.7.9"
- tarantool-version: "2.11"
coveralls: true
metrics-version: "1.0.0"
Expand Down Expand Up @@ -97,13 +101,8 @@ jobs:
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
VSHARD_VERSION: ${{ matrix.vshard-version }}

# There is unable to install metrics with tt for Tarantool 2.11
- name: Install metrics with tarantoolctl
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}

- name: Install metrics with tt
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
- name: Install metrics
if: matrix.metrics-version != ''
run: tt rocks install metrics ${{ matrix.metrics-version }}

- name: Remove external merger if needed
Expand Down Expand Up @@ -189,13 +188,8 @@ jobs:
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
VSHARD_VERSION: ${{ matrix.vshard-version }}

# There is unable to install metrics with tt for Tarantool 2.11
- name: Install metrics with tarantoolctl
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}

- name: Install metrics with tt
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
- name: Install metrics
if: matrix.metrics-version != ''
run: tt rocks install metrics ${{ matrix.metrics-version }}

# This server starts and listen on 8084 port that is used for tests
Expand Down
54 changes: 7 additions & 47 deletions test/entrypoint/srv_batch_operations/cartridge_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,16 @@ local log = require('log')
local errors = require('errors')
local cartridge = require('cartridge')

if package.setsearchroot ~= nil then
package.setsearchroot()
else
package.path = package.path .. debug.sourcedir() .. "/?.lua;"
end

package.preload['customers-storage'] = function()
return {
role_name = 'customers-storage',
init = function()
local engine = os.getenv('ENGINE') or 'memtx'
local customers_space = box.schema.space.create('customers', {
format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
{name = 'name', type = 'string'},
{name = 'age', type = 'number'},
},
if_not_exists = true,
engine = engine,
})
customers_space:create_index('id', {
parts = { {field = 'id'} },
if_not_exists = true,
})
customers_space:create_index('bucket_id', {
parts = { {field = 'bucket_id'} },
unique = false,
if_not_exists = true,
})

local developers_space = box.schema.space.create('developers', {
format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
{name = 'name', type = 'string'},
{name = 'login', type = 'string'},
},
if_not_exists = true,
engine = engine,
})
developers_space:create_index('id', {
parts = { {field = 'id'} },
if_not_exists = true,
})
developers_space:create_index('bucket_id', {
parts = { {field = 'bucket_id'} },
unique = false,
if_not_exists = true,
})
developers_space:create_index('login', {
parts = { {field = 'login'} },
unique = true,
if_not_exists = true,
})
end,
init = require('storage_init'),
}
end

Expand Down
8 changes: 8 additions & 0 deletions test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,14 @@ function helpers.stop_cluster(cluster, backend)
end
end

function helpers.get_router(cluster, backend)
if backend == helpers.backend.CARTRIDGE then
return cluster:server('router')
elseif backend == helpers.backend.VSHARD then
return cluster.main_server
end
end

function helpers.backend_matrix(base_matrix)
base_matrix = base_matrix or {{}}
local backends = {helpers.backend.VSHARD, helpers.backend.CARTRIDGE}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/integration/cfg_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local group = t.group('cfg', helpers.backend_matrix())
group.before_all(function(g)
helpers.start_default_cluster(g, 'srv_stats')

g.router = g.cluster.main_server
g.router = helpers.get_router(g.cluster, g.params.backend)
end)

group.after_all(function(g)
Expand Down
9 changes: 5 additions & 4 deletions test/integration/count_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ local pgroup = t.group('count', helpers.backend_matrix({
pgroup.before_all(function(g)
helpers.start_default_cluster(g, 'srv_select')

g.cluster.main_server.net_box:eval([[
g.router = helpers.get_router(g.cluster, g.params.backend)
g.router.net_box:eval([[
require('crud').cfg{ stats = true }
]])
g.cluster.main_server.net_box:eval([[
g.router.net_box:eval([[
require('crud.ratelimit').disable()
]])
end)
Expand Down Expand Up @@ -138,7 +139,7 @@ for name, case in pairs(count_safety_cases) do
pgroup[test_name] = function(g)
local uc = case.user_conditions
local opts = case.opts
local captured, err = helpers.get_command_log(g.cluster.main_server,
local captured, err = helpers.get_command_log(g.router,
g.params.backend, 'crud.count', {space, uc, opts})

t.assert_equals(err, nil)
Expand Down Expand Up @@ -641,7 +642,7 @@ pgroup.test_count_no_map_reduce = function(g)
},
})

local router = g.cluster.main_server.net_box
local router = g.router.net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')

-- Case: no conditions, just bucket id.
Expand Down
7 changes: 4 additions & 3 deletions test/integration/ddl_sharding_key_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pgroup.before_all(function(g)
t.assert_equals(type(result), 'table')
t.assert_equals(err, nil)

g.cluster.main_server.net_box:eval([[
g.router = helpers.get_router(g.cluster, g.params.backend)
g.router.net_box:eval([[
require('crud').cfg{ stats = true }
]])
end)
Expand Down Expand Up @@ -556,7 +557,7 @@ for name, case in pairs(cases) do
pgroup[('test_%s_wont_lead_to_map_reduce'):format(name)] = function(g)
case.prepare_data(g, case.space_name)

local router = g.cluster.main_server.net_box
local router = g.router.net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, case.space_name)

local result, err = router:call('crud.select', {
Expand All @@ -576,7 +577,7 @@ pgroup.test_select_for_part_of_sharding_key_will_lead_to_map_reduce = function(g
local space_name = 'customers_name_age_key_different_indexes'
prepare_data_name_age_sharding_key(g, space_name)

local router = g.cluster.main_server.net_box
local router = g.router.net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, space_name)

local result, err = router:call('crud.select', {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/pairs_readview_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ pgroup.test_pairs_no_map_reduce = function(g)

table.sort(customers, function(obj1, obj2) return obj1.id < obj2.id end)

local router = g.cluster.main_server.net_box
local router = helpers.get_router(g.cluster, g.params.backend).net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')

-- Case: no conditions, just bucket id.
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 @@ -828,7 +828,7 @@ pgroup.test_pairs_no_map_reduce = function(g)

table.sort(customers, function(obj1, obj2) return obj1.id < obj2.id end)

local router = g.cluster.main_server.net_box
local router = helpers.get_router(g.cluster, g.params.backend).net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')

-- Case: no conditions, just bucket id.
Expand Down
9 changes: 6 additions & 3 deletions test/integration/select_readview_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ local function init_cluster(g)

g.space_format = g.cluster.servers[2].net_box.space.customers:format()

g.cluster.main_server.net_box:eval([[
g.router = helpers.get_router(g.cluster, g.params.backend)
g.router.net_box:eval([[
require('crud').cfg{ stats = true }
]])
g.cluster.main_server.net_box:eval([[
g.router.net_box:eval([[
require('crud.ratelimit').disable()
]])
end
Expand Down Expand Up @@ -2205,7 +2206,7 @@ pgroup.test_select_no_map_reduce = function(g)

table.sort(customers, function(obj1, obj2) return obj1.id < obj2.id end)

local router = g.cluster.main_server.net_box
local router = g.router.net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')

-- Case: no conditions, just bucket id.
Expand Down Expand Up @@ -2383,6 +2384,7 @@ pgroup.test_select_switch_master = function(g)

end

-- TODO: https://github.com/tarantool/crud/issues/383
pgroup.test_select_switch_master_first = function(g)
helpers.skip_not_cartridge_backend(g.params.backend)

Expand Down Expand Up @@ -2438,6 +2440,7 @@ pgroup.test_select_switch_master_first = function(g)

end

-- TODO: https://github.com/tarantool/crud/issues/383
pgroup.test_select_closed_readview = function(g)
helpers.insert_objects(g, 'customers', {
{
Expand Down
9 changes: 5 additions & 4 deletions test/integration/select_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ pgroup.before_all(function(g)

g.space_format = g.cluster.servers[2].net_box.space.customers:format()

g.cluster.main_server.net_box:eval([[
g.router = helpers.get_router(g.cluster, g.params.backend)
g.router.net_box:eval([[
require('crud').cfg{ stats = true }
]])
g.cluster.main_server.net_box:eval([[
g.router.net_box:eval([[
require('crud.ratelimit').disable()
]])
end)
Expand Down Expand Up @@ -158,7 +159,7 @@ for name, case in pairs(select_safety_cases) do
opts.after = crud_utils.flatten(after_tuple, g.space_format)
end

local captured, err = helpers.get_command_log(g.cluster.main_server,
local captured, err = helpers.get_command_log(g.router,
g.params.backend, 'crud.select', {space, uc, opts})
t.assert_equals(err, nil)

Expand Down Expand Up @@ -1873,7 +1874,7 @@ pgroup.test_select_no_map_reduce = function(g)

table.sort(customers, function(obj1, obj2) return obj1.id < obj2.id end)

local router = g.cluster.main_server.net_box
local router = g.router.net_box
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')

-- Case: no conditions, just bucket id.
Expand Down
2 changes: 1 addition & 1 deletion test/integration/stats_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local new_space_name = 'newspace'
local function before_all(g)
helpers.start_default_cluster(g, 'srv_stats')

g.router = g.cluster.main_server.net_box
g.router = helpers.get_router(g.cluster, g.params.backend).net_box
if g.params.args.driver == 'metrics' then
local is_metrics_supported = g.router:eval([[
return require('crud.stats.metrics_registry').is_supported()
Expand Down
4 changes: 2 additions & 2 deletions test/performance/perf_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ g.before_all(function(g)

helpers.start_cluster(g, cartridge_cfg_template, vshard_cfg_template)

g.router = g.cluster.main_server.net_box
g.router = helpers.get_router(g.cluster, g.params.backend).net_box

g.router:eval([[
rawset(_G, 'crud', require('crud'))
Expand Down Expand Up @@ -1143,7 +1143,7 @@ for name, case in pairs(cases) do

local connections = {}

local router = g.cluster.main_server
local router = helpers.get_router(g.cluster, g.params.backend)
for _ = 1, params.connection_count do
local c = net_box:connect(router.net_box_uri, router.net_box_credentials)
if c == nil then
Expand Down
17 changes: 15 additions & 2 deletions test/unit/sharding_metadata_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,27 @@ g.before_each(function()
box.schema.space.create('fetch_on_storage')
end)

-- Since Tarantool 3.0 triggers still live after a space drop. To properly
-- clean up for the unit tests we need to remove all triggers from
-- the space. This is necessary because `crud` adds its own triggers to the
-- `ddl` spaces.
--
-- In practice `ddl` does not drop this spaces so it is the tests problem.
local function drop_ddl_space(space)
for _, t in pairs(space:on_replace()) do
space:on_replace(nil, t)
end
space:drop()
end

g.after_each(function()
-- Cleanup.
if box.space._ddl_sharding_key ~= nil then
box.space._ddl_sharding_key:drop()
drop_ddl_space(box.space._ddl_sharding_key)
end

if box.space._ddl_sharding_func ~= nil then
box.space._ddl_sharding_func:drop()
drop_ddl_space(box.space._ddl_sharding_func)
end

box.space.fetch_on_storage:drop()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/stats_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local space_name = 'customers'

local function before_all(g)
helpers.start_default_cluster(g, 'srv_stats')
g.router = g.cluster.main_server.net_box
g.router = helpers.get_router(g.cluster, g.params.backend).net_box

helpers.prepare_simple_functions(g.router)
g.router:eval("stats_module = require('crud.stats')")
Expand Down
7 changes: 0 additions & 7 deletions test/vshard_helpers/instances/router.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ end

local utils = require('test.vshard_helpers.instances.utils')

-- Do not load entire vshard into the global namespace to catch errors when
-- code relies on that.
_G.vshard = {
router = require('vshard.router'),
}
_G.ivshard = _G.vshard

-- Somewhy shutdown hangs on new Tarantools even though the nodes do not seem to
-- have any long requests running.
if box.ctl.set_on_shutdown_timeout then
Expand Down
4 changes: 1 addition & 3 deletions test/vshard_helpers/instances/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ end

local utils = require('test.vshard_helpers.instances.utils')

-- Do not load entire vshard into the global namespace to catch errors when
-- code relies on that.
-- It is not necessary in fact, but simplify `callrw` calls in tests.
_G.vshard = {
storage = require('vshard.storage'),
}
_G.ivshard = _G.vshard

-- Somewhy shutdown hangs on new Tarantools even though the nodes do not seem to
-- have any long requests running.
Expand Down

0 comments on commit 3e6023b

Please sign in to comment.