Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/mongo/server/monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,13 @@ def run_sdam_flow(result, awaited: false)
server.cluster.run_sdam_flow(server.description, new_description, awaited: awaited)

server.description.tap do |new_description|
if new_description.unknown? && !old_description.unknown?
@next_earliest_scan = @next_wanted_scan = Time.now
else
@next_earliest_scan = Time.now + MIN_SCAN_INTERVAL
@next_wanted_scan = Time.now + heartbeat_interval
unless awaited
if new_description.unknown? && !old_description.unknown?
@next_earliest_scan = @next_wanted_scan = Time.now
else
@next_earliest_scan = Time.now + MIN_SCAN_INTERVAL
@next_wanted_scan = Time.now + heartbeat_interval
end
end
end
end
Expand Down
64 changes: 64 additions & 0 deletions spec/integration/sdam_prose_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require 'spec_helper'

describe 'SDAM prose tests' do
# The "streaming protocol tests" are covered by the tests in
# sdam_events_spec.rb.

describe 'RTT tests' do
min_server_fcv '4.4'
require_topology :single

let(:subscriber) { EventSubscriber.new }

let(:client) do
new_local_client(SpecConfig.instance.addresses,
# Heartbeat interval is bound by 500 ms
SpecConfig.instance.test_options.merge(
heartbeat_frequency: 0.5,
app_name: 'streamingRttTest',
),
).tap do |client|
client.subscribe(Mongo::Monitoring::SERVER_HEARTBEAT, subscriber)
end
end

it 'updates RTT' do
server = client.cluster.next_primary

sleep 2

events = subscriber.select_succeeded_events(Mongo::Monitoring::Event::ServerHeartbeatSucceeded)
events.each do |event|
event.round_trip_time.should be_a(Numeric)
event.round_trip_time.should > 0
end

root_authorized_client.use('admin').database.command(
configureFailPoint: 'failCommand',
mode: {times: 1000},
data: {
failCommands: ["isMaster"],
blockConnection: true,
blockTimeMS: 500,
appName: "streamingRttTest",
},
)

deadline = Time.now + 10
loop do
if server.average_round_trip_time > 0.25
break
end
if Time.now >= deadline
raise "Failed to witness RTT growing to >= 250 ms in 10 seconds"
end
sleep 0.2
end
end

after do
root_authorized_client.use('admin').database.command(
configureFailPoint: 'failCommand', mode: 'off')
end
end
end