Skip to content

Commit 23e1153

Browse files
committed
minor: replica set test tweaks
1 parent 4e40e74 commit 23e1153

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

test/replica_sets/basic_test.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,18 @@ def test_accessors
4747
seeds = build_seeds(3)
4848
args = {:name => @rs.name}
4949
@conn = ReplSetConnection.new(seeds, args)
50-
@major_version = @rs.version.first
5150

5251
assert_equal @conn.host, @rs.primary[0]
5352
assert_equal @conn.port, @rs.primary[1]
5453
assert_equal @conn.host, @conn.primary_pool.host
5554
assert_equal @conn.port, @conn.primary_pool.port
56-
#assert_equal @conn.nodes.sort, @conn.seeds.sort
5755
assert_equal 2, @conn.secondaries.length
5856
assert_equal 0, @conn.arbiters.length
5957
assert_equal 2, @conn.secondary_pools.length
6058
assert_equal @rs.name, @conn.replica_set_name
6159
assert @conn.secondary_pools.include?(@conn.read_pool(:secondary))
6260
assert_equal 90, @conn.refresh_interval
6361
assert_equal @conn.refresh_mode, false
64-
#assert_equal 5, @conn.tag_map.keys.length unless @major_version < 2
6562
end
6663

6764
context "Socket pools" do

test/replica_sets/complex_read_preference_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def test_primary_with_tags
2727
end
2828

2929
def test_tags
30+
return true if @rs.version < "2.1"
31+
3032
assert_read_pool(:primary, {}, 0)
3133
assert_read_pool(:primary_preferred, {}, 0)
3234
assert_read_pool(:secondary, {}, [1,2])
@@ -82,6 +84,8 @@ def test_tags
8284
end
8385

8486
def test_tag_sets
87+
return true if @rs.version < "2.1"
88+
8589
# Test primary_preferred overrides any tags when primary is available
8690
assert_read_pool(:primary_preferred, [
8791
{"dc" => "sf"}
@@ -177,6 +181,8 @@ def test_nearest
177181
end
178182

179183
def test_tags_and_nearest
184+
return true if @rs.version < "2.1"
185+
180186
# Test connection's read pool matches tags
181187
assert_read_pool(:secondary_preferred, {"dc" => "sf"}, 2, [100,110,130])
182188

test/replica_sets/read_preference_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def test_read_routing_with_primary_down
9898

9999
# Restore set
100100
@rs.restart_killed_nodes
101+
sleep(1)
101102
@repl_cons.each { |con| con.refresh }
102103
sleep(1)
103104
@primary_direct = Connection.new(
@@ -134,6 +135,7 @@ def test_read_routing_with_secondary_down
134135

135136
# Restore set
136137
@rs.restart_killed_nodes
138+
sleep(1)
137139
@repl_cons.each { |con| con.refresh }
138140
sleep(1)
139141
@secondary_direct = Connection.new(

test/replica_sets/refresh_with_threads_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def teardown
1515

1616
def test_read_write_load_with_added_nodes
1717
# MongoDB < 2.0 will disconnect clients on rs.reconfig()
18-
return true if @rs.version.first < 2
18+
return true if @rs.version < "2"
1919

2020
seeds = build_seeds(3)
2121
args = {

test/tools/repl_set_manager.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def initialize(opts={})
4242
@mongods = {}
4343
version_string = `#{@mongod} --version`
4444
version_string =~ /(\d\.\d\.\d)/
45-
@version = $1.split(".").map {|d| d.to_i }
45+
@version = $1
4646
end
4747

4848
def start_set
@@ -54,7 +54,7 @@ def start_set
5454
n = 0
5555
(@primary_count + @secondary_count).times do
5656
init_node(n, should_start) do |attrs|
57-
if @version[0] >= 2
57+
if @version >= "2"
5858
attrs['tags'] = @tags[n % @tags.size]
5959
end
6060
end
@@ -114,7 +114,7 @@ def init_node(n, should_start=true)
114114
end
115115

116116
def journal_switch
117-
if @version[0] >= 2
117+
if @version >= "2"
118118
if @durable
119119
"--journal"
120120
else

0 commit comments

Comments
 (0)