Skip to content

Commit 82a5aa9

Browse files
committed
JAVA-2069: Added additional tests from the specification
1 parent c59e798 commit 82a5aa9

File tree

4 files changed

+508
-0
lines changed

4 files changed

+508
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"description": "New primary with greater setVersion",
3+
"phases": [
4+
{
5+
"outcome": {
6+
"servers": {
7+
"a:27017": {
8+
"electionId": {
9+
"$oid": "000000000000000000000001"
10+
},
11+
"setName": "rs",
12+
"setVersion": 1,
13+
"type": "RSPrimary"
14+
},
15+
"b:27017": {
16+
"electionId": null,
17+
"setName": null,
18+
"type": "Unknown"
19+
}
20+
},
21+
"setName": "rs",
22+
"topologyType": "ReplicaSetWithPrimary"
23+
},
24+
"responses": [
25+
[
26+
"a:27017",
27+
{
28+
"electionId": {
29+
"$oid": "000000000000000000000001"
30+
},
31+
"hosts": [
32+
"a:27017",
33+
"b:27017"
34+
],
35+
"ismaster": true,
36+
"ok": 1,
37+
"setName": "rs",
38+
"setVersion": 1
39+
}
40+
]
41+
]
42+
},
43+
{
44+
"outcome": {
45+
"servers": {
46+
"a:27017": {
47+
"electionId": null,
48+
"setName": null,
49+
"type": "Unknown"
50+
},
51+
"b:27017": {
52+
"electionId": {
53+
"$oid": "000000000000000000000001"
54+
},
55+
"setName": "rs",
56+
"setVersion": 2,
57+
"type": "RSPrimary"
58+
}
59+
},
60+
"setName": "rs",
61+
"topologyType": "ReplicaSetWithPrimary"
62+
},
63+
"responses": [
64+
[
65+
"b:27017",
66+
{
67+
"electionId": {
68+
"$oid": "000000000000000000000001"
69+
},
70+
"hosts": [
71+
"a:27017",
72+
"b:27017"
73+
],
74+
"ismaster": true,
75+
"ok": 1,
76+
"setName": "rs",
77+
"setVersion": 2
78+
}
79+
]
80+
]
81+
},
82+
{
83+
"outcome": {
84+
"servers": {
85+
"a:27017": {
86+
"electionId": null,
87+
"setName": null,
88+
"type": "Unknown"
89+
},
90+
"b:27017": {
91+
"electionId": {
92+
"$oid": "000000000000000000000001"
93+
},
94+
"setName": "rs",
95+
"setVersion": 2,
96+
"type": "RSPrimary"
97+
}
98+
},
99+
"setName": "rs",
100+
"topologyType": "ReplicaSetWithPrimary"
101+
},
102+
"responses": [
103+
[
104+
"a:27017",
105+
{
106+
"electionId": {
107+
"$oid": "000000000000000000000001"
108+
},
109+
"hosts": [
110+
"a:27017",
111+
"b:27017"
112+
],
113+
"ismaster": true,
114+
"ok": 1,
115+
"setName": "rs",
116+
"setVersion": 1
117+
}
118+
]
119+
]
120+
}
121+
],
122+
"uri": "mongodb://a/?replicaSet=rs"
123+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
{
2+
"description": "Disconnected from primary, reject primary with stale setVersion",
3+
"phases": [
4+
{
5+
"outcome": {
6+
"servers": {
7+
"a:27017": {
8+
"electionId": null,
9+
"setName": null,
10+
"type": "Unknown"
11+
},
12+
"b:27017": {
13+
"electionId": {
14+
"$oid": "000000000000000000000001"
15+
},
16+
"setName": "rs",
17+
"setVersion": 2,
18+
"type": "RSPrimary"
19+
}
20+
},
21+
"setName": "rs",
22+
"topologyType": "ReplicaSetWithPrimary"
23+
},
24+
"responses": [
25+
[
26+
"a:27017",
27+
{
28+
"electionId": {
29+
"$oid": "000000000000000000000001"
30+
},
31+
"hosts": [
32+
"a:27017",
33+
"b:27017"
34+
],
35+
"ismaster": true,
36+
"ok": 1,
37+
"setName": "rs",
38+
"setVersion": 1
39+
}
40+
],
41+
[
42+
"b:27017",
43+
{
44+
"electionId": {
45+
"$oid": "000000000000000000000001"
46+
},
47+
"hosts": [
48+
"a:27017",
49+
"b:27017"
50+
],
51+
"ismaster": true,
52+
"ok": 1,
53+
"setName": "rs",
54+
"setVersion": 2
55+
}
56+
]
57+
]
58+
},
59+
{
60+
"outcome": {
61+
"servers": {
62+
"a:27017": {
63+
"electionId": null,
64+
"setName": null,
65+
"type": "Unknown"
66+
},
67+
"b:27017": {
68+
"electionId": null,
69+
"setName": null,
70+
"type": "Unknown"
71+
}
72+
},
73+
"setName": "rs",
74+
"topologyType": "ReplicaSetNoPrimary"
75+
},
76+
"responses": [
77+
[
78+
"b:27017",
79+
{}
80+
]
81+
]
82+
},
83+
{
84+
"outcome": {
85+
"servers": {
86+
"a:27017": {
87+
"electionId": null,
88+
"setName": null,
89+
"type": "Unknown"
90+
},
91+
"b:27017": {
92+
"electionId": null,
93+
"setName": null,
94+
"type": "Unknown"
95+
}
96+
},
97+
"setName": "rs",
98+
"topologyType": "ReplicaSetNoPrimary"
99+
},
100+
"responses": [
101+
[
102+
"a:27017",
103+
{
104+
"electionId": {
105+
"$oid": "000000000000000000000001"
106+
},
107+
"hosts": [
108+
"a:27017",
109+
"b:27017"
110+
],
111+
"ismaster": true,
112+
"ok": 1,
113+
"setName": "rs",
114+
"setVersion": 1
115+
}
116+
]
117+
]
118+
},
119+
{
120+
"outcome": {
121+
"servers": {
122+
"a:27017": {
123+
"electionId": {
124+
"$oid": "000000000000000000000002"
125+
},
126+
"setName": "rs",
127+
"setVersion": 2,
128+
"type": "RSPrimary"
129+
},
130+
"b:27017": {
131+
"electionId": null,
132+
"setName": null,
133+
"type": "Unknown"
134+
}
135+
},
136+
"setName": "rs",
137+
"topologyType": "ReplicaSetWithPrimary"
138+
},
139+
"responses": [
140+
[
141+
"a:27017",
142+
{
143+
"electionId": {
144+
"$oid": "000000000000000000000002"
145+
},
146+
"hosts": [
147+
"a:27017",
148+
"b:27017"
149+
],
150+
"ismaster": true,
151+
"ok": 1,
152+
"setName": "rs",
153+
"setVersion": 2
154+
}
155+
]
156+
]
157+
},
158+
{
159+
"outcome": {
160+
"servers": {
161+
"a:27017": {
162+
"electionId": {
163+
"$oid": "000000000000000000000002"
164+
},
165+
"setName": "rs",
166+
"setVersion": 2,
167+
"type": "RSPrimary"
168+
},
169+
"b:27017": {
170+
"setName": "rs",
171+
"setVersion": 2,
172+
"type": "RSSecondary"
173+
}
174+
},
175+
"setName": "rs",
176+
"topologyType": "ReplicaSetWithPrimary"
177+
},
178+
"responses": [
179+
[
180+
"b:27017",
181+
{
182+
"hosts": [
183+
"a:27017",
184+
"b:27017"
185+
],
186+
"ismaster": false,
187+
"ok": 1,
188+
"secondary": true,
189+
"setName": "rs",
190+
"setVersion": 2
191+
}
192+
]
193+
]
194+
}
195+
],
196+
"uri": "mongodb://a/?replicaSet=rs"
197+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"description": "setVersion is ignored if there is no electionId",
3+
"phases": [
4+
{
5+
"outcome": {
6+
"servers": {
7+
"a:27017": {
8+
"electionId": null,
9+
"setName": "rs",
10+
"setVersion": 2,
11+
"type": "RSPrimary"
12+
},
13+
"b:27017": {
14+
"electionId": null,
15+
"setName": null,
16+
"type": "Unknown"
17+
}
18+
},
19+
"setName": "rs",
20+
"topologyType": "ReplicaSetWithPrimary"
21+
},
22+
"responses": [
23+
[
24+
"a:27017",
25+
{
26+
"hosts": [
27+
"a:27017",
28+
"b:27017"
29+
],
30+
"ismaster": true,
31+
"ok": 1,
32+
"setName": "rs",
33+
"setVersion": 2
34+
}
35+
]
36+
]
37+
},
38+
{
39+
"outcome": {
40+
"servers": {
41+
"a:27017": {
42+
"electionId": null,
43+
"setName": null,
44+
"type": "Unknown"
45+
},
46+
"b:27017": {
47+
"electionId": null,
48+
"setName": "rs",
49+
"setVersion": 1,
50+
"type": "RSPrimary"
51+
}
52+
},
53+
"setName": "rs",
54+
"topologyType": "ReplicaSetWithPrimary"
55+
},
56+
"responses": [
57+
[
58+
"b:27017",
59+
{
60+
"hosts": [
61+
"a:27017",
62+
"b:27017"
63+
],
64+
"ismaster": true,
65+
"ok": 1,
66+
"setName": "rs",
67+
"setVersion": 1
68+
}
69+
]
70+
]
71+
}
72+
],
73+
"uri": "mongodb://a/?replicaSet=rs"
74+
}

0 commit comments

Comments
 (0)