Skip to content

Commit 3e6023b

Browse files
committed
fixes
1 parent bc306c7 commit 3e6023b

17 files changed

+70
-98
lines changed

.github/workflows/test_on_push.yaml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
matrix:
1414
# We need 1.10.6 here to check that module works with
1515
# old Tarantool versions that don't have "tuple-keydef"/"tuple-merger" support.
16+
# We test old metrics with Tarantool 2.10 because since Tarantool 2.11.1
17+
# it uses its own metrics package.
18+
# We test old metrics with Cartridge 2.7.9 because since 2.8.0 it
19+
# requires metrics 1.0.0.
1620
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"]
1721
metrics-version: [""]
1822
cartridge-version: ["2.8.0"]
@@ -24,12 +28,12 @@ jobs:
2428
- tarantool-version: "2.7"
2529
remove-merger: true
2630
cartridge-version: "2.8.0"
27-
- tarantool-version: "2.11"
31+
- tarantool-version: "2.10"
2832
metrics-version: "0.1.8"
29-
cartridge-version: "2.8.0"
30-
- tarantool-version: "2.11"
33+
cartridge-version: "2.7.9"
34+
- tarantool-version: "2.10"
3135
metrics-version: "0.10.0"
32-
cartridge-version: "2.8.0"
36+
cartridge-version: "2.7.9"
3337
- tarantool-version: "2.11"
3438
coveralls: true
3539
metrics-version: "1.0.0"
@@ -97,13 +101,8 @@ jobs:
97101
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
98102
VSHARD_VERSION: ${{ matrix.vshard-version }}
99103

100-
# There is unable to install metrics with tt for Tarantool 2.11
101-
- name: Install metrics with tarantoolctl
102-
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
103-
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
104-
105-
- name: Install metrics with tt
106-
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
104+
- name: Install metrics
105+
if: matrix.metrics-version != ''
107106
run: tt rocks install metrics ${{ matrix.metrics-version }}
108107

109108
- name: Remove external merger if needed
@@ -189,13 +188,8 @@ jobs:
189188
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
190189
VSHARD_VERSION: ${{ matrix.vshard-version }}
191190

192-
# There is unable to install metrics with tt for Tarantool 2.11
193-
- name: Install metrics with tarantoolctl
194-
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
195-
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
196-
197-
- name: Install metrics with tt
198-
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
191+
- name: Install metrics
192+
if: matrix.metrics-version != ''
199193
run: tt rocks install metrics ${{ matrix.metrics-version }}
200194

201195
# This server starts and listen on 8084 port that is used for tests

test/entrypoint/srv_batch_operations/cartridge_init.lua

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,16 @@ local log = require('log')
77
local errors = require('errors')
88
local cartridge = require('cartridge')
99

10+
if package.setsearchroot ~= nil then
11+
package.setsearchroot()
12+
else
13+
package.path = package.path .. debug.sourcedir() .. "/?.lua;"
14+
end
15+
1016
package.preload['customers-storage'] = function()
1117
return {
1218
role_name = 'customers-storage',
13-
init = function()
14-
local engine = os.getenv('ENGINE') or 'memtx'
15-
local customers_space = box.schema.space.create('customers', {
16-
format = {
17-
{name = 'id', type = 'unsigned'},
18-
{name = 'bucket_id', type = 'unsigned'},
19-
{name = 'name', type = 'string'},
20-
{name = 'age', type = 'number'},
21-
},
22-
if_not_exists = true,
23-
engine = engine,
24-
})
25-
customers_space:create_index('id', {
26-
parts = { {field = 'id'} },
27-
if_not_exists = true,
28-
})
29-
customers_space:create_index('bucket_id', {
30-
parts = { {field = 'bucket_id'} },
31-
unique = false,
32-
if_not_exists = true,
33-
})
34-
35-
local developers_space = box.schema.space.create('developers', {
36-
format = {
37-
{name = 'id', type = 'unsigned'},
38-
{name = 'bucket_id', type = 'unsigned'},
39-
{name = 'name', type = 'string'},
40-
{name = 'login', type = 'string'},
41-
},
42-
if_not_exists = true,
43-
engine = engine,
44-
})
45-
developers_space:create_index('id', {
46-
parts = { {field = 'id'} },
47-
if_not_exists = true,
48-
})
49-
developers_space:create_index('bucket_id', {
50-
parts = { {field = 'bucket_id'} },
51-
unique = false,
52-
if_not_exists = true,
53-
})
54-
developers_space:create_index('login', {
55-
parts = { {field = 'login'} },
56-
unique = true,
57-
if_not_exists = true,
58-
})
59-
end,
19+
init = require('storage_init'),
6020
}
6121
end
6222

test/helper.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,14 @@ function helpers.stop_cluster(cluster, backend)
746746
end
747747
end
748748

749+
function helpers.get_router(cluster, backend)
750+
if backend == helpers.backend.CARTRIDGE then
751+
return cluster:server('router')
752+
elseif backend == helpers.backend.VSHARD then
753+
return cluster.main_server
754+
end
755+
end
756+
749757
function helpers.backend_matrix(base_matrix)
750758
base_matrix = base_matrix or {{}}
751759
local backends = {helpers.backend.VSHARD, helpers.backend.CARTRIDGE}

test/integration/cfg_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local group = t.group('cfg', helpers.backend_matrix())
88
group.before_all(function(g)
99
helpers.start_default_cluster(g, 'srv_stats')
1010

11-
g.router = g.cluster.main_server
11+
g.router = helpers.get_router(g.cluster, g.params.backend)
1212
end)
1313

1414
group.after_all(function(g)

test/integration/count_test.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ local pgroup = t.group('count', helpers.backend_matrix({
1212
pgroup.before_all(function(g)
1313
helpers.start_default_cluster(g, 'srv_select')
1414

15-
g.cluster.main_server.net_box:eval([[
15+
g.router = helpers.get_router(g.cluster, g.params.backend)
16+
g.router.net_box:eval([[
1617
require('crud').cfg{ stats = true }
1718
]])
18-
g.cluster.main_server.net_box:eval([[
19+
g.router.net_box:eval([[
1920
require('crud.ratelimit').disable()
2021
]])
2122
end)
@@ -138,7 +139,7 @@ for name, case in pairs(count_safety_cases) do
138139
pgroup[test_name] = function(g)
139140
local uc = case.user_conditions
140141
local opts = case.opts
141-
local captured, err = helpers.get_command_log(g.cluster.main_server,
142+
local captured, err = helpers.get_command_log(g.router,
142143
g.params.backend, 'crud.count', {space, uc, opts})
143144

144145
t.assert_equals(err, nil)
@@ -641,7 +642,7 @@ pgroup.test_count_no_map_reduce = function(g)
641642
},
642643
})
643644

644-
local router = g.cluster.main_server.net_box
645+
local router = g.router.net_box
645646
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')
646647

647648
-- Case: no conditions, just bucket id.

test/integration/ddl_sharding_key_test.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ pgroup.before_all(function(g)
2626
t.assert_equals(type(result), 'table')
2727
t.assert_equals(err, nil)
2828

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

559-
local router = g.cluster.main_server.net_box
560+
local router = g.router.net_box
560561
local map_reduces_before = helpers.get_map_reduces_stat(router, case.space_name)
561562

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

579-
local router = g.cluster.main_server.net_box
580+
local router = g.router.net_box
580581
local map_reduces_before = helpers.get_map_reduces_stat(router, space_name)
581582

582583
local result, err = router:call('crud.select', {

test/integration/pairs_readview_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ pgroup.test_pairs_no_map_reduce = function(g)
829829

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

832-
local router = g.cluster.main_server.net_box
832+
local router = helpers.get_router(g.cluster, g.params.backend).net_box
833833
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')
834834

835835
-- Case: no conditions, just bucket id.

test/integration/pairs_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ pgroup.test_pairs_no_map_reduce = function(g)
828828

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

831-
local router = g.cluster.main_server.net_box
831+
local router = helpers.get_router(g.cluster, g.params.backend).net_box
832832
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')
833833

834834
-- Case: no conditions, just bucket id.

test/integration/select_readview_test.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ local function init_cluster(g)
1717

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

20-
g.cluster.main_server.net_box:eval([[
20+
g.router = helpers.get_router(g.cluster, g.params.backend)
21+
g.router.net_box:eval([[
2122
require('crud').cfg{ stats = true }
2223
]])
23-
g.cluster.main_server.net_box:eval([[
24+
g.router.net_box:eval([[
2425
require('crud.ratelimit').disable()
2526
]])
2627
end
@@ -2205,7 +2206,7 @@ pgroup.test_select_no_map_reduce = function(g)
22052206

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

2208-
local router = g.cluster.main_server.net_box
2209+
local router = g.router.net_box
22092210
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')
22102211

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

23842385
end
23852386

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

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

24392441
end
24402442

2443+
-- TODO: https://github.com/tarantool/crud/issues/383
24412444
pgroup.test_select_closed_readview = function(g)
24422445
helpers.insert_objects(g, 'customers', {
24432446
{

test/integration/select_test.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ pgroup.before_all(function(g)
1515

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

18-
g.cluster.main_server.net_box:eval([[
18+
g.router = helpers.get_router(g.cluster, g.params.backend)
19+
g.router.net_box:eval([[
1920
require('crud').cfg{ stats = true }
2021
]])
21-
g.cluster.main_server.net_box:eval([[
22+
g.router.net_box:eval([[
2223
require('crud.ratelimit').disable()
2324
]])
2425
end)
@@ -158,7 +159,7 @@ for name, case in pairs(select_safety_cases) do
158159
opts.after = crud_utils.flatten(after_tuple, g.space_format)
159160
end
160161

161-
local captured, err = helpers.get_command_log(g.cluster.main_server,
162+
local captured, err = helpers.get_command_log(g.router,
162163
g.params.backend, 'crud.select', {space, uc, opts})
163164
t.assert_equals(err, nil)
164165

@@ -1873,7 +1874,7 @@ pgroup.test_select_no_map_reduce = function(g)
18731874

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

1876-
local router = g.cluster.main_server.net_box
1877+
local router = g.router.net_box
18771878
local map_reduces_before = helpers.get_map_reduces_stat(router, 'customers')
18781879

18791880
-- Case: no conditions, just bucket id.

test/integration/stats_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ local new_space_name = 'newspace'
3535
local function before_all(g)
3636
helpers.start_default_cluster(g, 'srv_stats')
3737

38-
g.router = g.cluster.main_server.net_box
38+
g.router = helpers.get_router(g.cluster, g.params.backend).net_box
3939
if g.params.args.driver == 'metrics' then
4040
local is_metrics_supported = g.router:eval([[
4141
return require('crud.stats.metrics_registry').is_supported()

test/performance/perf_test.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ g.before_all(function(g)
109109

110110
helpers.start_cluster(g, cartridge_cfg_template, vshard_cfg_template)
111111

112-
g.router = g.cluster.main_server.net_box
112+
g.router = helpers.get_router(g.cluster, g.params.backend).net_box
113113

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

11441144
local connections = {}
11451145

1146-
local router = g.cluster.main_server
1146+
local router = helpers.get_router(g.cluster, g.params.backend)
11471147
for _ = 1, params.connection_count do
11481148
local c = net_box:connect(router.net_box_uri, router.net_box_credentials)
11491149
if c == nil then

test/unit/sharding_metadata_test.lua

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,27 @@ g.before_each(function()
4545
box.schema.space.create('fetch_on_storage')
4646
end)
4747

48+
-- Since Tarantool 3.0 triggers still live after a space drop. To properly
49+
-- clean up for the unit tests we need to remove all triggers from
50+
-- the space. This is necessary because `crud` adds its own triggers to the
51+
-- `ddl` spaces.
52+
--
53+
-- In practice `ddl` does not drop this spaces so it is the tests problem.
54+
local function drop_ddl_space(space)
55+
for _, t in pairs(space:on_replace()) do
56+
space:on_replace(nil, t)
57+
end
58+
space:drop()
59+
end
60+
4861
g.after_each(function()
4962
-- Cleanup.
5063
if box.space._ddl_sharding_key ~= nil then
51-
box.space._ddl_sharding_key:drop()
64+
drop_ddl_space(box.space._ddl_sharding_key)
5265
end
5366

5467
if box.space._ddl_sharding_func ~= nil then
55-
box.space._ddl_sharding_func:drop()
68+
drop_ddl_space(box.space._ddl_sharding_func)
5669
end
5770

5871
box.space.fetch_on_storage:drop()

test/unit/stats_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local space_name = 'customers'
1818

1919
local function before_all(g)
2020
helpers.start_default_cluster(g, 'srv_stats')
21-
g.router = g.cluster.main_server.net_box
21+
g.router = helpers.get_router(g.cluster, g.params.backend).net_box
2222

2323
helpers.prepare_simple_functions(g.router)
2424
g.router:eval("stats_module = require('crud.stats')")

test/vshard_helpers/instances/router.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ end
1616

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

19-
-- Do not load entire vshard into the global namespace to catch errors when
20-
-- code relies on that.
21-
_G.vshard = {
22-
router = require('vshard.router'),
23-
}
24-
_G.ivshard = _G.vshard
25-
2619
-- Somewhy shutdown hangs on new Tarantools even though the nodes do not seem to
2720
-- have any long requests running.
2821
if box.ctl.set_on_shutdown_timeout then

test/vshard_helpers/instances/storage.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ end
1616

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

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

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

0 commit comments

Comments
 (0)