mongo 2.4.0.rc1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/auth/cr/conversation.rb +1 -1
  5. data/lib/mongo/auth/ldap/conversation.rb +1 -1
  6. data/lib/mongo/auth/scram/conversation.rb +1 -1
  7. data/lib/mongo/auth/x509/conversation.rb +4 -2
  8. data/lib/mongo/client.rb +7 -4
  9. data/lib/mongo/cluster.rb +55 -5
  10. data/lib/mongo/cluster/app_metadata.rb +7 -1
  11. data/lib/mongo/cluster/topology.rb +7 -6
  12. data/lib/mongo/cluster/topology/replica_set.rb +48 -2
  13. data/lib/mongo/cluster/topology/sharded.rb +47 -1
  14. data/lib/mongo/cluster/topology/single.rb +55 -4
  15. data/lib/mongo/cluster/topology/unknown.rb +65 -9
  16. data/lib/mongo/error/invalid_server_preference.rb +3 -1
  17. data/lib/mongo/event.rb +8 -0
  18. data/lib/mongo/event/description_changed.rb +20 -2
  19. data/lib/mongo/event/member_discovered.rb +65 -0
  20. data/lib/mongo/event/primary_elected.rb +3 -1
  21. data/lib/mongo/event/standalone_discovered.rb +1 -1
  22. data/lib/mongo/monitoring.rb +41 -0
  23. data/lib/mongo/monitoring/event.rb +6 -0
  24. data/lib/mongo/monitoring/event/server_closed.rb +46 -0
  25. data/lib/mongo/monitoring/event/server_description_changed.rb +58 -0
  26. data/lib/mongo/monitoring/event/server_opening.rb +46 -0
  27. data/lib/mongo/monitoring/event/topology_changed.rb +46 -0
  28. data/lib/mongo/monitoring/event/topology_closed.rb +41 -0
  29. data/lib/mongo/monitoring/event/topology_opening.rb +41 -0
  30. data/lib/mongo/monitoring/publishable.rb +12 -0
  31. data/lib/mongo/monitoring/sdam_log_subscriber.rb +54 -0
  32. data/lib/mongo/monitoring/server_closed_log_subscriber.rb +30 -0
  33. data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +33 -0
  34. data/lib/mongo/monitoring/server_opening_log_subscriber.rb +30 -0
  35. data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +40 -0
  36. data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +30 -0
  37. data/lib/mongo/server.rb +6 -0
  38. data/lib/mongo/server/connection.rb +1 -1
  39. data/lib/mongo/server/description.rb +23 -3
  40. data/lib/mongo/server/description/inspector.rb +4 -2
  41. data/lib/mongo/server/description/inspector/description_changed.rb +2 -2
  42. data/lib/mongo/server/description/inspector/member_discovered.rb +59 -0
  43. data/lib/mongo/server/description/inspector/primary_elected.rb +2 -0
  44. data/lib/mongo/server_selector.rb +10 -5
  45. data/lib/mongo/server_selector/nearest.rb +1 -1
  46. data/lib/mongo/server_selector/primary_preferred.rb +1 -1
  47. data/lib/mongo/server_selector/secondary.rb +1 -1
  48. data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
  49. data/lib/mongo/server_selector/selectable.rb +24 -12
  50. data/lib/mongo/uri.rb +1 -1
  51. data/lib/mongo/version.rb +1 -1
  52. data/mongo.gemspec +1 -1
  53. data/spec/mongo/auth/cr_spec.rb +6 -1
  54. data/spec/mongo/auth/ldap_spec.rb +6 -1
  55. data/spec/mongo/auth/scram_spec.rb +6 -1
  56. data/spec/mongo/auth/x509/conversation_spec.rb +69 -0
  57. data/spec/mongo/auth/x509_spec.rb +9 -4
  58. data/spec/mongo/client_spec.rb +40 -2
  59. data/spec/mongo/cluster/topology/replica_set_spec.rb +218 -9
  60. data/spec/mongo/cluster/topology/sharded_spec.rb +17 -2
  61. data/spec/mongo/cluster/topology/single_spec.rb +19 -4
  62. data/spec/mongo/cluster/topology/unknown_spec.rb +19 -1
  63. data/spec/mongo/cluster/topology_spec.rb +11 -7
  64. data/spec/mongo/cluster_spec.rb +25 -7
  65. data/spec/mongo/max_staleness_spec.rb +40 -22
  66. data/spec/mongo/monitoring_spec.rb +2 -2
  67. data/spec/mongo/sdam_monitoring_spec.rb +60 -0
  68. data/spec/mongo/sdam_spec.rb +77 -0
  69. data/spec/mongo/server/connection_pool_spec.rb +6 -1
  70. data/spec/mongo/server/connection_spec.rb +6 -1
  71. data/spec/mongo/server/description_spec.rb +90 -1
  72. data/spec/mongo/server_selection_spec.rb +7 -6
  73. data/spec/mongo/server_selector/nearest_spec.rb +7 -7
  74. data/spec/mongo/server_selector/primary_preferred_spec.rb +7 -7
  75. data/spec/mongo/server_selector/primary_spec.rb +4 -4
  76. data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
  77. data/spec/mongo/server_selector/secondary_spec.rb +6 -6
  78. data/spec/mongo/server_selector_spec.rb +8 -0
  79. data/spec/mongo/server_spec.rb +6 -1
  80. data/spec/mongo/uri_spec.rb +4 -4
  81. data/spec/spec_helper.rb +2 -0
  82. data/spec/support/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +4 -4
  83. data/spec/support/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
  84. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
  85. data/spec/support/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
  86. data/spec/support/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +15 -0
  87. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +1 -1
  88. data/spec/support/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +3 -3
  89. data/spec/support/max_staleness/ReplicaSetNoPrimary/Secondary.yml +3 -3
  90. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +1 -1
  91. data/spec/support/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +3 -3
  92. data/spec/support/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +23 -0
  93. data/spec/support/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +4 -4
  94. data/spec/support/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +5 -5
  95. data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness2.yml → LongHeartbeat.yml} +4 -4
  96. data/spec/support/max_staleness/ReplicaSetWithPrimary/{ShortHeartbeartShortMaxStaleness.yml → LongHeartbeat2.yml} +6 -10
  97. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +3 -2
  98. data/spec/support/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
  99. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
  100. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
  101. data/spec/support/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +3 -3
  102. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
  103. data/spec/support/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +3 -3
  104. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +1 -1
  105. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +3 -3
  106. data/spec/support/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
  107. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +3 -3
  108. data/spec/support/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
  109. data/spec/support/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +7 -11
  110. data/spec/support/max_staleness/Sharded/Incompatible.yml +4 -4
  111. data/spec/support/max_staleness/Sharded/SmallMaxStaleness.yml +10 -2
  112. data/spec/support/max_staleness/Single/Incompatible.yml +4 -4
  113. data/spec/support/max_staleness/Single/SmallMaxStaleness.yml +2 -2
  114. data/spec/support/max_staleness/Unknown/SmallMaxStaleness.yml +14 -0
  115. data/spec/support/sdam/rs/primary_mismatched_me.yml +2 -2
  116. data/spec/support/sdam/rs/secondary_mismatched_me.yml +2 -2
  117. data/spec/support/sdam_monitoring.rb +144 -0
  118. data/spec/support/sdam_monitoring/replica_set_with_no_primary.yml +112 -0
  119. data/spec/support/sdam_monitoring/replica_set_with_primary.yml +111 -0
  120. data/spec/support/sdam_monitoring/replica_set_with_removal.yml +106 -0
  121. data/spec/support/sdam_monitoring/required_replica_set.yml +84 -0
  122. data/spec/support/sdam_monitoring/standalone.yml +70 -0
  123. data/spec/support/server_discovery_and_monitoring.rb +34 -1
  124. data/spec/support/server_selection.rb +14 -11
  125. data/spec/support/shared/server_selector.rb +6 -0
  126. metadata +49 -13
  127. metadata.gz.sig +0 -0
  128. data/spec/mongo/server_discovery_and_monitoring_spec.rb +0 -115
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Server Discovery and Monitoring' do
4
+ include Mongo::SDAM
5
+
6
+ SERVER_DISCOVERY_TESTS.each do |file|
7
+
8
+ spec = Mongo::SDAM::Spec.new(file)
9
+
10
+ context(spec.description) do
11
+
12
+ before(:all) do
13
+ Mongo::Client.new(spec.uri_string).tap do |client|
14
+ @client = client.with(connect_timeout: 0.1, heartbeat_frequency: 100)
15
+ end.close
16
+ end
17
+
18
+ after(:all) do
19
+ @client.close
20
+ end
21
+
22
+ spec.phases.each_with_index do |phase, index|
23
+
24
+ context("Phase: #{index + 1}") do
25
+
26
+ before(:all) do
27
+ phase.responses.each do |response|
28
+ server = find_server(@client, response.address)
29
+ server ||= Mongo::Server.new(
30
+ Mongo::Address.new(response.address),
31
+ @client.cluster,
32
+ @client.instance_variable_get(:@monitoring),
33
+ @client.cluster.send(:event_listeners),
34
+ @client.cluster.options
35
+ )
36
+ monitor = server.instance_variable_get(:@monitor)
37
+ description = monitor.inspector.run(server.description, response.ismaster, 0.5)
38
+ monitor.instance_variable_set(:@description, description)
39
+ end
40
+ end
41
+
42
+ let(:cluster_addresses) do
43
+ @client.cluster.instance_variable_get(:@servers).
44
+ collect(&:address).collect(&:to_s).uniq.sort
45
+ end
46
+
47
+ let(:phase_addresses) do
48
+ phase.outcome.servers.keys.sort
49
+ end
50
+
51
+ it "sets the cluster topology to #{phase.outcome.topology_type}" do
52
+ expect(@client.cluster).to be_topology(phase.outcome.topology_type)
53
+ end
54
+
55
+ it "sets the cluster replica set name to #{phase.outcome.set_name.inspect}" do
56
+ expect(@client.cluster.replica_set_name).to eq(phase.outcome.set_name)
57
+ end
58
+
59
+ it "has the expected servers in the cluster" do
60
+ expect(cluster_addresses).to eq(phase_addresses)
61
+ end
62
+
63
+ phase.outcome.servers.each do |uri, server|
64
+
65
+ it "sets #{uri} to #{server['type']}" do
66
+ expect(find_server(@client, uri)).to be_server_type(server['type'])
67
+ end
68
+
69
+ it "sets #{uri} replica set name to #{server['setName'].inspect}" do
70
+ expect(find_server(@client, uri).replica_set_name).to eq(server['setName'])
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -11,15 +11,20 @@ describe Mongo::Server::ConnectionPool do
11
11
  end
12
12
 
13
13
  let(:monitoring) do
14
- Mongo::Monitoring.new
14
+ Mongo::Monitoring.new(monitoring: false)
15
15
  end
16
16
 
17
17
  let(:listeners) do
18
18
  Mongo::Event::Listeners.new
19
19
  end
20
20
 
21
+ let(:topology) do
22
+ double('topology')
23
+ end
24
+
21
25
  let(:cluster) do
22
26
  double('cluster').tap do |cl|
27
+ allow(cl).to receive(:topology).and_return(topology)
23
28
  allow(cl).to receive(:app_metadata).and_return(app_metadata)
24
29
  end
25
30
  end
@@ -7,7 +7,7 @@ describe Mongo::Server::Connection do
7
7
  end
8
8
 
9
9
  let(:monitoring) do
10
- Mongo::Monitoring.new
10
+ Mongo::Monitoring.new(monitoring: false)
11
11
  end
12
12
 
13
13
  let(:listeners) do
@@ -20,10 +20,15 @@ describe Mongo::Server::Connection do
20
20
 
21
21
  let(:cluster) do
22
22
  double('cluster').tap do |cl|
23
+ allow(cl).to receive(:topology).and_return(topology)
23
24
  allow(cl).to receive(:app_metadata).and_return(app_metadata)
24
25
  end
25
26
  end
26
27
 
28
+ let(:topology) do
29
+ double('topology')
30
+ end
31
+
27
32
  let(:server) do
28
33
  Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS)
29
34
  end
@@ -32,11 +32,16 @@ describe Mongo::Server::Description do
32
32
  end
33
33
 
34
34
  let(:monitoring) do
35
- Mongo::Monitoring.new
35
+ Mongo::Monitoring.new(monitoring: false)
36
36
  end
37
37
 
38
+ let(:topology) do
39
+ double('topology')
40
+ end
41
+
38
42
  let(:cluster) do
39
43
  double('cluster').tap do |cl|
44
+ allow(cl).to receive(:topology).and_return(topology)
40
45
  allow(cl).to receive(:app_metadata).and_return(app_metadata)
41
46
  end
42
47
  end
@@ -546,6 +551,90 @@ describe Mongo::Server::Description do
546
551
  end
547
552
  end
548
553
 
554
+ describe '#server_type' do
555
+
556
+ context 'when the server is an arbiter' do
557
+
558
+ let(:description) do
559
+ described_class.new(address, { 'arbiterOnly' => true, 'setName' => 'test' })
560
+ end
561
+
562
+ it 'returns :arbiter' do
563
+ expect(description.server_type).to eq(:arbiter)
564
+ end
565
+ end
566
+
567
+ context 'when the server is a ghost' do
568
+
569
+ let(:description) do
570
+ described_class.new(address, { 'isreplicaset' => true })
571
+ end
572
+
573
+ it 'returns :ghost' do
574
+ expect(description.server_type).to eq(:ghost)
575
+ end
576
+ end
577
+
578
+ context 'when the server is a mongos' do
579
+
580
+ let(:config) do
581
+ { 'msg' => 'isdbgrid', 'ismaster' => true }
582
+ end
583
+
584
+ let(:description) do
585
+ described_class.new(address, config)
586
+ end
587
+
588
+ it 'returns :sharded' do
589
+ expect(description.server_type).to eq(:sharded)
590
+ end
591
+ end
592
+
593
+ context 'when the server is a primary' do
594
+
595
+ let(:description) do
596
+ described_class.new(address, replica)
597
+ end
598
+
599
+ it 'returns :primary' do
600
+ expect(description.server_type).to eq(:primary)
601
+ end
602
+ end
603
+
604
+ context 'when the server is a secondary' do
605
+
606
+ let(:description) do
607
+ described_class.new(address, { 'secondary' => true, 'setName' => 'test' })
608
+ end
609
+
610
+ it 'returns :secondary' do
611
+ expect(description.server_type).to eq(:secondary)
612
+ end
613
+ end
614
+
615
+ context 'when the server is standalone' do
616
+
617
+ let(:description) do
618
+ described_class.new(address, { 'ismaster' => true, 'ok' => 1 })
619
+ end
620
+
621
+ it 'returns :standalone' do
622
+ expect(description.server_type).to eq(:standalone)
623
+ end
624
+ end
625
+
626
+ context 'when the description has no configuration' do
627
+
628
+ let(:description) do
629
+ described_class.new(address)
630
+ end
631
+
632
+ it 'returns :unknown' do
633
+ expect(description.server_type).to eq(:unknown)
634
+ end
635
+ end
636
+ end
637
+
549
638
  describe '#unknown?' do
550
639
 
551
640
  context 'when the description has no configuration' do
@@ -10,12 +10,12 @@ describe 'Server Selection' do
10
10
 
11
11
  context(spec.description) do
12
12
 
13
- let(:topology) do
14
- spec.type.new({})
13
+ let(:monitoring) do
14
+ Mongo::Monitoring.new(monitoring: false)
15
15
  end
16
16
 
17
- let(:monitoring) do
18
- Mongo::Monitoring.new
17
+ let(:topology) do
18
+ spec.type.new({}, monitoring)
19
19
  end
20
20
 
21
21
  let(:listeners) do
@@ -28,6 +28,7 @@ describe 'Server Selection' do
28
28
  allow(c).to receive(:single?).and_return(topology.single?)
29
29
  allow(c).to receive(:sharded?).and_return(topology.sharded?)
30
30
  allow(c).to receive(:replica_set?).and_return(topology.replica_set?)
31
+ allow(c).to receive(:unknown?).and_return(topology.unknown?)
31
32
  allow(c).to receive(:app_metadata).and_return(app_metadata)
32
33
  end
33
34
  end
@@ -36,7 +37,7 @@ describe 'Server Selection' do
36
37
  spec.candidate_servers.collect do |server|
37
38
  address = Mongo::Address.new(server['address'])
38
39
  Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS).tap do |s|
39
- allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'])
40
+ allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'] / 1000.0)
40
41
  allow(s).to receive(:tags).and_return(server['tags'])
41
42
  allow(s).to receive(:secondary?).and_return(server['type'] == 'RSSecondary')
42
43
  allow(s).to receive(:primary?).and_return(server['type'] == 'RSPrimary')
@@ -49,7 +50,7 @@ describe 'Server Selection' do
49
50
  spec.in_latency_window.collect do |server|
50
51
  address = Mongo::Address.new(server['address'])
51
52
  Mongo::Server.new(address, cluster, monitoring, listeners, TEST_OPTIONS).tap do |s|
52
- allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'])
53
+ allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'] / 1000.0)
53
54
  allow(s).to receive(:tags).and_return(server['tags'])
54
55
  allow(s).to receive(:connectable?).and_return(true)
55
56
  end
@@ -18,7 +18,7 @@ describe Mongo::ServerSelector::Nearest do
18
18
  context 'when max_staleness is provided' do
19
19
 
20
20
  let(:options) do
21
- { max_staleness: 60 }
21
+ { max_staleness: 95 }
22
22
  end
23
23
 
24
24
  it 'sets the max_staleness option' do
@@ -32,7 +32,7 @@ describe Mongo::ServerSelector::Nearest do
32
32
  context 'when max staleness is the same' do
33
33
 
34
34
  let(:options) do
35
- { max_staleness: 60 }
35
+ { max_staleness: 95 }
36
36
  end
37
37
 
38
38
  let(:other) do
@@ -47,7 +47,7 @@ describe Mongo::ServerSelector::Nearest do
47
47
  context 'when max staleness is different' do
48
48
 
49
49
  let(:other_options) do
50
- { max_staleness: 30 }
50
+ { max_staleness: 100 }
51
51
  end
52
52
 
53
53
  let(:other) do
@@ -100,11 +100,11 @@ describe Mongo::ServerSelector::Nearest do
100
100
  context 'max staleness provided' do
101
101
 
102
102
  let(:max_staleness) do
103
- 60
103
+ 100
104
104
  end
105
105
 
106
106
  let(:expected) do
107
- { :mode => 'nearest', maxStalenessMS: 60000 }
107
+ { :mode => 'nearest', maxStalenessSeconds: 100 }
108
108
  end
109
109
 
110
110
  it 'returns a read preference formatted for mongos' do
@@ -246,8 +246,8 @@ describe Mongo::ServerSelector::Nearest do
246
246
  end
247
247
 
248
248
  context 'high latency servers' do
249
- let(:far_primary) { make_server(:primary, :average_round_trip_time => 113, address: default_address) }
250
- let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 114, address: default_address) }
249
+ let(:far_primary) { make_server(:primary, :average_round_trip_time => 0.113, address: default_address) }
250
+ let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 0.114, address: default_address) }
251
251
 
252
252
  context 'single candidate' do
253
253
 
@@ -18,7 +18,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
18
18
  context 'when max_staleness is provided' do
19
19
 
20
20
  let(:options) do
21
- { max_staleness: 60 }
21
+ { max_staleness: 95 }
22
22
  end
23
23
 
24
24
  it 'sets the max_staleness option' do
@@ -32,7 +32,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
32
32
  context 'when max staleness is the same' do
33
33
 
34
34
  let(:options) do
35
- { max_staleness: 60 }
35
+ { max_staleness: 95 }
36
36
  end
37
37
 
38
38
  let(:other) do
@@ -47,7 +47,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
47
47
  context 'when max staleness is different' do
48
48
 
49
49
  let(:other_options) do
50
- { max_staleness: 30 }
50
+ { max_staleness: 100 }
51
51
  end
52
52
 
53
53
  let(:other) do
@@ -93,11 +93,11 @@ describe Mongo::ServerSelector::PrimaryPreferred do
93
93
  context 'max staleness provided' do
94
94
 
95
95
  let(:max_staleness) do
96
- 60
96
+ 100
97
97
  end
98
98
 
99
99
  let(:expected) do
100
- { :mode => 'primaryPreferred', maxStalenessMS: 60000 }
100
+ { :mode => 'primaryPreferred', maxStalenessSeconds: 100 }
101
101
  end
102
102
 
103
103
  it 'returns a read preference formatted for mongos' do
@@ -244,8 +244,8 @@ describe Mongo::ServerSelector::PrimaryPreferred do
244
244
  end
245
245
 
246
246
  context 'high latency servers' do
247
- let(:far_primary) { make_server(:primary, :average_round_trip_time => 100, address: default_address) }
248
- let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 113, address: default_address) }
247
+ let(:far_primary) { make_server(:primary, :average_round_trip_time => 0.100, address: default_address) }
248
+ let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 0.113, address: default_address) }
249
249
 
250
250
  context 'single candidate' do
251
251
 
@@ -16,7 +16,7 @@ describe Mongo::ServerSelector::Primary do
16
16
  context 'when max_staleness is provided' do
17
17
 
18
18
  let(:options) do
19
- { max_staleness: 60 }
19
+ { max_staleness: 100 }
20
20
  end
21
21
 
22
22
  it 'raises an exception' do
@@ -66,7 +66,7 @@ describe Mongo::ServerSelector::Primary do
66
66
  context 'max staleness provided' do
67
67
 
68
68
  let(:max_staleness) do
69
- 60
69
+ 100
70
70
  end
71
71
 
72
72
  it 'raises an error' do
@@ -112,8 +112,8 @@ describe Mongo::ServerSelector::Primary do
112
112
  end
113
113
 
114
114
  context 'high latency candidates' do
115
- let(:far_primary) { make_server(:primary, :average_round_trip_time => 100, address: default_address) }
116
- let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 120, address: default_address) }
115
+ let(:far_primary) { make_server(:primary, :average_round_trip_time => 0.100, address: default_address) }
116
+ let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 0.120, address: default_address) }
117
117
 
118
118
  context 'single candidate' do
119
119
 
@@ -18,7 +18,7 @@ describe Mongo::ServerSelector::SecondaryPreferred do
18
18
  context 'when max_staleness is provided' do
19
19
 
20
20
  let(:options) do
21
- { max_staleness: 60 }
21
+ { max_staleness: 95 }
22
22
  end
23
23
 
24
24
  it 'sets the max_staleness option' do
@@ -32,7 +32,7 @@ describe Mongo::ServerSelector::SecondaryPreferred do
32
32
  context 'when max staleness is the same' do
33
33
 
34
34
  let(:options) do
35
- { max_staleness: 60 }
35
+ { max_staleness: 90 }
36
36
  end
37
37
 
38
38
  let(:other) do
@@ -47,7 +47,7 @@ describe Mongo::ServerSelector::SecondaryPreferred do
47
47
  context 'when max staleness is different' do
48
48
 
49
49
  let(:other_options) do
50
- { max_staleness: 30 }
50
+ { max_staleness: 100 }
51
51
  end
52
52
 
53
53
  let(:other) do
@@ -100,7 +100,7 @@ describe Mongo::ServerSelector::SecondaryPreferred do
100
100
  end
101
101
 
102
102
  let(:expected) do
103
- { :mode => 'secondaryPreferred', maxStalenessMS: 60000 }
103
+ { :mode => 'secondaryPreferred', maxStalenessSeconds: 60 }
104
104
  end
105
105
 
106
106
  it 'returns a read preference formatted for mongos' do
@@ -243,8 +243,8 @@ describe Mongo::ServerSelector::SecondaryPreferred do
243
243
  end
244
244
 
245
245
  context 'high latency servers' do
246
- let(:far_primary) { make_server(:primary, :average_round_trip_time => 100, address: default_address) }
247
- let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 113, address: default_address) }
246
+ let(:far_primary) { make_server(:primary, :average_round_trip_time => 0.100, address: default_address) }
247
+ let(:far_secondary) { make_server(:secondary, :average_round_trip_time => 0.113, address: default_address) }
248
248
 
249
249
  context 'single candidate' do
250
250