gobeetle: fixed that slaves would not be properly reconnected to new master
gobeetle: fixed that slaves would not be properly reconnected to new master
MODIFY
features/redis_auto_failover.feature
features/redis_auto_failover.feature
@@ -24,6 +24,26 @@ Feature: Redis auto failover
Given a redis server "redis-1" exists as master
Then the role of redis server "redis-1" should be "slave"
+ Scenario: Successful redis master switch with multiple slaves
+ And a redis server "redis-3" exists as slave of "redis-3"
+ Given a redis configuration server using redis servers "redis-1,redis-2,redis-3" with clients "rc-client-1,rc-client-2" exists
+ And a redis configuration client "rc-client-1" using redis servers "redis-1,redis-2,redis-3" exists
+ And a redis configuration client "rc-client-2" using redis servers "redis-1,redis-2,redis-3" exists
+ And a beetle handler using the redis-master file from "rc-client-1" exists
+ And redis server "redis-1" is down
+ And the retry timeout for the redis master check is reached
+ Then a system notification for "redis-1" not being available should be sent
+ And the role of redis server "redis-2" should be "master"
+ And the redis master file of the redis configuration server should contain "redis-2"
+ And the redis master of "rc-client-1" should be "redis-2"
+ And the redis master of "rc-client-2" should be "redis-2"
+ And the redis master of the beetle handler should be "redis-2"
+ And a system notification for switching from "redis-1" to "redis-2" should be sent
+ Given a redis server "redis-1" exists as master
+ Then the role of redis server "redis-1" should be "slave"
+ And the redis server "redis-1" is a slave of "redis-2"
+ And the redis server "redis-3" is a slave of "redis-2"
+
Scenario: Successful single redis master switch with multiple failover sets
Given a redis server "redis-3" exists as master
And a redis server "redis-4" exists as slave of "redis-3"

MODIFY
features/step_definitions/redis_auto_failover_steps.rb
features/step_definitions/redis_auto_failover_steps.rb
@@ -93,7 +93,6 @@ Given /^an old redis master file for "([^\"]*)" with master "([^\"]*)" exists$/
end
end
-
Then /^the role of redis server "([^\"]*)" should be "(master|slave)"$/ do |redis_name, role|
expected_role = false
10.times do
@@ -103,6 +102,16 @@ Then /^the role of redis server "([^\"]*)" should be "(master|slave)"$/ do |redi
assert expected_role, "#{redis_name} is not a #{role}"
end
+Then /^the redis server "([^\"]*)" is a slave of "([^\"]*)"$/ do |redis_name, redis_master_name|
+ master = TestDaemons::Redis[redis_master_name].redis
+ slave = TestDaemons::Redis[redis_name].redis
+ 3.times do
+ sleep 1
+ break if slave.slave_of?(master.host, master.port)
+ end
+ assert slave.slave_of?(master.host, master.port)
+end
+
Then /^the redis master of "([^\"]*)" (?:in system "([^"]*)" )?should be "([^\"]*)"$/ do |redis_configuration_client_name, system_name, redis_name|
system_name ||= "system"
master_file = redis_master_file(redis_configuration_client_name)

MODIFY
go/failover_state.go
go/failover_state.go
@@ -287,15 +287,13 @@ func (s *FailoverState) PublishMaster(server string) {
s.SendToWebSockets(msg)
}
-// ConfigureSlaves turns all masters which are not the currently configured
-// master into slaves of the current master.
+// ConfigureSlaves turns all available servers into slaves of the current master.
func (s *FailoverState) ConfigureSlaves(master *RedisShim) {
- for _, r := range s.redis.Masters() {
+ for _, r := range s.redis.MastersAndSlaves() {
if r.server != master.server {
r.redis.SlaveOf(master.host, strconv.Itoa(master.port))
}
}
- // TODO: shouldn't we also make sure all slaves are slaves of the correct master?
}
// WatcherPaused checks whether the redis watcher has been paused.

MODIFY
go/redis_server_info.go
go/redis_server_info.go
@@ -21,7 +21,7 @@ func (shims RedisShims) Include(r *RedisShim) bool {
return false
}
-// Servers returns a slice od server strings (host:port format).
+// Servers returns a slice of server strings (host:port format).
func (shims RedisShims) Servers() []string {
servers := make([]string, 0)
for _, x := range shims {
@@ -100,6 +100,14 @@ func (si *RedisServerInfo) Slaves() RedisShims {
return si.serverInfo[SLAVE]
}
+// MastersAndSlaves returns masters ans slaves
+func (si *RedisServerInfo) MastersAndSlaves() RedisShims {
+ servers := make(RedisShims, 0)
+ servers = append(servers, si.Masters()...)
+ servers = append(servers, si.Slaves()...)
+ return servers
+}
+
// Unknowns returns all shims with role 'unknown'.
func (si *RedisServerInfo) Unknowns() RedisShims {
return si.serverInfo[UNKNOWN]

gobeetle: fixed that slaves would not be properly reconnected to new master (#83)

gobeetle: fixed that slaves would not be properly reconnected to new master