Sha256: 3745d316a6f00aebd87a80f8e93a3edbee85f8226828b3816d7fa626c1e97a9f

Contents?: true

Size: 1.71 KB

Versions: 16

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

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) { Mrss::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: %w(isMaster hello),
          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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/integration/sdam_prose_spec.rb
mongo-2.17.4 spec/integration/sdam_prose_spec.rb
mongo-2.18.3 spec/integration/sdam_prose_spec.rb
mongo-2.18.2 spec/integration/sdam_prose_spec.rb
mongo-2.17.3 spec/integration/sdam_prose_spec.rb
mongo-2.18.1 spec/integration/sdam_prose_spec.rb
mongo-2.18.0 spec/integration/sdam_prose_spec.rb
mongo-2.17.2 spec/integration/sdam_prose_spec.rb
mongo-2.16.3 spec/integration/sdam_prose_spec.rb
mongo-2.18.0.beta1 spec/integration/sdam_prose_spec.rb
mongo-2.16.2 spec/integration/sdam_prose_spec.rb
mongo-2.17.1 spec/integration/sdam_prose_spec.rb
mongo-2.16.1 spec/integration/sdam_prose_spec.rb
mongo-2.17.0 spec/integration/sdam_prose_spec.rb
mongo-2.16.0 spec/integration/sdam_prose_spec.rb
mongo-2.16.0.alpha1 spec/integration/sdam_prose_spec.rb