Skip to content

Commit 5d414cc

Browse files
authored
test(NODE-7462): add spec tests for disaggregated storage (#4904)
1 parent a4cba4c commit 5d414cc

8 files changed

+1163
-0
lines changed
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
{
2+
"description": "Static setVersion (DSC) is compatible with both pre and post DRIVERS-2412",
3+
"uri": "mongodb://a/?replicaSet=rs",
4+
"phases": [
5+
{
6+
"responses": [
7+
[
8+
"a:27017",
9+
{
10+
"ok": 1,
11+
"helloOk": true,
12+
"isWritablePrimary": true,
13+
"hosts": [
14+
"a:27017",
15+
"b:27017"
16+
],
17+
"setName": "rs",
18+
"setVersion": 1,
19+
"electionId": {
20+
"$oid": "000000000000000000000005"
21+
},
22+
"minWireVersion": 0,
23+
"maxWireVersion": 17
24+
}
25+
],
26+
[
27+
"b:27017",
28+
{
29+
"ok": 1,
30+
"helloOk": true,
31+
"isWritablePrimary": false,
32+
"secondary": true,
33+
"hosts": [
34+
"a:27017",
35+
"b:27017"
36+
],
37+
"setName": "rs",
38+
"setVersion": 1,
39+
"minWireVersion": 0,
40+
"maxWireVersion": 17
41+
}
42+
]
43+
],
44+
"outcome": {
45+
"servers": {
46+
"a:27017": {
47+
"type": "RSPrimary",
48+
"setName": "rs",
49+
"setVersion": 1,
50+
"electionId": {
51+
"$oid": "000000000000000000000005"
52+
}
53+
},
54+
"b:27017": {
55+
"type": "RSSecondary",
56+
"setName": "rs",
57+
"setVersion": 1,
58+
"electionId": null
59+
}
60+
},
61+
"topologyType": "ReplicaSetWithPrimary",
62+
"logicalSessionTimeoutMinutes": null,
63+
"setName": "rs",
64+
"maxSetVersion": 1,
65+
"maxElectionId": {
66+
"$oid": "000000000000000000000005"
67+
}
68+
}
69+
},
70+
{
71+
"responses": [
72+
[
73+
"b:27017",
74+
{
75+
"ok": 1,
76+
"helloOk": true,
77+
"isWritablePrimary": true,
78+
"hosts": [
79+
"a:27017",
80+
"b:27017"
81+
],
82+
"setName": "rs",
83+
"setVersion": 1,
84+
"electionId": {
85+
"$oid": "000000000000000000000006"
86+
},
87+
"minWireVersion": 0,
88+
"maxWireVersion": 17
89+
}
90+
]
91+
],
92+
"outcome": {
93+
"servers": {
94+
"a:27017": {
95+
"type": "Unknown",
96+
"setName": null,
97+
"setVersion": null,
98+
"electionId": null
99+
},
100+
"b:27017": {
101+
"type": "RSPrimary",
102+
"setName": "rs",
103+
"setVersion": 1,
104+
"electionId": {
105+
"$oid": "000000000000000000000006"
106+
}
107+
}
108+
},
109+
"topologyType": "ReplicaSetWithPrimary",
110+
"logicalSessionTimeoutMinutes": null,
111+
"setName": "rs",
112+
"maxSetVersion": 1,
113+
"maxElectionId": {
114+
"$oid": "000000000000000000000006"
115+
}
116+
}
117+
},
118+
{
119+
"responses": [
120+
[
121+
"a:27017",
122+
{
123+
"ok": 1,
124+
"helloOk": true,
125+
"isWritablePrimary": true,
126+
"hosts": [
127+
"a:27017",
128+
"b:27017"
129+
],
130+
"setName": "rs",
131+
"setVersion": 1,
132+
"electionId": {
133+
"$oid": "000000000000000000000005"
134+
},
135+
"minWireVersion": 0,
136+
"maxWireVersion": 17
137+
}
138+
]
139+
],
140+
"outcome": {
141+
"servers": {
142+
"a:27017": {
143+
"type": "Unknown",
144+
"setName": null,
145+
"setVersion": null,
146+
"electionId": null
147+
},
148+
"b:27017": {
149+
"type": "RSPrimary",
150+
"setName": "rs",
151+
"setVersion": 1,
152+
"electionId": {
153+
"$oid": "000000000000000000000006"
154+
}
155+
}
156+
},
157+
"topologyType": "ReplicaSetWithPrimary",
158+
"logicalSessionTimeoutMinutes": null,
159+
"setName": "rs",
160+
"maxSetVersion": 1,
161+
"maxElectionId": {
162+
"$oid": "000000000000000000000006"
163+
}
164+
}
165+
}
166+
]
167+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Disaggregated storage clusters use a constant setVersion (typically 1) instead of
2+
# incrementing it on each reconfig. This test validates that primary staleness detection
3+
# works correctly using electionId when setVersion doesn't change.
4+
description: Static setVersion (DSC) is compatible with both pre and post DRIVERS-2412
5+
uri: "mongodb://a/?replicaSet=rs"
6+
phases:
7+
# Phase 1: Initial state - A is primary with electionId=5, setVersion=1
8+
- responses:
9+
-
10+
- "a:27017"
11+
- ok: 1
12+
helloOk: true
13+
isWritablePrimary: true
14+
hosts:
15+
- "a:27017"
16+
- "b:27017"
17+
setName: rs
18+
setVersion: 1
19+
electionId: {"$oid": "000000000000000000000005"}
20+
minWireVersion: 0
21+
maxWireVersion: 17
22+
-
23+
- "b:27017"
24+
- ok: 1
25+
helloOk: true
26+
isWritablePrimary: false
27+
secondary: true
28+
hosts:
29+
- "a:27017"
30+
- "b:27017"
31+
setName: rs
32+
setVersion: 1
33+
minWireVersion: 0
34+
maxWireVersion: 17
35+
outcome:
36+
servers:
37+
a:27017:
38+
type: RSPrimary
39+
setName: rs
40+
setVersion: 1
41+
electionId: {"$oid": "000000000000000000000005"}
42+
b:27017:
43+
type: RSSecondary
44+
setName: rs
45+
setVersion: 1
46+
electionId: null
47+
topologyType: ReplicaSetWithPrimary
48+
logicalSessionTimeoutMinutes: null
49+
setName: rs
50+
maxSetVersion: 1
51+
maxElectionId: {"$oid": "000000000000000000000005"}
52+
# Phase 2: B becomes primary with newer electionId=6, but setVersion stays at 1
53+
# The driver should accept B as the new primary and mark A as Unknown
54+
- responses:
55+
-
56+
- "b:27017"
57+
- ok: 1
58+
helloOk: true
59+
isWritablePrimary: true
60+
hosts:
61+
- "a:27017"
62+
- "b:27017"
63+
setName: rs
64+
setVersion: 1
65+
electionId: {"$oid": "000000000000000000000006"}
66+
minWireVersion: 0
67+
maxWireVersion: 17
68+
outcome:
69+
servers:
70+
a:27017:
71+
type: Unknown
72+
setName: null
73+
setVersion: null
74+
electionId: null
75+
b:27017:
76+
type: RSPrimary
77+
setName: rs
78+
setVersion: 1
79+
electionId: {"$oid": "000000000000000000000006"}
80+
topologyType: ReplicaSetWithPrimary
81+
logicalSessionTimeoutMinutes: null
82+
setName: rs
83+
maxSetVersion: 1
84+
maxElectionId: {"$oid": "000000000000000000000006"}
85+
# Phase 3: Old primary A tries to come back with stale electionId=5
86+
# Even though setVersion is still 1 (unchanged), the driver should reject A
87+
# because its electionId is older than the current maxElectionId=6
88+
- responses:
89+
-
90+
- "a:27017"
91+
- ok: 1
92+
helloOk: true
93+
isWritablePrimary: true
94+
hosts:
95+
- "a:27017"
96+
- "b:27017"
97+
setName: rs
98+
setVersion: 1
99+
electionId: {"$oid": "000000000000000000000005"}
100+
minWireVersion: 0
101+
maxWireVersion: 17
102+
outcome:
103+
servers:
104+
a:27017:
105+
type: Unknown
106+
setName: null
107+
setVersion: null
108+
electionId: null
109+
b:27017:
110+
type: RSPrimary
111+
setName: rs
112+
setVersion: 1
113+
electionId: {"$oid": "000000000000000000000006"}
114+
topologyType: ReplicaSetWithPrimary
115+
logicalSessionTimeoutMinutes: null
116+
setName: rs
117+
maxSetVersion: 1
118+
maxElectionId: {"$oid": "000000000000000000000006"}

0 commit comments

Comments
 (0)