spec/support/cluster_tools.rb
def unfreeze_server(address)
    begin
      direct_client(address).use('admin').database.command(replSetFreeze: 0)
    rescue Mongo::Error::OperationFailure => e
      # Mongo::Error::OperationFailure: cannot freeze node when primary or running for election. state: Primary (95)
      if e.code == 95
        # The server we want to become primary may have already become the
        # primary by holding a spontaneous election and winning due to the
        # priorities we have set.
        admin_client.cluster.servers_list.each do |server|
          server.unknown!
        end
        if admin_client.cluster.next_primary.address == address
          puts "#{Time.now} [CT] Primary self-elected to #{address}"
          return true
        end
      end
      raise
    end
    false
  end
# Allows the server at the specified address to run for elections and
# potentially become a primary. Use after issuing a step down command
# to clear the prohibtion on the stepped down server to be a primary.
#
# Returns true if the server at address became a primary, such that
# a step up command is not necessary.
Allows the server at the specified address to run for elections and
potentially become a primary. Use after issuing a step down command
to clear the prohibtion on the stepped down server to be a primary.

Returns true if the server at address became a primary, such that
a step up command is not necessary.
Allows the server at the specified address to run for elections and potentially become a primary . Use after issuing a step down command to clear the prohibtion on the stepped down server to be a primary . Returns true if the server at address became a primary such that a step up command is not necessary .
def unfreeze_server(address)
    begin
      direct_client(address).use('admin').database.command(replSetFreeze: 0)
    rescue Mongo::Error::OperationFailure => e
      if e.code == 95
        admin_client.cluster.servers_list.each do |server|
          server.unknown!
        end
        if admin_client.cluster.next_primary.address == address
          puts "#{Time.now} [CT] Primary self-elected to #{address}"
          return true
        end
      end
      raise
    end
    false
  end
def unfreeze_server ( address ) begin direct_client ( address ) . use ( 'admin' ) . database . command ( replSetFreeze : 0 ) rescue Mongo :: Error :: OperationFailure => e if e . code == 95 admin_client . cluster . servers_list . each do | server | server . unknown! end if admin_client . cluster . next_primary . address == address puts "#{Time.now} [CT] Primary self-elected to #{address}" return true end end raise end false end
Allows the server at the specified address to run for elections and
potentially become a primary.
Allows the server at the specified address to run for elections and potentially become a primary .
# Mongo::Error::OperationFailure: cannot freeze node when primary or running for election. state: Primary (95) # The server we want to become primary may have already become the # primary by holding a spontaneous election and winning due to the # priorities we have set.
address