-
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.
cfg: allow uri of any type, not only string
Since 2.10.0-beta2 URI in all APIs can be passed not only as a string or number but also as a table. The table can be used to pass options like transport type (plain, SSL), encryption certificate and key, and potentially more. VShard always supported only string URIs but now it allows numbers and tables as well. In the config the replica_object.uri field is affected by the change. Part of #325
- Loading branch information
Showing
4 changed files
with
54 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local t = require('luatest') | ||
local lcfg = require('vshard.cfg') | ||
local uuid = require('uuid') | ||
|
||
local g = t.group('config') | ||
|
||
g.test_basic_uri = function() | ||
local url = 'storage:storage@127.0.0.1:3301' | ||
local storage_1_a = { | ||
uri = url, | ||
name = 'storage_1_a', | ||
} | ||
local config = { | ||
sharding = { | ||
storage_1_uuid = { | ||
replicas = { | ||
storage_1_a_uuid = storage_1_a, | ||
} | ||
}, | ||
}, | ||
} | ||
t.assert(lcfg.check(config), 'normal uri') | ||
|
||
storage_1_a.uri = {url} | ||
t.assert(lcfg.check(config), 'table uri') | ||
|
||
storage_1_a.uri = {url, params = {transport = 'plain'}} | ||
t.assert(lcfg.check(config), 'uri with options') | ||
|
||
storage_1_a.uri = 3301 | ||
t.assert(lcfg.check(config), 'number uri') | ||
|
||
storage_1_a.uri = 'bad uri ###' | ||
t.assert_error(lcfg.check, config) | ||
|
||
storage_1_a.uri = {} | ||
t.assert_error(lcfg.check, config) | ||
|
||
storage_1_a.uri = nil | ||
t.assert_error(lcfg.check, config) | ||
|
||
storage_1_a.uri = uuid.new() | ||
t.assert_error(lcfg.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