Skip to content

Commit d40e4b4

Browse files
committed
SERVER-5128/SERVER-5130 Modify js test to validate both tickets are fixed
Also gets rid of one unnecessary noPassthroughWithMongod test.
1 parent 8ae0a29 commit d40e4b4

File tree

4 files changed

+79
-114
lines changed

4 files changed

+79
-114
lines changed

buildscripts/resmokeconfig/suites/sharding_continuous_config_stepdown.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ selector:
107107
- jstests/sharding/stale_mongos_updates_and_removes.js
108108
- jstests/sharding/zero_shard_version.js
109109
# Already stop or blackholes the primary of the CSRS config shard
110-
- jstests/sharding/all_config_hosts_down.js
110+
- jstests/sharding/all_shard_and_config_hosts_brought_down_one_by_one.js
111111
- jstests/sharding/all_config_servers_blackholed_from_mongos.js
112112
- jstests/sharding/batch_write_command_sharded.js
113113
- jstests/sharding/config_rs_no_primary.js

jstests/noPassthroughWithMongod/replica_set_shard_version.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

jstests/sharding/all_config_hosts_down.js

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Shuts down config server and shard replica set nodes one by one and ensures correct behaviour.
3+
*/
4+
5+
// Checking UUID consistency involves talking to the config servers, which are shut down in this
6+
// test.
7+
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
8+
9+
(function() {
10+
'use strict';
11+
12+
var st = new ShardingTest({shards: {rs0: {nodes: 2}}});
13+
14+
jsTest.log('Config nodes up: 3 of 3, shard nodes up: 2 of 2: ' +
15+
'Insert test data to work with');
16+
assert.writeOK(st.s0.getDB('TestDB').TestColl.update(
17+
{_id: 0}, {$inc: {count: 1}}, {upsert: true, writeConcern: {w: 2, wtimeout: 30000}}));
18+
assert.eq([{_id: 0, count: 1}], st.s0.getDB('TestDB').TestColl.find().toArray());
19+
20+
jsTest.log('Config nodes up: 2 of 3, shard nodes up: 2 of 2: ' +
21+
'Inserts and queries must work');
22+
st.configRS.stop(0);
23+
st.restartMongos(0);
24+
assert.writeOK(st.s0.getDB('TestDB').TestColl.update(
25+
{_id: 0}, {$inc: {count: 1}}, {upsert: true, writeConcern: {w: 2, wtimeout: 30000}}));
26+
assert.eq([{_id: 0, count: 2}], st.s0.getDB('TestDB').TestColl.find().toArray());
27+
28+
jsTest.log('Config nodes up: 1 of 3, shard nodes up: 2 of 2: ' +
29+
'Inserts and queries must work');
30+
st.configRS.stop(1);
31+
st.restartMongos(0);
32+
assert.writeOK(st.s0.getDB('TestDB').TestColl.update(
33+
{_id: 0}, {$inc: {count: 1}}, {upsert: true, writeConcern: {w: 2, wtimeout: 30000}}));
34+
assert.eq([{_id: 0, count: 3}], st.s0.getDB('TestDB').TestColl.find().toArray());
35+
36+
jsTest.log('Config nodes up: 1 of 3, shard nodes up: 1 of 2: ' +
37+
'Only queries will work (no shard primary)');
38+
st.rs0.stop(0);
39+
st.restartMongos(0);
40+
st.s0.setSlaveOk(true);
41+
assert.eq([{_id: 0, count: 3}], st.s0.getDB('TestDB').TestColl.find().toArray());
42+
43+
jsTest.log('Config nodes up: 1 of 3, shard nodes up: 0 of 2: ' +
44+
'MongoS must start, but no operations will work (no shard nodes available)');
45+
st.rs0.stop(1);
46+
st.restartMongos(0);
47+
assert.throws(function() {
48+
st.s0.getDB('TestDB').TestColl.find().toArray();
49+
});
50+
51+
jsTest.log('Config nodes up: 0 of 3, shard nodes up: 0 of 2: ' +
52+
'Metadata cannot be loaded at all, no operations will work');
53+
st.configRS.stop(1);
54+
55+
// Instead of restarting mongos, ensure it has no metadata
56+
assert.commandWorked(st.s0.adminCommand({flushRouterConfig: 1}));
57+
58+
// Throws transport error first and subsequent times when loading config data, not no primary
59+
for (var i = 0; i < 2; i++) {
60+
try {
61+
st.s0.getDB('TestDB').TestColl.findOne();
62+
63+
// Must always throw
64+
assert(false);
65+
} catch (e) {
66+
printjson(e);
67+
68+
// Make sure we get a transport error, and not a no-primary error
69+
assert(e.code == 10276 || // Transport error
70+
e.code == 13328 || // Connect error
71+
e.code == ErrorCodes.HostUnreachable ||
72+
e.code == ErrorCodes.FailedToSatisfyReadPreference ||
73+
e.code == ErrorCodes.ReplicaSetNotFound);
74+
}
75+
}
76+
77+
st.stop();
78+
}());

0 commit comments

Comments
 (0)