forked from tarantool/vshard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part of tarantool#426 @TarantoolBot document Title: vshard: config identification mode The option `identification_mode` should be specified in the root of the config. It can have one of those values: * `'uuid_as_key'` - default. Means, that default uuid config identification is used. replica.name is allowed and should not be interpreted as `box.cfg.instance_name`. replica/replicaset.uuid is forbidden. The config should have the following format: ``` { ['cbf06940-0790-498b-948d-042b62cf3d29'] = { -- replicaset tarantool#1 replicas = { ['8a274925-a26d-47fc-9e1b-af88ce939412'] = { name = 'storage_1_a', ... }, ... }, }, ... } ``` * `'name_as_key'`. Name identification is used, supported only by Tarantool >= 3.0.0. It's forbidden to specify replica.name in such format. UUIDs are optional and can be specified via replicaset/replica.uuid: ``` { replicaset_1 = { uuid = 'cbf06940-0790-498b-948d-042b62cf3d29', replicas = { replica_1_a = { uuid = '8a274925-a26d-47fc-9e1b-af88ce939412' ... }, ... } }, ... } ``` Note, that names, used as keys in config are passed to box.cfg.replicaset/instance_name for storage. In case of reconfiguration it's strictly validated, that both replicaset and instance name corresponds to the passed config. Vshard doesn't deal with changing or setting names, it must be done externally (using Tarantool's config module, for example).
- Loading branch information
1 parent
c25d649
commit 2a4f4ac
Showing
4 changed files
with
168 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,3 +310,85 @@ g.test_enum = function() | |
vcfg.check, config) | ||
config.schema_management_mode = nil | ||
end | ||
|
||
g.test_enum_identification_mode = function() | ||
t.run_only_if(vutil.feature.persistent_names) | ||
local config = { | ||
sharding = { | ||
storage_1_uuid = { | ||
replicas = {} | ||
}, | ||
}, | ||
} | ||
-- Test enum identification_mode. | ||
for _, v in pairs({'uuid_as_key', 'name_as_key'}) do | ||
config.identification_mode = v | ||
t.assert(vcfg.check(config)) | ||
end | ||
config.identification_mode = 'bad' | ||
t.assert_error_msg_content_equals( | ||
"Config identification mode must be enum " .. | ||
"{'uuid_as_key', 'name_as_key', nil}", | ||
vcfg.check, config) | ||
config.identification_mode = nil | ||
end | ||
|
||
g.test_identification_mode_name_as_key = function() | ||
t.run_only_if(vutil.feature.persistent_names) | ||
local storage_1_a = { | ||
uuid = 'storage_1_a_uuid', | ||
uri = 'storage:[email protected]:3301', | ||
} | ||
local replicaset_1 = { | ||
uuid = 'replicaset_1_uuid', | ||
replicas = { | ||
storage_1_a = storage_1_a, | ||
}, | ||
} | ||
local config = { | ||
identification_mode = 'name_as_key', | ||
sharding = { | ||
replicaset_1 = replicaset_1, | ||
}, | ||
} | ||
|
||
-- UUID is optional. | ||
storage_1_a.uuid = nil | ||
replicaset_1.uuid = nil | ||
t.assert(vcfg.check(config)) | ||
|
||
-- replica.name is forbidden. | ||
storage_1_a.name = 'name' | ||
t.assert_error_msg_content_equals( | ||
'replica.name can be specified only when ' .. | ||
'identification_mode = "uuid_as_key"', vcfg.check, config) | ||
end | ||
|
||
g.test_identification_mode_uuid_as_key = function() | ||
local storage_1_a = { | ||
name = 'storage_1_a', | ||
uri = 'storage:[email protected]:3301', | ||
} | ||
local replicaset_1 = { | ||
replicas = { | ||
storage_1_a_uuid = storage_1_a, | ||
}, | ||
} | ||
local config = { | ||
identification_mode = 'uuid_as_key', | ||
sharding = { | ||
replicaset_1_uuid = replicaset_1, | ||
}, | ||
} | ||
t.assert(vcfg.check(config)) | ||
|
||
-- replica.name is optional. | ||
storage_1_a.name = nil | ||
t.assert(vcfg.check(config)) | ||
|
||
-- replicaset/replica.uuid is forbidden. | ||
storage_1_a.uuid = 'uuid' | ||
t.assert_error_msg_content_equals( | ||
'uuid option can be specified only when ' .. | ||
'identification_mode = "name_as_key"', vcfg.check, config) | ||
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