Skip to content

Commit fef2bb3

Browse files
committed
add replset test
1 parent 4e1a40b commit fef2bb3

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"description": "replicaset-emit-topology-description-changed-before-close",
3+
"schemaVersion": "1.16",
4+
"runOnRequirements": [
5+
{
6+
"topologies": [
7+
"replicaset"
8+
],
9+
"minServerVersion": "4.4"
10+
}
11+
],
12+
"tests": [
13+
{
14+
"description": "Topology lifecycle",
15+
"operations": [
16+
{
17+
"name": "createEntities",
18+
"object": "testRunner",
19+
"arguments": {
20+
"entities": [
21+
{
22+
"client": {
23+
"id": "client",
24+
"observeEvents": [
25+
"topologyDescriptionChangedEvent",
26+
"topologyOpeningEvent",
27+
"topologyClosedEvent"
28+
]
29+
}
30+
}
31+
]
32+
}
33+
},
34+
{
35+
"name": "waitForEvent",
36+
"object": "testRunner",
37+
"arguments": {
38+
"client": "client",
39+
"event": {
40+
"topologyDescriptionChangedEvent": {}
41+
},
42+
"count": 2
43+
}
44+
},
45+
{
46+
"name": "close",
47+
"object": "client"
48+
}
49+
],
50+
"expectEvents": [
51+
{
52+
"client": "client",
53+
"eventType": "sdam",
54+
"ignoreExtraEvents": true,
55+
"events": [
56+
{
57+
"topologyOpeningEvent": {}
58+
},
59+
{
60+
"topologyDescriptionChangedEvent": {
61+
"previousDescription": {
62+
"type": "Unknown"
63+
},
64+
"newDescription": {
65+
"type": "ReplicaSetNoPrimary"
66+
}
67+
}
68+
},
69+
{
70+
"topologyDescriptionChangedEvent": {
71+
"previousDescription": {
72+
"type": "ReplicaSetNoPrimary"
73+
},
74+
"newDescription": {
75+
"type": "ReplicaSetWithPrimary"
76+
}
77+
}
78+
},
79+
{
80+
"topologyDescriptionChangedEvent": {
81+
"previousDescription": {
82+
"type": "ReplicaSetWithPrimary"
83+
},
84+
"newDescription": {
85+
"type": "ReplicaSetWithPrimary"
86+
}
87+
}
88+
},
89+
{
90+
"topologyDescriptionChangedEvent": {
91+
"previousDescription": {
92+
"type": "ReplicaSetWithPrimary"
93+
},
94+
"newDescription": {
95+
"type": "ReplicaSetWithPrimary"
96+
}
97+
}
98+
},
99+
{
100+
"topologyDescriptionChangedEvent": {
101+
"previousDescription": {
102+
"type": "ReplicaSetWithPrimary"
103+
},
104+
"newDescription": {
105+
"type": "ReplicaSetWithPrimary"
106+
}
107+
}
108+
},
109+
{
110+
"topologyDescriptionChangedEvent": {
111+
"previousDescription": {
112+
"type": "ReplicaSetWithPrimary"
113+
},
114+
"newDescription": {
115+
"type": "Unknown"
116+
}
117+
}
118+
},
119+
{
120+
"topologyClosedEvent": {}
121+
}
122+
]
123+
}
124+
]
125+
}
126+
]
127+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
description: "replicaset-emit-topology-description-changed-before-close"
2+
3+
schemaVersion: "1.16"
4+
5+
runOnRequirements:
6+
- topologies:
7+
- replicaset
8+
minServerVersion: "4.4" # awaitable hello
9+
10+
tests:
11+
- description: "Topology lifecycle"
12+
operations:
13+
- name: createEntities
14+
object: testRunner
15+
arguments:
16+
entities:
17+
- client:
18+
id: &client client
19+
observeEvents:
20+
- topologyDescriptionChangedEvent
21+
- topologyOpeningEvent
22+
- topologyClosedEvent
23+
# ensure the topology has been fully discovered before closing the client.
24+
# expected events are initial server discovery and server connect event.
25+
- name: waitForEvent
26+
object: testRunner
27+
arguments:
28+
client: *client
29+
event:
30+
topologyDescriptionChangedEvent: {}
31+
count: 2
32+
- name: close
33+
object: *client
34+
expectEvents:
35+
- client: *client
36+
eventType: sdam
37+
ignoreExtraEvents: true
38+
events:
39+
- topologyOpeningEvent: {}
40+
- topologyDescriptionChangedEvent: # unknown -> unknown w disconnected server
41+
previousDescription:
42+
type: "Unknown"
43+
newDescription:
44+
type: "ReplicaSetNoPrimary"
45+
- topologyDescriptionChangedEvent: # server connected
46+
previousDescription:
47+
type: "ReplicaSetNoPrimary"
48+
newDescription:
49+
type: "ReplicaSetWithPrimary"
50+
- topologyDescriptionChangedEvent: # server connected
51+
previousDescription:
52+
type: "ReplicaSetWithPrimary"
53+
newDescription:
54+
type: "ReplicaSetWithPrimary"
55+
- topologyDescriptionChangedEvent: # server connected
56+
previousDescription:
57+
type: "ReplicaSetWithPrimary"
58+
newDescription:
59+
type: "ReplicaSetWithPrimary"
60+
- topologyDescriptionChangedEvent: # server connected
61+
previousDescription:
62+
type: "ReplicaSetWithPrimary"
63+
newDescription:
64+
type: "ReplicaSetWithPrimary"
65+
- topologyDescriptionChangedEvent: # replicaset -> unknown
66+
previousDescription:
67+
type: "ReplicaSetWithPrimary"
68+
newDescription:
69+
type: "Unknown"
70+
- topologyClosedEvent: {}

0 commit comments

Comments
 (0)