summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/refresh_syncclusterconn.js
blob: 90135fb9d512982b1ae0294b9e9bf0baa46258cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* SERVER-4385
 * SyncClusterConnection should refresh sub-connections on recieving exceptions
 *
 * 1. Start 3 config servers.
 * 2. Create a syncclusterconnection to the servers from step 1.
 * 3. Restart one of the config servers.
 * 4. Try an insert. It should fail. This will also refresh the sub connection.
 * 5. Try an insert again. This should work fine.
 */

var mongoA = MongoRunner.runMongod({});
var mongoB = MongoRunner.runMongod({});
var mongoC = MongoRunner.runMongod({});
var mongoSCC = new Mongo(mongoA.host + "," + mongoB.host + "," + mongoC.host);

MongoRunner.stopMongod(mongoA);
MongoRunner.runMongod({restart: mongoA.runId});

try {
    mongoSCC.getCollection("foo.bar").insert({x: 1});
    assert(false, "must throw an insert exception");
} catch (e) {
    printjson(e);
}

mongoSCC.getCollection("foo.bar").insert({blah: "blah"});
assert.eq(null, mongoSCC.getDB("foo").getLastError());