Skip to content

Commit 6fbdfda

Browse files
committed
PYTHON-4960 Add tests
1 parent c42f3d6 commit 6fbdfda

10 files changed

+29
-13
lines changed

test/discovery_and_monitoring/rs/new_primary.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"servers": {
5959
"a:27017": {
6060
"type": "Unknown",
61-
"setName": null
61+
"setName": null,
62+
"error": "primary marked stale due to discovery of newer primary"
6263
},
6364
"b:27017": {
6465
"type": "RSPrimary",

test/discovery_and_monitoring/rs/new_primary_new_electionid.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
"a:27017": {
7777
"type": "Unknown",
7878
"setName": null,
79-
"electionId": null
79+
"electionId": null,
80+
"error": "primary marked stale due to electionId/setVersion mismatch"
8081
},
8182
"b:27017": {
8283
"type": "RSPrimary",
@@ -123,7 +124,8 @@
123124
"a:27017": {
124125
"type": "Unknown",
125126
"setName": null,
126-
"electionId": null
127+
"electionId": null,
128+
"error": "primary marked stale due to electionId/setVersion mismatch"
127129
},
128130
"b:27017": {
129131
"type": "RSPrimary",

test/discovery_and_monitoring/rs/new_primary_new_setversion.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
"a:27017": {
7777
"type": "Unknown",
7878
"setName": null,
79-
"electionId": null
79+
"electionId": null,
80+
"error": "primary marked stale due to electionId/setVersion mismatch"
8081
},
8182
"b:27017": {
8283
"type": "RSPrimary",
@@ -123,7 +124,8 @@
123124
"a:27017": {
124125
"type": "Unknown",
125126
"setName": null,
126-
"electionId": null
127+
"electionId": null,
128+
"error": "primary marked stale due to electionId/setVersion mismatch"
127129
},
128130
"b:27017": {
129131
"type": "RSPrimary",

test/discovery_and_monitoring/rs/primary_disconnect_electionid.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"a:27017": {
4949
"type": "Unknown",
5050
"setName": null,
51-
"electionId": null
51+
"electionId": null,
52+
"error": "primary marked stale due to electionId/setVersion mismatch"
5253
},
5354
"b:27017": {
5455
"type": "RSPrimary",

test/discovery_and_monitoring/rs/primary_disconnect_setversion.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"a:27017": {
4949
"type": "Unknown",
5050
"setName": null,
51-
"electionId": null
51+
"electionId": null,
52+
"error": "primary marked stale due to electionId/setVersion mismatch"
5253
},
5354
"b:27017": {
5455
"type": "RSPrimary",

test/discovery_and_monitoring/rs/setversion_greaterthan_max_without_electionid.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"a:27017": {
6666
"type": "Unknown",
6767
"setName": null,
68-
"electionId": null
68+
"electionId": null,
69+
"error": "primary marked stale due to electionId/setVersion mismatch"
6970
},
7071
"b:27017": {
7172
"type": "RSPrimary",

test/discovery_and_monitoring/rs/setversion_without_electionid-pre-6.0.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"a:27017": {
6666
"type": "Unknown",
6767
"setName": null,
68-
"electionId": null
68+
"electionId": null,
69+
"error": "primary marked stale due to electionId/setVersion mismatch"
6970
},
7071
"b:27017": {
7172
"type": "RSPrimary",

test/discovery_and_monitoring/rs/use_setversion_without_electionid-pre-6.0.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"a:27017": {
7474
"type": "Unknown",
7575
"setName": null,
76-
"electionId": null
76+
"electionId": null,
77+
"error": "primary marked stale due to electionId/setVersion mismatch"
7778
},
7879
"b:27017": {
7980
"type": "RSPrimary",
@@ -117,7 +118,8 @@
117118
"a:27017": {
118119
"type": "Unknown",
119120
"setName": null,
120-
"electionId": null
121+
"electionId": null,
122+
"error": "primary marked stale due to electionId/setVersion mismatch"
121123
},
122124
"b:27017": {
123125
"type": "RSPrimary",

test/discovery_and_monitoring/rs/use_setversion_without_electionid.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
"b:27017": {
8282
"type": "Unknown",
8383
"setName": null,
84-
"electionId": null
84+
"electionId": null,
85+
"error": "primary marked stale due to electionId/setVersion mismatch"
8586
}
8687
},
8788
"topologyType": "ReplicaSetWithPrimary",
@@ -128,7 +129,8 @@
128129
"b:27017": {
129130
"type": "Unknown",
130131
"setName": null,
131-
"electionId": null
132+
"electionId": null,
133+
"error": "primary marked stale due to electionId/setVersion mismatch"
132134
}
133135
},
134136
"topologyType": "ReplicaSetWithPrimary",

test/test_discovery_and_monitoring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ def check_outcome(self, topology, outcome):
166166
server_type_name(expected_server_type),
167167
server_type_name(actual_server_description.server_type),
168168
)
169+
expected_error = expected_server.get("error")
170+
if expected_error:
171+
self.assertIn(expected_error, str(actual_server_description.error))
169172

170173
self.assertEqual(expected_server.get("setName"), actual_server_description.replica_set_name)
171174

0 commit comments

Comments
 (0)