spec/mongo/server/monitor_spec.rb in mongo-2.15.0.alpha vs spec/mongo/server/monitor_spec.rb in mongo-2.15.0
- old
+ new
@@ -1,5 +1,8 @@
+# frozen_string_literal: true
+# encoding: utf-8
+
require 'spec_helper'
describe Mongo::Server::Monitor do
before(:all) do
ClientRegistry.instance.close_all_clients
@@ -54,24 +57,24 @@
monitor.scan!
expect(Time.now - start).to be >= 0.5
end
end
- context 'when the ismaster fails the first time' do
+ context 'when the hello fails the first time' do
let(:monitor_options) do
{monitoring_io: false}
end
it 'runs sdam flow on unknown description' do
- expect(monitor).to receive(:ismaster).once.and_raise(Mongo::Error::SocketError)
+ expect(monitor).to receive(:check).once.and_raise(Mongo::Error::SocketError)
expect(cluster).to receive(:run_sdam_flow)
monitor.scan!
end
end
- context 'when the ismaster command succeeds' do
+ context 'when the hello command succeeds' do
it 'invokes sdam flow' do
server.unknown!
expect(server.description).to be_unknown
@@ -83,11 +86,11 @@
expect(updated_desc).not_to be_unknown
end
end
- context 'when the ismaster command fails' do
+ context 'when the hello command fails' do
context 'when no server is running on the address' do
let(:address) do
Mongo::Address.new('127.0.0.1:27050')
@@ -111,11 +114,11 @@
end
before do
server.unknown!
expect(server.description).to be_unknown
- expect(monitor).to receive(:ismaster).and_raise(Mongo::Error::SocketError)
+ expect(monitor).to receive(:check).and_raise(Mongo::Error::SocketError)
monitor.scan!
end
it 'keeps the server unknown' do
expect(server.description).to be_unknown
@@ -260,24 +263,24 @@
it 'is successful' do
expect(result['ok']).to eq(1.0)
end
- context 'network error during ismaster' do
+ context 'network error during check' do
let(:result) do
- expect(monitor).to receive(:ismaster).and_raise(IOError)
+ expect(monitor).to receive(:check).and_raise(IOError)
# The retry is done on a new socket instance.
#expect(socket).to receive(:write).and_call_original
monitor.send(:do_scan)
end
it 'adds server diagnostics' do
expect(Mongo::Logger.logger).to receive(:warn) do |msg|
# The "on <address>" and "for <address>" bits are in different parts
# of the message.
- expect(msg).to match(/on #{server.address}/)
+ expect(msg).to match(/#{server.address}/)
end
expect(result).to be_a(Hash)
end
end
@@ -311,11 +314,11 @@
# It is correct in raising Error::SocketError if mocking write
# which performs exception mapping.
expect_any_instance_of(Mongo::Socket).to receive(:write).and_raise(Mongo::Error::SocketError, 'test error')
expect do
- monitor.send(:ismaster)
- end.to raise_error(Mongo::Error::SocketError, /on #{server.address}/)
+ monitor.send(:check)
+ end.to raise_error(Mongo::Error::SocketError, /#{server.address}/)
end
end
end
end