diff --git a/changelogs/unreleased/config-support-vshard-ee.md b/changelogs/unreleased/config-support-vshard-ee.md new file mode 100644 index 0000000000000000000000000000000000000000..8c5b12e208ec956d4d0eb28d7b3b5317b0ee3631 --- /dev/null +++ b/changelogs/unreleased/config-support-vshard-ee.md @@ -0,0 +1,4 @@ +## bugfix/config + +* Support for `vshard-ee` in addition to `vshard` in the sharding configuration + logic (ghe-815). diff --git a/src/box/lua/config/applier/credentials.lua b/src/box/lua/config/applier/credentials.lua index 70547c073f2cb861d041215093b1d2894aa8ff6e..36028ef703dbdc5a4eea8b62fee9db2a464e8309 100644 --- a/src/box/lua/config/applier/credentials.lua +++ b/src/box/lua/config/applier/credentials.lua @@ -1,5 +1,6 @@ local expression = require('internal.config.utils.expression') local log = require('internal.config.utils.log') +local loaders = require('internal.loaders') local digest = require('digest') local fiber = require('fiber') @@ -318,9 +319,10 @@ local function sharding_role(configdata) -- The error will be thrown later, in sharding.lua. Here we are simply -- trying to avoid the "module not found" error. -- - local ok, vshard = pcall(require, 'vshard') + local ok, vshard = pcall(loaders.require_first, 'vshard-ee', 'vshard') if ok and expression.eval('v >= 0.1.25', {v = vshard.consts.VERSION}) then - local vexports = require('vshard.storage.exports') + local vexports = loaders.require_first('vshard-ee.storage.exports', + 'vshard.storage.exports') local exports = vexports.compile(vexports.log[#vexports.log]) for name in pairs(exports.funcs) do table.insert(funcs, name) diff --git a/src/box/lua/config/applier/sharding.lua b/src/box/lua/config/applier/sharding.lua index 2869f77ef9be795ba739c526a73abf44db57e28f..db8ede0c6c2b18fe427dc86978bd8ecc171f9902 100644 --- a/src/box/lua/config/applier/sharding.lua +++ b/src/box/lua/config/applier/sharding.lua @@ -1,5 +1,6 @@ local expression = require('internal.config.utils.expression') local log = require('internal.config.utils.log') +local loaders = require('internal.loaders') _G.vshard = nil -- Watcher which will create all the necessary functions. @@ -12,9 +13,9 @@ local function apply(config) return end -- Make sure vshard is available and its version is not too old. - local ok, vshard = pcall(require, 'vshard') + local ok, vshard = pcall(loaders.require_first, 'vshard-ee', 'vshard') if not ok then - error('The vshard module is not available', 0) + error('The vshard-ee/vshard module is not available', 0) end if expression.eval('v < 0.1.25', {v = vshard.consts.VERSION}) then error('The vshard module is too old: the minimum supported version ' .. @@ -36,7 +37,8 @@ local function apply(config) -- Start a watcher which will create all the necessary functions. if watcher == nil then local function deploy_funcs() - local vexports = require('vshard.storage.exports') + local vexports = loaders.require_first( + 'vshard-ee.storage.exports', 'vshard.storage.exports') local exports = vexports.compile(vexports.log[#vexports.log]) vexports.deploy_funcs(exports) end diff --git a/test/box-luatest/upgrade/2.11.0/vshard/storage-gen.lua b/test/box-luatest/upgrade/2.11.0/vshard/storage-gen.lua index b9d075378ff4f3312eea9d2fae26a42097d35cb3..2498b0b27a8e2144173779b5c63dccc68c2cdfcc 100644 --- a/test/box-luatest/upgrade/2.11.0/vshard/storage-gen.lua +++ b/test/box-luatest/upgrade/2.11.0/vshard/storage-gen.lua @@ -45,7 +45,10 @@ local names = { } -- Start the database with sharding -local vshard = require('vshard') +local ok, vshard = pcall(require, 'vshard-ee') +if not ok then + vshard = require('vshard') +end vshard.storage.cfg(cfg, names[NAME]) box.once("testapp", function() diff --git a/test/config-luatest/vshard_test.lua b/test/config-luatest/vshard_test.lua index de37b5ffd6bd7a9678b25b82958c94f653c6227a..7abd2a62c4c93c544ebe2300a6ab1d4c5ad429af 100644 --- a/test/config-luatest/vshard_test.lua +++ b/test/config-luatest/vshard_test.lua @@ -7,10 +7,17 @@ local helpers = require('test.config-luatest.helpers') local g = helpers.group() -local has_vshard = pcall(require, 'vshard') +local has_vshard = pcall(require, 'vshard-ee') +if not has_vshard then + has_vshard = pcall(require, 'vshard') +end + +local function skip_if_no_vshard() + t.skip_if(not has_vshard, 'Module "vshard-ee/vshard" is not available') +end g.test_fixed_masters = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -258,7 +265,7 @@ g.test_fixed_masters = function(g) end g.test_rebalancer_role = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -422,7 +429,7 @@ g.test_rebalancer_role = function(g) end g.test_too_many_rebalancers = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -470,7 +477,7 @@ end -- credentials sharding role. -- g.test_no_sharding_credentials_role_success = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() helpers.success_case(g, { options = { ['credentials.users.storage.roles'] = {'sharding'}, @@ -494,7 +501,7 @@ g.test_no_sharding_credentials_role_success = function(g) end g.test_no_sharding_credentials_role_error = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -536,7 +543,7 @@ end -- credentials, its credential sharding role is not checked. -- g.test_no_storage_user = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() helpers.success_case(g, { options = { ['sharding.roles'] = {'storage', 'router'}, @@ -551,7 +558,7 @@ end -- Make sure that the credential sharding role has all necessary credentials. g.test_sharding_credentials_role = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -594,7 +601,10 @@ g.test_sharding_credentials_role = function(g) local role = box.space._user.index.name:get('sharding') local repl_id = box.space._user.index.name:get('replication').id t.assert(role ~= nil) - local vexports = require('vshard.storage.exports') + local ok, vexports = pcall(require, 'vshard-ee.storage.exports') + if not ok then + vexports = require('vshard.storage.exports') + end local exports = vexports.compile(vexports.log[#vexports.log]) -- The role should have the necessary privileges. @@ -618,7 +628,7 @@ g.test_sharding_credentials_role = function(g) end g.test_no_suitable_uri = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -656,7 +666,7 @@ end -- Make sure that rebalancing will be disabled if rebalancer_mode == 'off', even -- if rebalancer sharding role is assigned. g.test_rebalancer_mode = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: @@ -708,7 +718,7 @@ end -- Make sure the shrading.weight configuration parameter is set -- correctly in vshard. g.test_weight = function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + skip_if_no_vshard() local dir = treegen.prepare_directory(g, {}, {}) local config = [[ credentials: diff --git a/test/config-luatest/vshard_upgrade_test.lua b/test/config-luatest/vshard_upgrade_test.lua index f5538c7a1a7653e8a281bbdb42824f96225abc67..2a6620e8ddf9157948b61742b4b87885e7f093dc 100644 --- a/test/config-luatest/vshard_upgrade_test.lua +++ b/test/config-luatest/vshard_upgrade_test.lua @@ -7,7 +7,10 @@ local fio = require('fio') local g = t.group() -local has_vshard = pcall(require, 'vshard') +local has_vshard = pcall(require, 'vshard-ee') +if not has_vshard then + has_vshard = pcall(require, 'vshard') +end -- -- Test, that Tarantool upgrade with vshard happens without downtime: @@ -20,7 +23,7 @@ local has_vshard = pcall(require, 'vshard') -- 6. Vshard works after all names are applied. -- g.before_all(function(g) - t.skip_if(not has_vshard, 'Module "vshard" is not available') + t.skip_if(not has_vshard, 'Module "vshard-ee/vshard" is not available') treegen.init(g) local uuids = { ['rs-001'] = 'cbf06940-0790-498b-948d-042b62cf3d29',