File: awaited_ismaster_spec.rb

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (31 lines) | stat: -rw-r--r-- 844 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

describe 'awaited hello' do
  min_server_fcv '4.4'

  # If we send the consecutive hello commands to different mongoses,
  # they have different process ids, and so the awaited one would return
  # immediately.
  require_no_multi_mongos

  let(:client) { authorized_client }

  it 'waits' do
    # Perform a regular hello to get topology version
    resp = client.database.command(hello: 1)
    doc = resp.replies.first.documents.first
    tv = Mongo::TopologyVersion.new(doc['topologyVersion'])
    tv.should be_a(BSON::Document)

    elapsed_time = Benchmark.realtime do
      resp = client.database.command(hello: 1,
        topologyVersion: tv.to_doc, maxAwaitTimeMS: 500)
    end
    doc = resp.replies.first.documents.first

    elapsed_time.should > 0.5
  end
end