11local fio = require (' fio' )
22
33local t = require (' luatest' )
4- local g_memtx = t .group (' custom_bucket_id_memtx' )
5- local g_vinyl = t .group (' custom_bucket_id_vinyl' )
6-
74local crud_utils = require (' crud.common.utils' )
85
96local helpers = require (' test.helper' )
107
11- local function before_all (g , engine )
8+ local pgroup = helpers .pgroup .new (' custom_bucket_id' , {
9+ engine = {' memtx' , ' vinyl' },
10+ })
11+
12+ pgroup :set_before_all (function (g )
1213 g .cluster = helpers .Cluster :new ({
1314 datadir = fio .tempdir (),
1415 server_command = helpers .entrypoint (' srv_simple_operations' ),
@@ -42,44 +43,20 @@ local function before_all(g, engine)
4243 }
4344 },
4445 env = {
45- [' ENGINE' ] = engine ,
46+ [' ENGINE' ] = g . params . engine ,
4647 },
4748 })
48- g . engine = engine
49+
4950 g .cluster :start ()
5051
5152 g .space_format = g .cluster .servers [2 ].net_box .space .customers :format ()
52- end
53-
54- g_memtx .before_all = function () before_all (g_memtx , ' memtx' ) end
55- g_vinyl .before_all = function () before_all (g_vinyl , ' vinyl' ) end
56-
57- local function after_all (g )
58- g .cluster :stop ()
59- fio .rmtree (g .cluster .datadir )
60- end
61-
62- g_memtx .after_all = function () after_all (g_memtx ) end
63- g_vinyl .after_all = function () after_all (g_vinyl ) end
64-
65- local function before_each (g )
66- for _ , server in ipairs (g .cluster .servers ) do
67- server .net_box :eval ([[
68- local space = box.space.customers
69- if space ~= nil and not box.cfg.read_only then
70- space:truncate()
71- end
72- ]] )
73- end
74- end
53+ end )
7554
76- g_memtx .before_each (function () before_each (g_memtx ) end )
77- g_vinyl .before_each (function () before_each (g_vinyl ) end )
55+ pgroup :set_after_all (function (g ) helpers .stop_cluster (g .cluster ) end )
7856
79- local function add (name , fn )
80- g_memtx [name ] = fn
81- g_vinyl [name ] = fn
82- end
57+ pgroup :set_before_each (function (g )
58+ helpers .truncate_space_on_cluster (g .cluster , ' customers' )
59+ end )
8360
8461local function get_other_storage_bucket_id (g , key )
8562 local res_bucket_id , err = g .cluster .main_server .net_box :eval ([[
@@ -145,7 +122,7 @@ local function check_get(g, space_name, id, bucket_id, tuple)
145122 t .assert_equals (result .rows , {tuple })
146123end
147124
148- add (' test_update' , function (g )
125+ pgroup : add (' test_update' , function (g )
149126 local tuple = {2 , box .NULL , ' Ivan' , 20 }
150127 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
151128
@@ -183,7 +160,7 @@ add('test_update', function(g)
183160 t .assert_equals (# result .rows , 1 )
184161end )
185162
186- add (' test_delete' , function (g )
163+ pgroup : add (' test_delete' , function (g )
187164 local tuple = {2 , box .NULL , ' Ivan' , 20 }
188165 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
189166
@@ -235,7 +212,7 @@ add('test_delete', function(g)
235212 t .assert_equals (# result .rows , 0 )
236213end )
237214
238- add (' test_insert_object' , function (g )
215+ pgroup : add (' test_insert_object' , function (g )
239216 local object = {id = 2 , name = ' Ivan' , age = 46 }
240217 local bucket_id = get_other_storage_bucket_id (g , object .id )
241218 object .bucket_id = bucket_id
@@ -254,7 +231,7 @@ add('test_insert_object', function(g)
254231 check_get (g , ' customers' , object .id , bucket_id , tuple )
255232end )
256233
257- add (' test_insert_object_bucket_id_opt' , function (g )
234+ pgroup : add (' test_insert_object_bucket_id_opt' , function (g )
258235 local object = {id = 1 , name = ' Fedor' , age = 59 }
259236 local bucket_id = get_other_storage_bucket_id (g , object .id )
260237
@@ -272,7 +249,7 @@ add('test_insert_object_bucket_id_opt', function(g)
272249 check_get (g , ' customers' , object .id , bucket_id , tuple )
273250end )
274251
275- add (' test_insert_object_bucket_id_specified_twice' , function (g )
252+ pgroup : add (' test_insert_object_bucket_id_specified_twice' , function (g )
276253 local object = {id = 1 , name = ' Fedor' , age = 59 }
277254 local bucket_id = get_other_storage_bucket_id (g , object .id )
278255 object .bucket_id = bucket_id
@@ -299,7 +276,7 @@ add('test_insert_object_bucket_id_specified_twice', function(g)
299276 check_get (g , ' customers' , object .id , bucket_id , tuple )
300277end )
301278
302- add (' test_insert' , function (g )
279+ pgroup : add (' test_insert' , function (g )
303280 local tuple = {2 , box .NULL , ' Ivan' , 20 }
304281 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
305282 tuple [2 ] = bucket_id
@@ -316,7 +293,7 @@ add('test_insert', function(g)
316293 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
317294end )
318295
319- add (' test_insert_bucket_id_opt' , function (g )
296+ pgroup : add (' test_insert_bucket_id_opt' , function (g )
320297 local tuple = {1 , box .NULL , ' Ivan' , 20 }
321298 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
322299
@@ -335,7 +312,7 @@ add('test_insert_bucket_id_opt', function(g)
335312 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple_with_bucket_id )
336313end )
337314
338- add (' test_insert_bucket_id_specified_twice' , function (g )
315+ pgroup : add (' test_insert_bucket_id_specified_twice' , function (g )
339316 local tuple = {2 , box .NULL , ' Ivan' , 20 }
340317 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
341318 tuple [2 ] = bucket_id
@@ -360,7 +337,7 @@ add('test_insert_bucket_id_specified_twice', function(g)
360337 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
361338end )
362339
363- add (' test_replace_object' , function (g )
340+ pgroup : add (' test_replace_object' , function (g )
364341 local object = {id = 2 , name = ' Jane' , age = 21 }
365342 local bucket_id = get_other_storage_bucket_id (g , object .id )
366343 object .bucket_id = bucket_id
@@ -379,7 +356,7 @@ add('test_replace_object', function(g)
379356 check_get (g , ' customers' , object .id , bucket_id , tuple )
380357end )
381358
382- add (' test_replace_object_bucket_id_opt' , function (g )
359+ pgroup : add (' test_replace_object_bucket_id_opt' , function (g )
383360 local object = {id = 1 , name = ' John' , age = 25 }
384361 local bucket_id = get_other_storage_bucket_id (g , object .id )
385362
@@ -397,7 +374,7 @@ add('test_replace_object_bucket_id_opt', function(g)
397374 check_get (g , ' customers' , object .id , bucket_id , tuple )
398375end )
399376
400- add (' test_replace_object_bucket_id_specified_twice' , function (g )
377+ pgroup : add (' test_replace_object_bucket_id_specified_twice' , function (g )
401378 local object = {id = 1 , name = ' Fedor' , age = 59 }
402379 local bucket_id = get_other_storage_bucket_id (g , object .id )
403380 object .bucket_id = bucket_id
@@ -424,7 +401,7 @@ add('test_replace_object_bucket_id_specified_twice', function(g)
424401 check_get (g , ' customers' , object .id , bucket_id , tuple )
425402end )
426403
427- add (' test_replace' , function (g )
404+ pgroup : add (' test_replace' , function (g )
428405 local tuple = {2 , box .NULL , ' Jane' , 21 }
429406 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
430407 tuple [2 ] = bucket_id
@@ -441,7 +418,7 @@ add('test_replace', function(g)
441418 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
442419end )
443420
444- add (' test_replace_bucket_id_opt' , function (g )
421+ pgroup : add (' test_replace_bucket_id_opt' , function (g )
445422 local tuple = {1 , box .NULL , ' John' , 25 }
446423 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
447424
@@ -460,7 +437,7 @@ add('test_replace_bucket_id_opt', function(g)
460437 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple_with_bucket_id )
461438end )
462439
463- add (' test_replace_bucket_id_specified_twice' , function (g )
440+ pgroup : add (' test_replace_bucket_id_specified_twice' , function (g )
464441 local tuple = {1 , box .NULL , ' John' , 25 }
465442 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
466443 tuple [2 ] = bucket_id
@@ -485,7 +462,7 @@ add('test_replace_bucket_id_specified_twice', function(g)
485462 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
486463end )
487464
488- add (' test_upsert_object' , function (g )
465+ pgroup : add (' test_upsert_object' , function (g )
489466 local object = {id = 2 , name = ' Jane' , age = 21 }
490467 local bucket_id = get_other_storage_bucket_id (g , object .id )
491468 object .bucket_id = bucket_id
@@ -504,7 +481,7 @@ add('test_upsert_object', function(g)
504481 check_get (g , ' customers' , object .id , bucket_id , tuple )
505482end )
506483
507- add (' test_upsert_object_bucket_id_opt' , function (g )
484+ pgroup : add (' test_upsert_object_bucket_id_opt' , function (g )
508485 local object = {id = 1 , name = ' John' , age = 25 }
509486 local bucket_id = get_other_storage_bucket_id (g , object .id )
510487
@@ -522,7 +499,7 @@ add('test_upsert_object_bucket_id_opt', function(g)
522499 check_get (g , ' customers' , object .id , bucket_id , tuple )
523500end )
524501
525- add (' test_upsert_object_bucket_id_specified_twice' , function (g )
502+ pgroup : add (' test_upsert_object_bucket_id_specified_twice' , function (g )
526503 local object = {id = 1 , name = ' Fedor' , age = 59 }
527504 local bucket_id = get_other_storage_bucket_id (g , object .id )
528505 object .bucket_id = bucket_id
@@ -549,7 +526,7 @@ add('test_upsert_object_bucket_id_specified_twice', function(g)
549526 check_get (g , ' customers' , object .id , bucket_id , tuple )
550527end )
551528
552- add (' test_upsert' , function (g )
529+ pgroup : add (' test_upsert' , function (g )
553530 local tuple = {1 , box .NULL , ' John' , 25 }
554531 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
555532 tuple [2 ] = bucket_id
@@ -566,7 +543,7 @@ add('test_upsert', function(g)
566543 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
567544end )
568545
569- add (' test_upsert_bucket_id_opt' , function (g )
546+ pgroup : add (' test_upsert_bucket_id_opt' , function (g )
570547 local tuple = {1 , box .NULL , ' John' , 25 }
571548 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
572549
@@ -585,7 +562,7 @@ add('test_upsert_bucket_id_opt', function(g)
585562 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple_with_bucket_id )
586563end )
587564
588- add (' test_upsert_bucket_id_specified_twice' , function (g )
565+ pgroup : add (' test_upsert_bucket_id_specified_twice' , function (g )
589566 local tuple = {1 , box .NULL , ' John' , 25 }
590567 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
591568 tuple [2 ] = bucket_id
@@ -610,7 +587,7 @@ add('test_upsert_bucket_id_specified_twice', function(g)
610587 check_get (g , ' customers' , tuple [1 ], bucket_id , tuple )
611588end )
612589
613- add (' test_select' , function (g )
590+ pgroup : add (' test_select' , function (g )
614591 local tuple = {2 , box .NULL , ' Ivan' , 20 }
615592 local bucket_id = get_other_storage_bucket_id (g , tuple [1 ])
616593
0 commit comments