232232
233233function helpers .get_test_vshard_sharding ()
234234 local sharding = {
235- {
235+ [ ' s-1 ' ] = {
236236 replicas = {
237237 [' s1-master' ] = {
238238 instance_uuid = helpers .uuid (' b' , 1 ),
@@ -243,7 +243,7 @@ function helpers.get_test_vshard_sharding()
243243 },
244244 },
245245 },
246- {
246+ [ ' s-2 ' ] = {
247247 replicas = {
248248 [' s2-master' ] = {
249249 instance_uuid = helpers .uuid (' c' , 1 ),
@@ -361,12 +361,12 @@ function helpers.get_other_storage_bucket_id(cluster, bucket_id)
361361
362362 local replicasets = vshard.router.routeall()
363363
364- local other_replicaset_uuid
365- for replicaset_uuid , replicaset in pairs(replicasets) do
364+ local other_replicaset
365+ for _ , replicaset in pairs(replicasets) do
366366 local stat, err = replicaset:callrw('vshard.storage.bucket_stat', {bucket_id})
367367
368368 if err ~= nil and err.name == 'WRONG_BUCKET' then
369- other_replicaset_uuid = replicaset_uuid
369+ other_replicaset = replicaset
370370 break
371371 end
372372
@@ -378,13 +378,8 @@ function helpers.get_other_storage_bucket_id(cluster, bucket_id)
378378 end
379379 end
380380
381- if other_replicaset_uuid == nil then
382- return nil, 'Other replicaset is not found'
383- end
384-
385- local other_replicaset = replicasets[other_replicaset_uuid]
386381 if other_replicaset == nil then
387- return nil, string.format('Replicaset %s not found', other_replicaset_uuid)
382+ return nil, 'Other replicaset is not found'
388383 end
389384
390385 local buckets_info = other_replicaset:callrw('vshard.storage.buckets_info')
@@ -734,7 +729,7 @@ function helpers.start_cluster(g, cartridge_cfg, vshard_cfg)
734729 local cfg = table .deepcopy (vshard_cfg )
735730 cfg .engine = g .params .engine
736731
737- g .cfg = vtest .config_new (cfg )
732+ g .cfg = vtest .config_new (cfg , g . params . backend_cfg )
738733 vtest .cluster_new (g , g .cfg )
739734 g .cfg .engine = nil
740735 end
@@ -756,14 +751,57 @@ function helpers.get_router(cluster, backend)
756751 end
757752end
758753
754+ function helpers .parse_module_version (str )
755+ -- https://github.com/tarantool/luatest/blob/f37b353b77be50a1f1ce87c1ff2edf0c1b96d5d1/luatest/utils.lua#L166-L173
756+ local splitstr = str :split (' .' )
757+ local major = tonumber (splitstr [1 ]:match (' %d+' ))
758+ local minor = tonumber (splitstr [2 ]:match (' %d+' ))
759+ local patch = tonumber (splitstr [3 ]:match (' %d+' ))
760+ return luatest_utils .version (major , minor , patch )
761+ end
762+
763+ function helpers .is_name_supported_as_vshard_id ()
764+ local vshard_version = helpers .parse_module_version (require (' vshard' )._VERSION )
765+ local is_vshard_supports = luatest_utils .version_ge (vshard_version ,
766+ luatest_utils .version (0 , 1 , 25 ))
767+
768+ local tarantool_version = luatest_utils .get_tarantool_version ()
769+ local is_tarantool_supports = luatest_utils .version_ge (tarantool_version ,
770+ luatest_utils .version (3 , 0 , 0 ))
771+ return is_vshard_supports and is_tarantool_supports
772+ end
773+
759774function helpers .backend_matrix (base_matrix )
760775 base_matrix = base_matrix or {{}}
761- local backends = {helpers .backend .VSHARD , helpers .backend .CARTRIDGE }
776+ local backend_params = {
777+ {
778+ backend = helpers .backend .CARTRIDGE ,
779+ backend_cfg = nil ,
780+ },
781+ }
782+
783+ if helpers .is_name_supported_as_vshard_id () then
784+ table.insert (backend_params , {
785+ backend = helpers .backend .VSHARD ,
786+ backend_cfg = {identification_mode = ' uuid_as_key' },
787+ })
788+ table.insert (backend_params , {
789+ backend = helpers .backend .VSHARD ,
790+ backend_cfg = {identification_mode = ' name_as_key' },
791+ })
792+ else
793+ table.insert (backend_params , {
794+ backend = helpers .backend .VSHARD ,
795+ backend_cfg = nil ,
796+ })
797+ end
798+
762799 local matrix = {}
763- for _ , backend in ipairs (backends ) do
800+ for _ , params in ipairs (backend_params ) do
764801 for _ , base in ipairs (base_matrix ) do
765802 base = table .deepcopy (base )
766- base .backend = backend
803+ base .backend = params .backend
804+ base .backend_cfg = params .backend_cfg
767805 table.insert (matrix , base )
768806 end
769807 end
0 commit comments