minor: replica set test improvements
This commit is contained in:
parent
01d1231373
commit
3e2c4c3851
|
@ -46,7 +46,6 @@ class ReplSetManager
|
||||||
def start_set
|
def start_set
|
||||||
system("killall mongod")
|
system("killall mongod")
|
||||||
sleep(1)
|
sleep(1)
|
||||||
p system("ps aux | grep mongod")
|
|
||||||
should_start = true
|
should_start = true
|
||||||
puts "** Starting a replica set with #{@count} nodes"
|
puts "** Starting a replica set with #{@count} nodes"
|
||||||
|
|
||||||
|
@ -75,7 +74,6 @@ class ReplSetManager
|
||||||
end
|
end
|
||||||
|
|
||||||
initiate
|
initiate
|
||||||
p system("ps aux | grep mongod")
|
|
||||||
ensure_up
|
ensure_up
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -243,7 +241,12 @@ class ReplSetManager
|
||||||
attempt(n) do
|
attempt(n) do
|
||||||
print "."
|
print "."
|
||||||
con = connection || get_connection
|
con = connection || get_connection
|
||||||
status = con['admin'].command({:replSetGetStatus => 1})
|
begin
|
||||||
|
status = con['admin'].command({:replSetGetStatus => 1})
|
||||||
|
rescue Mongo::OperationFailure => ex
|
||||||
|
con.close
|
||||||
|
raise ex
|
||||||
|
end
|
||||||
if status['members'].all? { |m| m['health'] == 1 &&
|
if status['members'].all? { |m| m['health'] == 1 &&
|
||||||
[1, 2, 7].include?(m['state']) } &&
|
[1, 2, 7].include?(m['state']) } &&
|
||||||
status['members'].any? { |m| m['state'] == 1 }
|
status['members'].any? { |m| m['state'] == 1 }
|
||||||
|
@ -254,12 +257,13 @@ class ReplSetManager
|
||||||
begin
|
begin
|
||||||
host, port = member['name'].split(':')
|
host, port = member['name'].split(':')
|
||||||
port = port.to_i
|
port = port.to_i
|
||||||
con = Mongo::Connection.new(host, port, :slave_ok => true)
|
conn = Mongo::Connection.new(host, port, :slave_ok => true)
|
||||||
connections << con
|
connections << conn
|
||||||
state = con['admin'].command({:ismaster => 1})
|
state = conn['admin'].command({:ismaster => 1})
|
||||||
states << state
|
states << state
|
||||||
rescue ConnectionFailure
|
rescue Mongo::ConnectionFailure
|
||||||
connections.each {|c| c.close }
|
connections.each {|c| c.close }
|
||||||
|
con.close
|
||||||
raise Mongo::OperationFailure
|
raise Mongo::OperationFailure
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -270,6 +274,7 @@ class ReplSetManager
|
||||||
con.close
|
con.close
|
||||||
return status
|
return status
|
||||||
else
|
else
|
||||||
|
con.close
|
||||||
raise Mongo::OperationFailure
|
raise Mongo::OperationFailure
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -310,7 +315,8 @@ class ReplSetManager
|
||||||
con = get_connection
|
con = get_connection
|
||||||
|
|
||||||
attempt do
|
attempt do
|
||||||
p con['admin'].command({'replSetInitiate' => @config})
|
con.object_id
|
||||||
|
con['admin'].command({'replSetInitiate' => @config})
|
||||||
end
|
end
|
||||||
|
|
||||||
con.close
|
con.close
|
||||||
|
|
Loading…
Reference in New Issue