-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replicaset: properly compare table URIs
URI comparison is used in order not to recreate netbox connections on storage/router reconfig. For tables it wasn't working properly when compared the tables by values. The patch introduces deep comparison. For example, now {3313} and 3313 are considered the same URI. If such a change happened in vshard config, it won't lead to a reconnect. Closes #325
- Loading branch information
Showing
4 changed files
with
155 additions
and
1 deletion.
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,83 @@ | ||
local t = require('luatest') | ||
local uuid = require('uuid') | ||
local util = require('vshard.util') | ||
|
||
local g = t.group('util') | ||
|
||
g.test_uri_eq = function() | ||
local uri_eq = util.uri_eq | ||
-- | ||
-- Equal. | ||
-- | ||
t.assert(uri_eq(1, 1)) | ||
t.assert(uri_eq('1', '1')) | ||
t.assert(uri_eq({1}, 1)) | ||
t.assert(uri_eq(1, {1})) | ||
t.assert(uri_eq('1', {'1'})) | ||
t.assert(uri_eq({'1'}, '1')) | ||
t.assert(uri_eq({'1'}, {'1'})) | ||
t.assert(uri_eq({1}, {1})) | ||
|
||
t.assert(uri_eq(1, '1')) | ||
t.assert(uri_eq('1', 1)) | ||
t.assert(uri_eq({'1'}, 1)) | ||
t.assert(uri_eq('1', {1})) | ||
t.assert(uri_eq({1}, '1')) | ||
t.assert(uri_eq(1, {'1'})) | ||
t.assert(uri_eq({1}, {'1'})) | ||
t.assert(uri_eq({'1'}, {1})) | ||
|
||
t.assert(uri_eq({ | ||
1, params = {key1 = 10, key2 = 20} | ||
}, { | ||
1, params = {key1 = 10, key2 = 20} | ||
})) | ||
|
||
t.assert(uri_eq({ | ||
'1', params = {key1 = 10, key2 = '20'} | ||
}, { | ||
1, params = {key1 = 10, key2 = 20} | ||
})) | ||
|
||
t.assert(uri_eq({ | ||
1, params = {key1 = {'10', 20}, key2 = 30} | ||
}, { | ||
'1', params = {key1 = {10, 20}, key2 = 30} | ||
})) | ||
|
||
t.assert(uri_eq( | ||
'localhost:1?key1=10&key1=20&key2=30', | ||
{'localhost:1', params = {key1 = {10, 20}, key2 = 30}} | ||
)) | ||
-- | ||
-- Not equal. | ||
-- | ||
t.assert(not uri_eq(1, 2)) | ||
t.assert(not uri_eq('1', '2')) | ||
|
||
t.assert(not uri_eq({ | ||
1, params = {key1 = 10, key2 = 20} | ||
}, { | ||
1, params = {key1 = 20, key2 = 10} | ||
})) | ||
|
||
t.assert(not uri_eq({ | ||
'1', params = {key1 = 10} | ||
}, { | ||
1, params = {key1 = 10, key2 = 20} | ||
})) | ||
|
||
t.assert(not uri_eq({ | ||
1, params = {key1 = {10}, key2 = 30} | ||
}, { | ||
1, params = {key1 = {10, 20}, key2 = 30} | ||
})) | ||
|
||
t.assert(not uri_eq( | ||
'localhost:1?key1=10&key1=20&key2=30', | ||
{'localhost:1', params = {key1 = {20, 10}, key2 = 30}} | ||
)) | ||
|
||
t.assert_error(uri_eq, 1, uuid.new()) | ||
t.assert_error(uri_eq, nil, 1) | ||
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