Skip to content

Commit 5d41f7e

Browse files
committed
Merge pull request #727 from estolfo/RUBY-1070-sdam-tests
RUBY-1070 Add missing SDAM test, make updates and adjust SDAM
2 parents 04ac4ed + d0d780f commit 5d41f7e

File tree

3 files changed

+85
-4
lines changed

3 files changed

+85
-4
lines changed

lib/mongo/server/description.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ def mongos?
364364
#
365365
# @since 2.0.0
366366
def other?
367-
!primary? && !secondary? && !passive? && !arbiter?
367+
(!primary? && !secondary? && !passive? && !arbiter?) ||
368+
(hidden? && !replica_set_name.nil?)
368369
end
369370

370371
# Will return true if the server is passive.

spec/support/sdam/rs/rsother_discovered.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@ phases: [
77
{
88
responses: [
99

10+
["a:27017", {
11+
12+
ok: 1,
13+
ismaster: false,
14+
secondary: true,
15+
hidden: true,
16+
hosts: ["c:27017", "d:27017"],
17+
setName: "rs"
18+
}],
1019
["b:27017", {
1120

1221
ok: 1,
1322
ismaster: false,
1423
secondary: false,
15-
hosts: ["a:27017", "b:27017"],
24+
hosts: ["c:27017", "d:27017"],
1625
setName: "rs"
1726
}]
1827
],
@@ -23,14 +32,26 @@ phases: [
2332

2433
"a:27017": {
2534

26-
type: "Unknown",
27-
setName:
35+
type: "RSOther",
36+
setName: "rs"
2837
},
2938

3039
"b:27017": {
3140

3241
type: "RSOther",
3342
setName: "rs"
43+
},
44+
45+
"c:27017": {
46+
47+
type: "Unknown",
48+
setName:
49+
},
50+
51+
"d:27017": {
52+
53+
type: "Unknown",
54+
setName:
3455
}
3556
},
3657

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
description: "Primary becomes a secondary with wrong setName"
2+
3+
uri: "mongodb://a/?replicaSet=rs"
4+
5+
phases: [
6+
7+
# Primary is discovered normally.
8+
{
9+
responses: [
10+
11+
["a:27017", {
12+
13+
ok: 1,
14+
ismaster: true,
15+
hosts: ["a:27017"],
16+
setName: "rs"
17+
}]
18+
],
19+
20+
outcome: {
21+
22+
servers: {
23+
24+
"a:27017": {
25+
26+
type: "RSPrimary",
27+
setName: "rs"
28+
}
29+
},
30+
31+
topologyType: "ReplicaSetWithPrimary",
32+
setName: "rs"
33+
}
34+
},
35+
36+
# Primary changes its setName and becomes secondary.
37+
# Remove it and change the topologyType.
38+
{
39+
responses: [
40+
41+
["a:27017", {
42+
43+
ok: 1,
44+
ismaster: false,
45+
secondary: true,
46+
hosts: ["a:27017"],
47+
setName: "wrong"
48+
}]
49+
],
50+
51+
outcome: {
52+
53+
servers: {},
54+
55+
topologyType: "ReplicaSetNoPrimary",
56+
setName: "rs"
57+
}
58+
}
59+
]

0 commit comments

Comments
 (0)