-
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.
rebalancer: introduce rebalancer flag
The flags allows to explicitly assign the rebalancer role to a specific instance or a replicaset. Or forbid its automatic assignment to instances or whole replicasets. Part of #432 NO_DOC=in the final commit with rebalancer options
- Loading branch information
Showing
5 changed files
with
219 additions
and
5 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 |
---|---|---|
|
@@ -128,3 +128,86 @@ g.test_extract_vshard = function() | |
replication_timeout = 10, | ||
}) | ||
end | ||
|
||
g.test_rebalancer_flag = function() | ||
local storage_1_a = { | ||
uri = 'storage:[email protected]:3301', | ||
name = 'storage_1_a', | ||
} | ||
local replicaset_1 = { | ||
replicas = { | ||
storage_1_a_uuid = storage_1_a, | ||
}, | ||
} | ||
local storage_2_a = { | ||
uri = 'storage:[email protected]:3302', | ||
name = 'storage_2_a', | ||
} | ||
local replicaset_2 = { | ||
replicas = { | ||
storage_2_a_uuid = storage_2_a, | ||
}, | ||
} | ||
local config = { | ||
sharding = { | ||
storage_1_uuid = replicaset_1, | ||
storage_2_uuid = replicaset_2, | ||
}, | ||
} | ||
t.assert(vcfg.check(config)) | ||
-- | ||
-- Bad replica-rebalancer flag. | ||
-- | ||
storage_1_a.rebalancer = 'test' | ||
t.assert_error_msg_content_equals( | ||
'Rebalancer flag must be boolean', vcfg.check, config) | ||
storage_1_a.rebalancer = nil | ||
-- | ||
-- Bad replicaset-rebalancer flag. | ||
-- | ||
replicaset_1.rebalancer = 'test' | ||
t.assert_error_msg_content_equals( | ||
'Rebalancer flag must be boolean', vcfg.check, config) | ||
replicaset_1.rebalancer = nil | ||
-- | ||
-- Rebalancer flag for a replicaset and an instance. | ||
-- | ||
storage_1_a.rebalancer = true | ||
replicaset_1.rebalancer = true | ||
t.assert_error_msg_content_equals( | ||
'Found 2 rebalancer flags at storage_1_uuid and storage_1_a_uuid', | ||
vcfg.check, config) | ||
storage_1_a.rebalancer = nil | ||
replicaset_1.rebalancer = nil | ||
-- | ||
-- Rebalancer flag for 2 replicasets. | ||
-- | ||
replicaset_1.rebalancer = true | ||
replicaset_2.rebalancer = true | ||
t.assert_error_msg_content_equals( | ||
'Found 2 rebalancer flags at storage_1_uuid and storage_2_uuid', | ||
vcfg.check, config) | ||
replicaset_1.rebalancer = nil | ||
replicaset_2.rebalancer = nil | ||
-- | ||
-- Rebalancer flag for 2 instances. | ||
-- | ||
storage_1_a.rebalancer = true | ||
storage_2_a.rebalancer = true | ||
t.assert_error_msg_content_equals( | ||
'Found 2 rebalancer flags at storage_1_a_uuid and storage_2_a_uuid', | ||
vcfg.check, config) | ||
storage_1_a.rebalancer = nil | ||
storage_2_a.rebalancer = nil | ||
-- | ||
-- Conflicting rebalancer flag in one replicaset. | ||
-- | ||
replicaset_1.rebalancer = false | ||
storage_1_a.rebalancer = true | ||
t.assert_error_msg_content_equals( | ||
'Replicaset storage_1_uuid can\'t run the rebalancer, and yet it was '.. | ||
'explicitly assigned to its instance storage_1_a_uuid', | ||
vcfg.check, config) | ||
replicaset_1.rebalancer = nil | ||
storage_1_a.rebalancer = nil | ||
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