summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Guo <robert.guo@10gen.com>2017-05-25 15:33:35 -0400
committerRobert Guo <robert.guo@10gen.com>2017-05-30 14:51:48 -0400
commit7b112f71fe551e92ae0a365f62fff402d4158035 (patch)
tree0d20c64242f8ed35145eb3c9458487512174d62c
parent3dc6ba1ad91727189c70ad41afdc446c76c81306 (diff)
downloadmongo-7b112f71fe551e92ae0a365f62fff402d4158035.tar.gz
SERVER-27549 Better check for when a server has shut down
-rw-r--r--jstests/multiVersion/transitioning_to_and_from_WT.js6
-rw-r--r--jstests/replsets/initial_sync_invalid_index_spec.js14
-rw-r--r--jstests/replsets/initial_sync_unsupported_auth_schema.js30
-rw-r--r--jstests/replsets/invalid_index_spec.js13
-rw-r--r--src/mongo/shell/servers.js5
5 files changed, 55 insertions, 13 deletions
diff --git a/jstests/multiVersion/transitioning_to_and_from_WT.js b/jstests/multiVersion/transitioning_to_and_from_WT.js
index 682abc95cfa..f1c5717226f 100644
--- a/jstests/multiVersion/transitioning_to_and_from_WT.js
+++ b/jstests/multiVersion/transitioning_to_and_from_WT.js
@@ -121,11 +121,7 @@
assert.eq(0, ret);
// stop previous mongod
- MongoRunner.stopMongod(toolTest.m);
-
- // clear old node configuration info
- toolTest.m = null;
- toolTest.db = null;
+ toolTest.stop();
// set up new node configuration info
toolTest.options.binVersion = MongoRunner.getBinVersionFor(entry.binVersion);
diff --git a/jstests/replsets/initial_sync_invalid_index_spec.js b/jstests/replsets/initial_sync_invalid_index_spec.js
index fc6e8dd7f77..d1126477894 100644
--- a/jstests/replsets/initial_sync_invalid_index_spec.js
+++ b/jstests/replsets/initial_sync_invalid_index_spec.js
@@ -22,7 +22,8 @@
{createIndexes: "test", indexes: [{v: 2, name: "x_1", key: {x: 1}, invalidOption: 1}]}));
// Add another node to the replica set to allow an initial sync to occur.
- var init_sync_node = replTest.add();
+ var initSyncNode = replTest.add();
+ var initSyncNodeAdminDB = initSyncNode.getDB("admin");
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(replTest);
@@ -36,7 +37,16 @@
};
assert.soon(assertFn, "Initial sync should have aborted on invalid index specification");
- replTest.stop(init_sync_node, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ assert.soon(function() {
+ try {
+ initSyncNodeAdminDB.runCommand({ping: 1});
+ } catch (e) {
+ return true;
+ }
+ return false;
+ }, "Node did not terminate due to invalid index spec during initial sync", 60 * 1000);
+
+ replTest.stop(initSyncNode, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
replTest.stopSet();
})();
diff --git a/jstests/replsets/initial_sync_unsupported_auth_schema.js b/jstests/replsets/initial_sync_unsupported_auth_schema.js
index 8e63c0039c1..5bc5d093bf4 100644
--- a/jstests/replsets/initial_sync_unsupported_auth_schema.js
+++ b/jstests/replsets/initial_sync_unsupported_auth_schema.js
@@ -19,7 +19,8 @@ function testInitialSyncAbortsWithUnsupportedAuthSchema(schema) {
assert.writeOK(res);
// Add another node to the replica set to allow an initial sync to occur
- var init_sync_node = rst.add();
+ var initSyncNode = rst.add();
+ var initSyncNodeAdminDB = initSyncNode.getDB("admin");
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(rst);
@@ -45,7 +46,16 @@ function testInitialSyncAbortsWithUnsupportedAuthSchema(schema) {
' authSchema version: ' + tojson(schema),
60000);
- rst.stop(init_sync_node, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ assert.soon(function() {
+ try {
+ initSyncNodeAdminDB.runCommand({ping: 1});
+ } catch (e) {
+ return true;
+ }
+ return false;
+ }, "Node did not terminate due to unsupported auth schema during initial sync", 60 * 1000);
+
+ rst.stop(initSyncNode, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
rst.stopSet();
}
@@ -65,7 +75,8 @@ function testInitialSyncAbortsWithExistingUserAndNoAuthSchema() {
assert.writeOK(res);
// Add another node to the replica set to allow an initial sync to occur
- var init_sync_node = rst.add();
+ var initSyncNode = rst.add();
+ var initSyncNodeAdminDB = initSyncNode.getDB("admin");
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(rst);
@@ -85,9 +96,18 @@ function testInitialSyncAbortsWithExistingUserAndNoAuthSchema() {
assert.soon(assertFn,
'Initial sync should have aborted due to an existing user document and' +
' a missing auth schema',
- 60000);
+ 60 * 1000);
+
+ assert.soon(function() {
+ try {
+ initSyncNodeAdminDB.runCommand({ping: 1});
+ } catch (e) {
+ return true;
+ }
+ return false;
+ }, "Node did not terminate due to unsupported auth schema during initial sync", 60 * 1000);
- rst.stop(init_sync_node, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ rst.stop(initSyncNode, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
rst.stopSet();
}
diff --git a/jstests/replsets/invalid_index_spec.js b/jstests/replsets/invalid_index_spec.js
index 80f5da09055..6805c806a89 100644
--- a/jstests/replsets/invalid_index_spec.js
+++ b/jstests/replsets/invalid_index_spec.js
@@ -14,6 +14,8 @@
replTest.initiate();
let primaryDB = replTest.getPrimary().getDB(testName);
+ let secondary = replTest.getSecondary();
+ let secondaryAdminDB = secondary.getDB("admin");
// Set a fail point that allows for index creation with invalid spec fields.
primaryDB.adminCommand(
@@ -38,6 +40,15 @@
};
assert.soon(assertFn, "Replication should have aborted on invalid index specification", 60000);
- replTest.stop(replTest.getSecondary(), undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ assert.soon(function() {
+ try {
+ secondaryAdminDB.runCommand({ping: 1});
+ } catch (e) {
+ return true;
+ }
+ return false;
+ }, "Node did not terminate due to invalid index spec", 60 * 1000);
+
+ replTest.stop(secondary, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
replTest.stopSet();
})();
diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js
index 69fecc2aab5..16e3ec4ebc0 100644
--- a/src/mongo/shell/servers.js
+++ b/src/mongo/shell/servers.js
@@ -849,6 +849,11 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
"it is usually the object returned from MongoRunner.runMongod/s");
}
+ if (!conn.port) {
+ throw new Error("first arg must have a `port` property; " +
+ "it is usually the object returned from MongoRunner.runMongod/s");
+ }
+
signal = parseInt(signal) || 15;
opts = opts || {};