-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: introduce user_management_mode cfg
Closes #435 @TarantoolBot document Title: vshard: `user_management_mode` cfg option The option can be specified at the root level and regulates how much vshard is involved into the user management. When specified to 'auto' (default), vshard will create the user as specified in the config URIs, and will grant it all needed rights to public and internal APIs. When specified to 'manual', vshard will neither create the user, nor grant it any rights. It is all expected to be done externally outside of vshard.
- Loading branch information
Showing
5 changed files
with
176 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
local t = require('luatest') | ||
local vtest = require('test.luatest_helpers.vtest') | ||
|
||
local test_group = t.group('storage') | ||
|
||
test_group.after_each(function(g) | ||
g.cluster:drop() | ||
g.cluster = nil | ||
end) | ||
|
||
test_group.test_user_management_mode_boot_auto = function(g) | ||
local cfg_template = { | ||
sharding = { | ||
{ | ||
replicas = { | ||
replica_1_a = {master = true}, | ||
replica_1_b = {}, | ||
}, | ||
}, | ||
{ | ||
replicas = { | ||
replica_2_a = {master = true}, | ||
}, | ||
}, | ||
}, | ||
bucket_count = 2, | ||
user_management_mode = 'auto', | ||
} | ||
local cfg = vtest.config_new(cfg_template) | ||
vtest.cluster_new(g, cfg) | ||
vtest.cluster_bootstrap(g, cfg) | ||
local bid = g.replica_1_a:exec(function(uuid) | ||
local bid = _G.get_first_bucket() | ||
local ok, err = ivshard.storage.bucket_send(bid, uuid, | ||
{timeout = iwait_timeout}) | ||
ilt.assert_equals(err, nil) | ||
ilt.assert(ok) | ||
_G.bucket_gc_wait() | ||
return bid | ||
end, {g.replica_2_a:replicaset_uuid()}) | ||
-- | ||
-- Switch to manual. Still works fine. | ||
-- | ||
cfg_template.user_management_mode = 'manual' | ||
cfg = vtest.config_new(cfg_template) | ||
vtest.cluster_cfg(g, cfg) | ||
g.replica_2_a:exec(function(bid, uuid) | ||
local ok, err = ivshard.storage.bucket_send(bid, uuid, | ||
{timeout = iwait_timeout}) | ||
ilt.assert_equals(err, nil) | ||
ilt.assert(ok) | ||
_G.bucket_gc_wait() | ||
end, {bid, g.replica_1_a:replicaset_uuid()}) | ||
end | ||
|
||
test_group.test_user_management_mode_boot_manual_only_replication = function(g) | ||
local cfg_template = { | ||
sharding = { | ||
{ | ||
replicas = { | ||
replica_1_a = {master = true}, | ||
replica_1_b = {}, | ||
}, | ||
}, | ||
{ | ||
replicas = { | ||
replica_2_a = {master = true}, | ||
}, | ||
}, | ||
}, | ||
bucket_count = 2, | ||
user_management_mode = 'manual', | ||
test_user_grant_range = 'replication', | ||
} | ||
local cfg = vtest.config_new(cfg_template) | ||
vtest.cluster_new(g, cfg) | ||
vtest.cluster_bootstrap(g, cfg) | ||
-- | ||
-- Just replication rights are not enough for vshard operation. It will | ||
-- boot, but any vshard operations between instances won't work. | ||
-- | ||
g.replica_1_a:exec(function(uuid) | ||
local bid = _G.get_first_bucket() | ||
local ok, err = ivshard.storage.bucket_send(bid, uuid, | ||
{timeout = iwait_timeout}) | ||
if ivutil.version_is_at_least(2, 7, 0, nil, 0, 0) then | ||
ilt.assert_equals(err.type, 'AccessDeniedError') | ||
end | ||
ilt.assert_str_contains(err.message, 'bucket_recv') | ||
ilt.assert(not ok) | ||
end, {g.replica_2_a:replicaset_uuid()}) | ||
end | ||
|
||
test_group.test_user_management_mode_boot_manual_super = function(g) | ||
local cfg_template = { | ||
sharding = { | ||
{ | ||
replicas = { | ||
replica_1_a = {master = true}, | ||
replica_1_b = {}, | ||
}, | ||
}, | ||
{ | ||
replicas = { | ||
replica_2_a = {master = true}, | ||
}, | ||
}, | ||
}, | ||
bucket_count = 2, | ||
user_management_mode = 'manual', | ||
test_user_grant_range = 'super', | ||
} | ||
local cfg = vtest.config_new(cfg_template) | ||
vtest.cluster_new(g, cfg) | ||
vtest.cluster_bootstrap(g, cfg) | ||
local bid = g.replica_1_a:exec(function(uuid) | ||
local bid = _G.get_first_bucket() | ||
local ok, err = ivshard.storage.bucket_send(bid, uuid, | ||
{timeout = iwait_timeout}) | ||
ilt.assert_equals(err, nil) | ||
ilt.assert(ok) | ||
_G.bucket_gc_wait() | ||
return bid | ||
end, {g.replica_2_a:replicaset_uuid()}) | ||
-- | ||
-- Switch to auto. Still works fine. | ||
-- | ||
cfg_template.user_management_mode = 'auto' | ||
cfg = vtest.config_new(cfg_template) | ||
vtest.cluster_cfg(g, cfg) | ||
g.replica_2_a:exec(function(bid, uuid) | ||
local ok, err = ivshard.storage.bucket_send(bid, uuid, | ||
{timeout = iwait_timeout}) | ||
ilt.assert_equals(err, nil) | ||
ilt.assert(ok) | ||
_G.bucket_gc_wait() | ||
end, {bid, g.replica_1_a:replicaset_uuid()}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters