summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/resmokeconfig/suites/disk_mmapv1.yml4
-rw-r--r--jstests/auth/access_control_with_unreachable_configs.js2
-rw-r--r--jstests/auth/authz_modifications_access_control.js2
-rw-r--r--jstests/auth/basic_role_auth.js2
-rw-r--r--jstests/auth/clac_system_colls.js2
-rw-r--r--jstests/auth/copyauth.js2
-rw-r--r--jstests/auth/getMore.js6
-rw-r--r--jstests/auth/killop_own_ops.js6
-rw-r--r--jstests/auth/localhostAuthBypass.js2
-rw-r--r--jstests/auth/log_user_basic.js6
-rw-r--r--jstests/auth/log_userid_off.js2
-rw-r--r--jstests/auth/mergeAuthCollsCommand.js2
-rw-r--r--jstests/auth/pseudo_commands.js2
-rw-r--r--jstests/auth/role_management_commands_edge_cases.js2
-rw-r--r--jstests/auth/role_management_commands_standalone.js2
-rw-r--r--jstests/auth/server-4892.js2
-rw-r--r--jstests/auth/user_defined_roles.js2
-rw-r--r--jstests/auth/user_management_commands_edge_cases.js2
-rw-r--r--jstests/auth/user_management_commands_standalone.js2
-rw-r--r--jstests/disk/repair.js6
-rw-r--r--jstests/disk/repair2.js12
-rw-r--r--jstests/disk/repair3.js4
-rw-r--r--jstests/disk/repair4.js2
-rw-r--r--jstests/dur/a_quick.js2
-rw-r--r--jstests/dur/checksum.js27
-rw-r--r--jstests/dur/dropdb.js2
-rw-r--r--jstests/dur/dur1.js2
-rw-r--r--jstests/dur/dur1_tool.js2
-rw-r--r--jstests/dur/dur2.js2
-rw-r--r--jstests/dur/lsn.js2
-rw-r--r--jstests/dur/manyRestart.js4
-rw-r--r--jstests/dur/oplog.js2
-rw-r--r--jstests/fail_point/fail_point.js2
-rw-r--r--jstests/libs/command_line/test_parsed_options.js4
-rw-r--r--jstests/libs/ssl_test.js3
-rw-r--r--jstests/multiVersion/libs/dumprestore_helpers.js4
-rw-r--r--jstests/multiVersion/transitioning_to_and_from_WT.js2
-rw-r--r--jstests/noPassthrough/compression_options.js2
-rw-r--r--jstests/noPassthrough/dir_per_db_and_split.js2
-rw-r--r--jstests/noPassthrough/directoryperdb.js2
-rw-r--r--jstests/noPassthrough/durable_view_catalog.js2
-rw-r--r--jstests/noPassthrough/exit_logging.js2
-rw-r--r--jstests/noPassthrough/index_no_retry.js2
-rw-r--r--jstests/noPassthrough/index_retry.js2
-rw-r--r--jstests/noPassthrough/libs/backup_restore.js11
-rw-r--r--jstests/noPassthrough/minvalid2.js2
-rw-r--r--jstests/noPassthrough/parameters.js2
-rw-r--r--jstests/noPassthrough/split_collections_and_indexes.js2
-rw-r--r--jstests/noPassthrough/sync_write.js2
-rw-r--r--jstests/noPassthrough/wt_nojournal_fsync.js2
-rw-r--r--jstests/noPassthrough/wt_nojournal_repl.js2
-rw-r--r--jstests/noPassthrough/wt_nojournal_skip_recovery.js2
-rw-r--r--jstests/noPassthrough/wt_nojournal_toggle.js2
-rw-r--r--jstests/noPassthrough/wt_unclean_shutdown.js2
-rw-r--r--jstests/noPassthroughWithMongod/indexbg_restart_secondary.js6
-rw-r--r--jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js5
-rw-r--r--jstests/noPassthroughWithMongod/logpath.js8
-rw-r--r--jstests/noPassthroughWithMongod/reconfigwt.js2
-rw-r--r--jstests/noPassthroughWithMongod/testing_only_commands.js4
-rw-r--r--jstests/noPassthroughWithMongod/ttl_repl_maintenance.js6
-rw-r--r--jstests/replsets/auth1.js1
-rw-r--r--jstests/replsets/cloneDb.js2
-rw-r--r--jstests/replsets/initial_sync_invalid_index_spec.js7
-rw-r--r--jstests/replsets/initial_sync_unsupported_auth_schema.js14
-rw-r--r--jstests/replsets/invalid_index_spec.js6
-rw-r--r--jstests/replsets/oplog_replay_on_startup_with_bad_op.js2
-rw-r--r--jstests/replsets/rollback_cmd_unrollbackable.js3
-rw-r--r--jstests/replsets/rollback_collMod_fatal.js3
-rw-r--r--jstests/replsets/rollback_dropdb.js3
-rw-r--r--jstests/replsets/rollback_too_new.js4
-rw-r--r--jstests/replsets/shutdown.js7
-rw-r--r--jstests/sharding/auth_no_config_primary.js2
-rw-r--r--jstests/sharding/convert_to_and_from_sharded.js2
-rw-r--r--jstests/sharding/implicit_db_creation.js2
-rw-r--r--jstests/sharding/lagged_config_secondary.js2
-rw-r--r--jstests/sharding/localhostAuthBypass.js14
-rw-r--r--jstests/sharding/shard_aware_init.js25
-rw-r--r--jstests/sharding/shard_aware_on_add_shard.js2
-rw-r--r--jstests/sharding/shard_identity_config_update.js2
-rw-r--r--jstests/sharding/shard_kill_and_pooling.js4
-rw-r--r--jstests/ssl/libs/ssl_helpers.js2
-rw-r--r--jstests/ssl/set_parameter_ssl.js4
-rw-r--r--jstests/ssl/ssl_cert_password.js2
-rw-r--r--jstests/ssl/ssl_hostname_validation.js2
-rw-r--r--jstests/ssl/ssl_options.js2
-rw-r--r--jstests/ssl/ssl_with_system_ca.js2
-rw-r--r--jstests/ssl/ssl_without_ca.js2
-rw-r--r--jstests/ssl/x509_client.js2
-rw-r--r--jstests/sslSpecial/set_parameter_nossl.js8
-rw-r--r--jstests/tool/dumprestore_excludecollections.js4
-rw-r--r--src/mongo/shell/bridge.js2
-rw-r--r--src/mongo/shell/replsettest.js8
-rw-r--r--src/mongo/shell/servers.js76
-rw-r--r--src/mongo/shell/shell_utils_launcher.cpp22
94 files changed, 226 insertions, 229 deletions
diff --git a/buildscripts/resmokeconfig/suites/disk_mmapv1.yml b/buildscripts/resmokeconfig/suites/disk_mmapv1.yml
index 6fb993c8a4b..194e5121cf9 100644
--- a/buildscripts/resmokeconfig/suites/disk_mmapv1.yml
+++ b/buildscripts/resmokeconfig/suites/disk_mmapv1.yml
@@ -4,6 +4,10 @@ selector:
- jstests/disk/*.js
exclude_files:
- jstests/disk/repair2.js # SERVER-18256
+ # The following tests require a dedicated disk partition to be set up. Otherwise they will
+ # silently be no-ops.
+ - jstests/disk/repair3.js
+ - jstests/disk/repair4.js
executor:
js_test:
diff --git a/jstests/auth/access_control_with_unreachable_configs.js b/jstests/auth/access_control_with_unreachable_configs.js
index 7e173475f7a..3d7f9ab24a6 100644
--- a/jstests/auth/access_control_with_unreachable_configs.js
+++ b/jstests/auth/access_control_with_unreachable_configs.js
@@ -36,7 +36,7 @@ assert.commandWorked(db.adminCommand('serverStatus'));
jsTest.log('repeat without config server');
// shut down only config server
-MongoRunner.stopMongod(config.port, /*signal*/ 15);
+MongoRunner.stopMongod(config);
// open a new connection to mongos (unauthorized)
var conn2 = new Mongo(mongos.host);
diff --git a/jstests/auth/authz_modifications_access_control.js b/jstests/auth/authz_modifications_access_control.js
index 7f7b01e12ba..483a54be4f8 100644
--- a/jstests/auth/authz_modifications_access_control.js
+++ b/jstests/auth/authz_modifications_access_control.js
@@ -296,7 +296,7 @@ function runTest(conn) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/basic_role_auth.js b/jstests/auth/basic_role_auth.js
index 0dfef842da8..a2484565755 100644
--- a/jstests/auth/basic_role_auth.js
+++ b/jstests/auth/basic_role_auth.js
@@ -486,7 +486,7 @@ var runTests = function(conn) {
var conn = MongoRunner.runMongod({auth: ''});
runTests(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 1, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/clac_system_colls.js b/jstests/auth/clac_system_colls.js
index 26a315db252..3ac67e28291 100644
--- a/jstests/auth/clac_system_colls.js
+++ b/jstests/auth/clac_system_colls.js
@@ -57,7 +57,7 @@ function runTest(admindb) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
runTest(conn.getDB("admin"));
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/copyauth.js b/jstests/auth/copyauth.js
index 6960692ef24..d93e726eaa1 100644
--- a/jstests/auth/copyauth.js
+++ b/jstests/auth/copyauth.js
@@ -78,7 +78,7 @@ function ClusterSpawnHelper(clusterType, startWithAuth, startWithTransitionToAut
} else if (clusterType === "repl") {
replSetTest.stopSet();
} else {
- MongoRunner.stopMongod(this.conn.port);
+ MongoRunner.stopMongod(this.conn);
}
};
}
diff --git a/jstests/auth/getMore.js b/jstests/auth/getMore.js
index ba1dc19173b..d8795278cbc 100644
--- a/jstests/auth/getMore.js
+++ b/jstests/auth/getMore.js
@@ -226,9 +226,9 @@
}
// Run the test on a standalone.
- let mongod = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"});
- runTest(mongod);
- MongoRunner.stopMongod(mongod);
+ let conn = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1"});
+ runTest(conn);
+ MongoRunner.stopMongod(conn);
// Run the test on a sharded cluster.
let cluster = new ShardingTest(
diff --git a/jstests/auth/killop_own_ops.js b/jstests/auth/killop_own_ops.js
index d412e31c8ce..562ee2645b4 100644
--- a/jstests/auth/killop_own_ops.js
+++ b/jstests/auth/killop_own_ops.js
@@ -149,9 +149,9 @@
assert.lt(diff, 30000, "Start: " + start + "; end: " + end + "; diff: " + diff);
}
- var m = MongoRunner.runMongod({auth: ""});
- runTest(m);
- MongoRunner.stopMongod(m);
+ var conn = MongoRunner.runMongod({auth: ""});
+ runTest(conn);
+ MongoRunner.stopMongod(conn);
// TODO: This feature is currently not supported on sharded clusters.
/*var st =
diff --git a/jstests/auth/localhostAuthBypass.js b/jstests/auth/localhostAuthBypass.js
index cd56e3bc160..aeb11465596 100644
--- a/jstests/auth/localhostAuthBypass.js
+++ b/jstests/auth/localhostAuthBypass.js
@@ -120,7 +120,7 @@ var authenticate = function(mongo) {
var shutdown = function(conn) {
print("============ shutting down.");
- MongoRunner.stopMongod(conn.port, /*signal*/ false, {auth: {user: username, pwd: password}});
+ MongoRunner.stopMongod(conn, /*signal*/ false, {auth: {user: username, pwd: password}});
};
var runTest = function(useHostName) {
diff --git a/jstests/auth/log_user_basic.js b/jstests/auth/log_user_basic.js
index 9e782fed9f5..298aa1f2eb5 100644
--- a/jstests/auth/log_user_basic.js
+++ b/jstests/auth/log_user_basic.js
@@ -248,9 +248,9 @@ if (0) {
})();
};
- var mongo = MongoRunner.runMongod({verbose: 5, setParameter: 'logUserIds=1'});
- doTest(mongo, new Mongo(mongo.host));
- MongoRunner.stopMongod(mongo.port);
+ var conn = MongoRunner.runMongod({verbose: 5, setParameter: 'logUserIds=1'});
+ doTest(conn, new Mongo(conn.host));
+ MongoRunner.stopMongod(conn);
var st = new ShardingTest(
{shards: 1, verbose: 5, other: {mongosOptions: {setParameter: 'logUserIds=1'}}});
diff --git a/jstests/auth/log_userid_off.js b/jstests/auth/log_userid_off.js
index 62d0af74c02..23e90b6fd1e 100644
--- a/jstests/auth/log_userid_off.js
+++ b/jstests/auth/log_userid_off.js
@@ -32,7 +32,7 @@ var doTest = function(mongo, callSetParam) {
var mongo = MongoRunner.runMongod({verbose: 5});
doTest(mongo);
-MongoRunner.stopMongod(mongo.port);
+MongoRunner.stopMongod(mongo);
var st = new ShardingTest({shards: 1, verbose: 5});
doTest(st.s);
diff --git a/jstests/auth/mergeAuthCollsCommand.js b/jstests/auth/mergeAuthCollsCommand.js
index c89a7ff460d..d5084d76a85 100644
--- a/jstests/auth/mergeAuthCollsCommand.js
+++ b/jstests/auth/mergeAuthCollsCommand.js
@@ -117,7 +117,7 @@ function runTest(conn) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3});
diff --git a/jstests/auth/pseudo_commands.js b/jstests/auth/pseudo_commands.js
index 2a882f219c8..921c1c3f548 100644
--- a/jstests/auth/pseudo_commands.js
+++ b/jstests/auth/pseudo_commands.js
@@ -187,7 +187,7 @@ function runTest(conn) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/role_management_commands_edge_cases.js b/jstests/auth/role_management_commands_edge_cases.js
index 5af309a1a7a..8adb7571692 100644
--- a/jstests/auth/role_management_commands_edge_cases.js
+++ b/jstests/auth/role_management_commands_edge_cases.js
@@ -376,7 +376,7 @@ function runTest(conn) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/role_management_commands_standalone.js b/jstests/auth/role_management_commands_standalone.js
index 38f848f9936..d35f2c30a3f 100644
--- a/jstests/auth/role_management_commands_standalone.js
+++ b/jstests/auth/role_management_commands_standalone.js
@@ -5,5 +5,5 @@
var conn = MongoRunner.runMongod({auth: '', useHostname: false});
runAllRoleManagementCommandsTests(conn);
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
})();
diff --git a/jstests/auth/server-4892.js b/jstests/auth/server-4892.js
index a6bbf89e69e..bfa51347fe1 100644
--- a/jstests/auth/server-4892.js
+++ b/jstests/auth/server-4892.js
@@ -28,7 +28,7 @@ function withMongod(extraMongodArgs, operation) {
try {
operation(mongod);
} finally {
- MongoRunner.stopMongod(mongod.port);
+ MongoRunner.stopMongod(mongod);
}
}
diff --git a/jstests/auth/user_defined_roles.js b/jstests/auth/user_defined_roles.js
index c786018dbb5..8c480385369 100644
--- a/jstests/auth/user_defined_roles.js
+++ b/jstests/auth/user_defined_roles.js
@@ -142,7 +142,7 @@ function runTest(conn) {
jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/user_management_commands_edge_cases.js b/jstests/auth/user_management_commands_edge_cases.js
index ab42714fb9a..704043e24b3 100644
--- a/jstests/auth/user_management_commands_edge_cases.js
+++ b/jstests/auth/user_management_commands_edge_cases.js
@@ -279,7 +279,7 @@ jsTest.log('Test standalone');
var conn = MongoRunner.runMongod({auth: ''});
conn.getDB('admin').runCommand({setParameter: 1, newCollectionsUsePowerOf2Sizes: false});
runTest(conn);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log('Test sharding');
var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
diff --git a/jstests/auth/user_management_commands_standalone.js b/jstests/auth/user_management_commands_standalone.js
index 951ee1e9801..192f5968aa2 100644
--- a/jstests/auth/user_management_commands_standalone.js
+++ b/jstests/auth/user_management_commands_standalone.js
@@ -5,5 +5,5 @@
var conn = MongoRunner.runMongod({auth: '', useHostname: false});
runAllUserManagementCommandsTests(conn);
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
})();
diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js
index cf86e50434d..e8c39f9563c 100644
--- a/jstests/disk/repair.js
+++ b/jstests/disk/repair.js
@@ -27,7 +27,7 @@ function check() {
assert.eq.automsg("1", "db[ baseName ].count()");
}
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
m = MongoRunner.runMongod({
@@ -38,7 +38,7 @@ m = MongoRunner.runMongod({
db = m.getDB(baseName);
assert.commandWorked(db.runCommand({repairDatabase: 1}));
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
rc = runMongoProgram(
@@ -51,7 +51,7 @@ m = MongoRunner.runMongod({
});
db = m.getDB(baseName);
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
rc = runMongoProgram("mongod", "--repair", "--port", m.port, "--dbpath", dbpath);
diff --git a/jstests/disk/repair2.js b/jstests/disk/repair2.js
index a73194c15eb..11be561ef71 100644
--- a/jstests/disk/repair2.js
+++ b/jstests/disk/repair2.js
@@ -48,7 +48,7 @@ for (f in files) {
assert(fileCount > 0, "Expected more than zero nondirectory files in the database directory");
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
m = MongoRunner.runMongod({
@@ -60,7 +60,7 @@ m = MongoRunner.runMongod({
db = m.getDB(baseName);
assert.commandWorked(db.runCommand({repairDatabase: 1}));
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
// Test long database names
resetDbpath(repairpath);
@@ -73,7 +73,7 @@ m = MongoRunner.runMongod({
db = m.getDB(longDBName);
assert.writeOK(db[baseName].save({}));
assert.commandWorked(db.runCommand({repairDatabase: 1}));
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
// Test long repairPath
resetDbpath(longRepairPath);
@@ -87,7 +87,7 @@ m = MongoRunner.runMongod({
db = m.getDB(longDBName);
assert.commandWorked(db.runCommand({repairDatabase: 1, backupOriginalFiles: true}));
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
// Test database name and repairPath with --repair
resetDbpath(longRepairPath);
@@ -109,7 +109,7 @@ m = MongoRunner.runMongod({
});
db = m.getDB(longDBName);
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
returnCode = runMongoProgram("mongod",
@@ -131,7 +131,7 @@ m = MongoRunner.runMongod({
});
db = m.getDB(baseName);
check();
-MongoRunner.stopMongod(m.port);
+MongoRunner.stopMongod(m);
resetDbpath(repairpath);
returnCode =
diff --git a/jstests/disk/repair3.js b/jstests/disk/repair3.js
index a2b64282d99..f339a666a70 100644
--- a/jstests/disk/repair3.js
+++ b/jstests/disk/repair3.js
@@ -47,7 +47,7 @@ if (doIt) {
}
check();
- MongoRunner.stopMongod(m.port);
+ MongoRunner.stopMongod(m);
resetDbpath(repairpath);
var rc = runMongoProgram("mongod",
@@ -73,5 +73,5 @@ if (doIt) {
});
db = m.getDB(baseName);
check();
- MongoRunner.stopMongod(m.port);
+ MongoRunner.stopMongod(m);
}
diff --git a/jstests/disk/repair4.js b/jstests/disk/repair4.js
index 2fed96e3674..15033dc5986 100644
--- a/jstests/disk/repair4.js
+++ b/jstests/disk/repair4.js
@@ -49,5 +49,5 @@ if (doIt) {
}
check();
- MongoRunner.stopMongod(port);
+ MongoRunner.stopMongod(m);
}
diff --git a/jstests/dur/a_quick.js b/jstests/dur/a_quick.js
index 5e1ff17a758..1528d6a8452 100644
--- a/jstests/dur/a_quick.js
+++ b/jstests/dur/a_quick.js
@@ -83,7 +83,7 @@ sleep(8000);
// kill the process hard
tst.log("kill -9 mongod");
-MongoRunner.stopMongod(conn.port, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/dur/checksum.js b/jstests/dur/checksum.js
index 0076024de66..789bae418ec 100644
--- a/jstests/dur/checksum.js
+++ b/jstests/dur/checksum.js
@@ -3,27 +3,6 @@
var testname = "dur_checksum";
var path = MongoRunner.dataPath + testname;
-if (0) {
- // This is used to create the prototype journal file.
- jsTest.log("Just creating prototype journal, not testing anything");
- var conn = MongoRunner.runMongod({dbpath: path, journal: ""});
- var db = conn.getDB("test");
-
- // each insert is in it's own commit.
- db.foo.insert({a: 1});
- db.runCommand({getlasterror: 1, j: 1});
-
- db.foo.insert({a: 2});
- db.runCommand({getlasterror: 1, j: 1});
-
- MongoRunner.stopMongod(conn.port, /*signal*/ 9);
-
- jsTest.log("Journal file left at " + path + "/journal/j._0");
- quit();
- // A hex editor must be used to replace the checksums of specific journal sections with
- // "0BADC0DE 1BADC0DE 2BADC0DE 3BADCD0E"
-}
-
function startMongodWithJournal() {
return MongoRunner.runMongod({
restart: true,
@@ -42,7 +21,7 @@ copyFile("jstests/libs/dur_checksum_good.journal", path + "/journal/j._0");
var conn = startMongodWithJournal();
var db = conn.getDB('test');
assert.eq(db.foo.count(), 2);
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
// dur_checksum_bad_last.journal is good.journal with the bad checksum on the last section.
jsTest.log("Starting with bad_last.journal");
@@ -52,7 +31,7 @@ copyFile("jstests/libs/dur_checksum_bad_last.journal", path + "/journal/j._0");
conn = startMongodWithJournal();
var db = conn.getDB('test');
assert.eq(db.foo.count(), 1); // 2nd insert "never happened"
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
// dur_checksum_bad_first.journal is good.journal with the bad checksum on the prior section.
// This means there is a good commit after the bad one. We currently ignore this, but a future
@@ -64,7 +43,7 @@ copyFile("jstests/libs/dur_checksum_bad_first.journal", path + "/journal/j._0");
conn = startMongodWithJournal();
var db = conn.getDB('test');
assert.eq(db.foo.count(), 0); // Neither insert happened.
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
// If we detect an error in a non-final journal file, that is considered an error.
jsTest.log("Starting with bad_last.journal followed by good.journal");
diff --git a/jstests/dur/dropdb.js b/jstests/dur/dropdb.js
index 9d60f60869a..d79c9b60ab8 100644
--- a/jstests/dur/dropdb.js
+++ b/jstests/dur/dropdb.js
@@ -125,7 +125,7 @@ verify();
// kill the process hard
log("kill 9");
-MongoRunner.stopMongod(conn.port, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/dur/dur1.js b/jstests/dur/dur1.js
index 568ba4ada55..3bd77e42c54 100644
--- a/jstests/dur/dur1.js
+++ b/jstests/dur/dur1.js
@@ -111,7 +111,7 @@ printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1}));
// kill the process hard
log("kill 9");
-MongoRunner.stopMongod(conn.port, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/dur/dur1_tool.js b/jstests/dur/dur1_tool.js
index e96e1f20c6d..fa645fac11f 100644
--- a/jstests/dur/dur1_tool.js
+++ b/jstests/dur/dur1_tool.js
@@ -111,7 +111,7 @@ printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1}));
// kill the process hard
log("kill 9");
-MongoRunner.stopMongod(conn, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/dur/dur2.js b/jstests/dur/dur2.js
index 5ff6aa9840e..b56949e00ad 100644
--- a/jstests/dur/dur2.js
+++ b/jstests/dur/dur2.js
@@ -82,7 +82,7 @@ conn = MongoRunner.runMongod({
work();
log("kill -9");
-MongoRunner.stopMongod(conn, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
assert(listFiles(path + "/journal/").length > 0,
diff --git a/jstests/dur/lsn.js b/jstests/dur/lsn.js
index 679475ad6ea..497b4597b2e 100644
--- a/jstests/dur/lsn.js
+++ b/jstests/dur/lsn.js
@@ -94,7 +94,7 @@ log("wait a while for a sync and an lsn write");
sleep(14); // wait for lsn write
log("kill mongod -9");
-MongoRunner.stopMongod(conn, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/dur/manyRestart.js b/jstests/dur/manyRestart.js
index f4d03f60edc..76c658d7bdd 100644
--- a/jstests/dur/manyRestart.js
+++ b/jstests/dur/manyRestart.js
@@ -146,7 +146,7 @@ for (var i = 0; i < 3; ++i) {
// kill the process hard
log("hard kill");
- MongoRunner.stopMongod(conn, /*signal*/ 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
sleep(5000);
}
@@ -204,7 +204,7 @@ for (var i = 0; i < 5; ++i) {
// kill the process hard
log("hard kill");
- MongoRunner.stopMongod(conn, /*signal*/ 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
sleep(5000);
}
diff --git a/jstests/dur/oplog.js b/jstests/dur/oplog.js
index be0bdd17948..fb56455c193 100644
--- a/jstests/dur/oplog.js
+++ b/jstests/dur/oplog.js
@@ -127,7 +127,7 @@ work();
printjson(conn.getDB('admin').runCommand({getlasterror: 1, fsync: 1}));
// kill the process hard
-MongoRunner.stopMongod(conn, /*signal*/ 9);
+MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// journal file should be present, and non-empty as we killed hard
diff --git a/jstests/fail_point/fail_point.js b/jstests/fail_point/fail_point.js
index 0bb08f0b358..b8c877cb9b2 100644
--- a/jstests/fail_point/fail_point.js
+++ b/jstests/fail_point/fail_point.js
@@ -69,7 +69,7 @@ var runTest = function(adminDB) {
var conn = MongoRunner.runMongod();
runTest(conn.getDB('admin'));
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
///////////////////////////////////////////////////////////
// Test mongos
diff --git a/jstests/libs/command_line/test_parsed_options.js b/jstests/libs/command_line/test_parsed_options.js
index c38d07668af..50e2733c520 100644
--- a/jstests/libs/command_line/test_parsed_options.js
+++ b/jstests/libs/command_line/test_parsed_options.js
@@ -52,7 +52,7 @@ function testGetCmdLineOptsMongod(mongoRunnerConfig, expectedResult) {
var getCmdLineOptsBaseMongod = baseMongod.adminCommand("getCmdLineOpts");
// Stop the mongod we used to get the options
- MongoRunner.stopMongod(baseMongod.port);
+ MongoRunner.stopMongod(baseMongod);
return getCmdLineOptsBaseMongod;
}
@@ -114,7 +114,7 @@ function testGetCmdLineOptsMongod(mongoRunnerConfig, expectedResult) {
// Cleanup
mongod.getDB("admin").logout();
- MongoRunner.stopMongod(mongod.port);
+ MongoRunner.stopMongod(mongod);
}
// Test that the parsed result of setting certain command line options has the correct format in
diff --git a/jstests/libs/ssl_test.js b/jstests/libs/ssl_test.js
index 11874ebc01e..1d3c2b06fe0 100644
--- a/jstests/libs/ssl_test.js
+++ b/jstests/libs/ssl_test.js
@@ -74,7 +74,8 @@ SSLTest.prototype.connectWorked = function() {
var serverPID = _startMongoProgram.apply(null, serverArgv);
try {
assert.soon(function() {
- return checkProgram(serverPID) && (0 === _runMongoProgram.apply(null, clientArgv));
+ return checkProgram(serverPID).alive &&
+ (0 === _runMongoProgram.apply(null, clientArgv));
}, "connect failed", connectTimeoutMillis);
} catch (ex) {
return false;
diff --git a/jstests/multiVersion/libs/dumprestore_helpers.js b/jstests/multiVersion/libs/dumprestore_helpers.js
index 5502a10bbb9..c62c817332b 100644
--- a/jstests/multiVersion/libs/dumprestore_helpers.js
+++ b/jstests/multiVersion/libs/dumprestore_helpers.js
@@ -95,7 +95,7 @@ function multiVersionDumpRestoreTest(configObj) {
host: serverSource.host,
db: testBaseName
});
- MongoRunner.stopMongod(serverSource.port);
+ MongoRunner.stopMongod(serverSource);
} else { /* "mongos" */
MongoRunner.runMongoTool("mongodump", {
out: configObj.dumpDir,
@@ -161,7 +161,7 @@ function multiVersionDumpRestoreTest(configObj) {
if (configObj.restoreType === "mongos") {
shardingTest.stop();
} else {
- MongoRunner.stopMongod(serverDest.port);
+ MongoRunner.stopMongod(serverDest);
}
}
diff --git a/jstests/multiVersion/transitioning_to_and_from_WT.js b/jstests/multiVersion/transitioning_to_and_from_WT.js
index f51e21a2ef9..682abc95cfa 100644
--- a/jstests/multiVersion/transitioning_to_and_from_WT.js
+++ b/jstests/multiVersion/transitioning_to_and_from_WT.js
@@ -121,7 +121,7 @@
assert.eq(0, ret);
// stop previous mongod
- MongoRunner.stopMongod(toolTest.port);
+ MongoRunner.stopMongod(toolTest.m);
// clear old node configuration info
toolTest.m = null;
diff --git a/jstests/noPassthrough/compression_options.js b/jstests/noPassthrough/compression_options.js
index acbb1d66ba7..3dc4e3b5601 100644
--- a/jstests/noPassthrough/compression_options.js
+++ b/jstests/noPassthrough/compression_options.js
@@ -32,7 +32,7 @@
output = JSON.parse(output);
assert.eq(output.compression, expected);
- MongoRunner.stopMongod(mongo.port);
+ MongoRunner.stopMongod(mongo);
};
assert.isnull(MongoRunner.runMongod({networkMessageCompressors: "snappy,disabled"}));
diff --git a/jstests/noPassthrough/dir_per_db_and_split.js b/jstests/noPassthrough/dir_per_db_and_split.js
index a9ddb0eb6d0..2704afa4aa2 100644
--- a/jstests/noPassthrough/dir_per_db_and_split.js
+++ b/jstests/noPassthrough/dir_per_db_and_split.js
@@ -13,7 +13,7 @@ if (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wired
assert(listFiles(dbpath + "/foo/index").length > 0);
assert(listFiles(dbpath + "/foo/collection").length > 0);
- MongoRunner.stopMongod(m.port);
+ MongoRunner.stopMongod(m);
// Subsequent attempts to start server using same dbpath but different
// wiredTigerDirectoryForIndexes and directoryperdb options should fail.
diff --git a/jstests/noPassthrough/directoryperdb.js b/jstests/noPassthrough/directoryperdb.js
index 52d3d700006..8561b810156 100644
--- a/jstests/noPassthrough/directoryperdb.js
+++ b/jstests/noPassthrough/directoryperdb.js
@@ -39,7 +39,7 @@
files = listFiles(files[0].name);
assert(files.length > 0);
- MongoRunner.stopMongod(m.port);
+ MongoRunner.stopMongod(m);
// Subsequent attempt to start server using same dbpath without directoryperdb should fail.
assert.isnull(MongoRunner.runMongod({dbpath: dbpath, restart: true}));
diff --git a/jstests/noPassthrough/durable_view_catalog.js b/jstests/noPassthrough/durable_view_catalog.js
index 5c06cf31167..02afd804fda 100644
--- a/jstests/noPassthrough/durable_view_catalog.js
+++ b/jstests/noPassthrough/durable_view_catalog.js
@@ -32,7 +32,7 @@
assert.commandWorked(viewsDB.runCommand({drop: "view1", writeConcern: {j: 1}}));
// Hard kill the mongod to ensure the data was indeed synced to durable storage.
- MongoRunner.stopMongod(conn, 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// Restart the mongod.
conn = MongoRunner.runMongod(mongodArgs);
diff --git a/jstests/noPassthrough/exit_logging.js b/jstests/noPassthrough/exit_logging.js
index f996766866f..1dee8c347db 100644
--- a/jstests/noPassthrough/exit_logging.js
+++ b/jstests/noPassthrough/exit_logging.js
@@ -48,7 +48,7 @@
crashFn(conn);
checkOutput();
} finally {
- launcher.stop(conn, undefined, {allowedExitCodes: [expectedExitCode]});
+ launcher.stop(conn, undefined, {allowedExitCode: expectedExitCode});
}
}
diff --git a/jstests/noPassthrough/index_no_retry.js b/jstests/noPassthrough/index_no_retry.js
index e05881c590a..40442555760 100644
--- a/jstests/noPassthrough/index_no_retry.js
+++ b/jstests/noPassthrough/index_no_retry.js
@@ -60,5 +60,5 @@
var indexes = t.getIndexes();
assert.eq(1, indexes.length, 'unfinished indexes in listIndexes result: ' + tojson(indexes));
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
}());
diff --git a/jstests/noPassthrough/index_retry.js b/jstests/noPassthrough/index_retry.js
index 4c870eacb10..f546c81ec38 100644
--- a/jstests/noPassthrough/index_retry.js
+++ b/jstests/noPassthrough/index_retry.js
@@ -61,5 +61,5 @@
indexes.length,
'unexpected number of indexes in listIndexes result: ' + tojson(indexes));
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
}());
diff --git a/jstests/noPassthrough/libs/backup_restore.js b/jstests/noPassthrough/libs/backup_restore.js
index 29380a1ef05..cba8915aec1 100644
--- a/jstests/noPassthrough/libs/backup_restore.js
+++ b/jstests/noPassthrough/libs/backup_restore.js
@@ -347,9 +347,16 @@ var BackupRestoreTest = function(options) {
rst.waitForState(hiddenNode, [ReplSetTest.State.RECOVERING, ReplSetTest.State.SECONDARY]);
// Stop CRUD client and FSM client.
- assert(checkProgram(crudPid), testName + ' CRUD client was not running at end of test');
- assert(checkProgram(fsmPid), testName + ' FSM client was not running at end of test');
+ var crudStatus = checkProgram(crudPid);
+ assert(crudStatus.alive,
+ testName + ' CRUD client was not running at end of test and exited with code: ' +
+ crudStatus.exitCode);
stopMongoProgramByPid(crudPid);
+
+ var fsmStatus = checkProgram(fsmPid);
+ assert(fsmStatus.alive,
+ testName + ' FSM client was not running at end of test and exited with code: ' +
+ fsmStatus.exitCode);
stopMongoProgramByPid(fsmPid);
// Wait up to 5 minutes until the new hidden node is in state SECONDARY.
diff --git a/jstests/noPassthrough/minvalid2.js b/jstests/noPassthrough/minvalid2.js
index f41a6a7e369..f51a1430490 100644
--- a/jstests/noPassthrough/minvalid2.js
+++ b/jstests/noPassthrough/minvalid2.js
@@ -90,4 +90,4 @@ assert.soon(function() {
'it does not contain the necessary operations for us to reach a consistent state');
});
-replTest.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+replTest.stopSet();
diff --git a/jstests/noPassthrough/parameters.js b/jstests/noPassthrough/parameters.js
index 53fe45acf7d..e157497464b 100644
--- a/jstests/noPassthrough/parameters.js
+++ b/jstests/noPassthrough/parameters.js
@@ -58,6 +58,6 @@ ensureSetParameterFailure(dbConn, "journalCommitInterval", 0);
ensureSetParameterFailure(dbConn, "syncdelay", 10 * 1000 * 1000);
ensureSetParameterFailure(dbConn, "syncdelay", -10 * 1000 * 1000);
-MongoRunner.stopMongod(dbConn.port);
+MongoRunner.stopMongod(dbConn);
jsTest.log("noPassthrough_parameters_test succeeded!");
diff --git a/jstests/noPassthrough/split_collections_and_indexes.js b/jstests/noPassthrough/split_collections_and_indexes.js
index 3ad5f95d999..9ad12b3eb48 100644
--- a/jstests/noPassthrough/split_collections_and_indexes.js
+++ b/jstests/noPassthrough/split_collections_and_indexes.js
@@ -13,7 +13,7 @@ if (!jsTest.options().storageEngine || jsTest.options().storageEngine === "wired
assert(listFiles(dbpath + "/index").length > 0);
assert(listFiles(dbpath + "/collection").length > 0);
- MongoRunner.stopMongod(m.port);
+ MongoRunner.stopMongod(m);
// Subsequent attempts to start server using same dbpath but different
// wiredTigerDirectoryForIndexes and directoryperdb options should fail.
diff --git a/jstests/noPassthrough/sync_write.js b/jstests/noPassthrough/sync_write.js
index b2f2fa24a45..8908d6bad5e 100644
--- a/jstests/noPassthrough/sync_write.js
+++ b/jstests/noPassthrough/sync_write.js
@@ -20,7 +20,7 @@
// Now connect to the mongod, do a journaled write and abruptly stop the server.
var testDB = conn.getDB('test');
assert.writeOK(testDB.synced.insert({synced: true}, {writeConcern: {j: true}}));
- MongoRunner.stopMongod(conn, 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// Restart the mongod.
conn = MongoRunner.runMongod(mongodArgs);
diff --git a/jstests/noPassthrough/wt_nojournal_fsync.js b/jstests/noPassthrough/wt_nojournal_fsync.js
index e5be8b9659e..3fd7d9ff05a 100644
--- a/jstests/noPassthrough/wt_nojournal_fsync.js
+++ b/jstests/noPassthrough/wt_nojournal_fsync.js
@@ -18,7 +18,7 @@ function writeDataAndRestart(doFsync) {
}
jsTestLog("kill -9");
- MongoRunner.stopMongod(conn, /*signal*/ 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
jsTestLog("restart node");
conn = MongoRunner.runMongod({
diff --git a/jstests/noPassthrough/wt_nojournal_repl.js b/jstests/noPassthrough/wt_nojournal_repl.js
index ebea3f1b5ab..2805d1506cf 100644
--- a/jstests/noPassthrough/wt_nojournal_repl.js
+++ b/jstests/noPassthrough/wt_nojournal_repl.js
@@ -61,7 +61,7 @@ if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredT
assert.commandWorked(secondary1.getDB("admin").runCommand({fsync: 1}));
jsTestLog("kill -9 secondary 1");
- MongoRunner.stopMongod(secondary1.port, /*signal*/ 9);
+ MongoRunner.stopMongod(secondary1, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
jsTestLog("add some data to a new collection bar");
for (var i = 0; i < 100; i++) {
diff --git a/jstests/noPassthrough/wt_nojournal_skip_recovery.js b/jstests/noPassthrough/wt_nojournal_skip_recovery.js
index df3b32609d0..7a5b0e7dc31 100644
--- a/jstests/noPassthrough/wt_nojournal_skip_recovery.js
+++ b/jstests/noPassthrough/wt_nojournal_skip_recovery.js
@@ -51,7 +51,7 @@
function() {
var count = conn.getDB('test').nojournal.count({journaled: {$exists: true}});
if (count >= 100) {
- MongoRunner.stopMongod(conn, 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
return true;
}
return false;
diff --git a/jstests/noPassthrough/wt_nojournal_toggle.js b/jstests/noPassthrough/wt_nojournal_toggle.js
index 8973c37b2f5..f09f92f6a95 100644
--- a/jstests/noPassthrough/wt_nojournal_toggle.js
+++ b/jstests/noPassthrough/wt_nojournal_toggle.js
@@ -60,7 +60,7 @@
// do an extra journaled write to make all visible commits durable, before killing
// the mongod.
assert.writeOK(testDB.nojournal.insert({final: true}, {writeConcern: {j: true}}));
- MongoRunner.stopMongod(conn, 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
return true;
}
return false;
diff --git a/jstests/noPassthrough/wt_unclean_shutdown.js b/jstests/noPassthrough/wt_unclean_shutdown.js
index 112413ec61b..74dceda2a5c 100644
--- a/jstests/noPassthrough/wt_unclean_shutdown.js
+++ b/jstests/noPassthrough/wt_unclean_shutdown.js
@@ -83,7 +83,7 @@ load('jstests/libs/parallelTester.js'); // For ScopedThread
// Mongod needs an unclean shutdown so that WT recovery is forced on restart and we can detect
// any missing records.
- MongoRunner.stopMongod(conn, 9);
+ MongoRunner.stopMongod(conn, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
// Retrieve the start and end data from each thread.
var retData = [];
diff --git a/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js b/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
index a84e2b57293..26b8083de75 100644
--- a/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
+++ b/jstests/noPassthroughWithMongod/indexbg_restart_secondary.js
@@ -27,8 +27,6 @@
var master = replTest.getPrimary();
var second = replTest.getSecondary();
- var secondId = replTest.getNodeId(second);
-
var masterDB = master.getDB('bgIndexSec');
var secondDB = second.getDB('bgIndexSec');
@@ -60,7 +58,9 @@
// the oplog entry so it isn't replayed. If (A) is present without (B), then there are two ways
// that the index can be rebuilt on startup and this test is only for the one triggered by (A).
secondDB.adminCommand({fsync: 1});
- replTest.restart(secondId, {}, /*signal=*/9, /*wait=*/true);
+
+ MongoRunner.stopMongod(second, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
+ replTest.start(second, {}, /*restart=*/true, /*wait=*/true);
// Make sure secondary comes back.
assert.soon(function() {
diff --git a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
index 747c8b2e6b8..05e1e2bed8f 100644
--- a/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
+++ b/jstests/noPassthroughWithMongod/indexbg_restart_secondary_noretry.js
@@ -26,8 +26,6 @@
var master = replTest.getPrimary();
var second = replTest.getSecondary();
- var secondId = replTest.getNodeId(second);
-
var masterDB = master.getDB('bgIndexNoRetrySec');
var secondDB = second.getDB('bgIndexNoRetrySec');
@@ -58,7 +56,8 @@
// the oplog entry so it isn't replayed. If (A) is present without (B), then there are two ways
// that the index can be rebuilt on startup and this test is only for the one triggered by (A).
secondDB.adminCommand({fsync: 1});
- replTest.restart(secondId, {}, /*signal=*/9, /*wait=*/true);
+ replTest.stop(second, 9, {allowedExitCode: MongoRunner.EXIT_SIGKILL});
+ replTest.start(second, {}, /*restart*/ true, /*wait=*/true);
// Make sure secondary comes back.
assert.soon(function() {
diff --git a/jstests/noPassthroughWithMongod/logpath.js b/jstests/noPassthroughWithMongod/logpath.js
index 3b6b2069937..eea71efdc4f 100644
--- a/jstests/noPassthroughWithMongod/logpath.js
+++ b/jstests/noPassthroughWithMongod/logpath.js
@@ -57,7 +57,7 @@ var m = MongoRunner.runMongod({port: port[0], dbpath: dbdir, logpath: logdir + l
// log should now exist (and no rotations should exist)
assert.eq(logCount(logs[0], true), 1);
-MongoRunner.stopMongod(port[0]);
+MongoRunner.stopMongod(m /*port[0]*/);
print("------ Start mongod with logpath set to existing file");
m = MongoRunner.runMongod({port: port[1], dbpath: dbdir, logpath: logdir + logs[0]});
@@ -69,7 +69,7 @@ assert.eq(logCount(logs[0]), 1);
assert.eq(logCount(logs[0], true), 2);
cleanupFiles();
-MongoRunner.stopMongod(port[1]);
+MongoRunner.stopMongod(m /*port[1]*/);
// Blocking on SERVER-5117:
// MongoRunner currently hangs if mongod fails to start so these tests don't work
@@ -85,7 +85,7 @@ if (false) {
// log should now exist (and no rotations should exist)
assert.eq(logCount(logs[1], true), 1);
- MongoRunner.stopMongod(port[2]);
+ MongoRunner.stopMongod(m /*port[2]*/);
print("------ Start mongod with logpath set to existing file, fork");
m = MongoRunner.runMongod(
@@ -98,7 +98,7 @@ if (false) {
assert.eq(logCount(logs[1], true), 2);
cleanupFiles();
- MongoRunner.stopMongod(port[3]);
+ MongoRunner.stopMongod(m /*port[3]*/);
}
// the following tests depend on undefined behavior; assume that MongoRunner raises exception on
diff --git a/jstests/noPassthroughWithMongod/reconfigwt.js b/jstests/noPassthroughWithMongod/reconfigwt.js
index 4176022e971..b7ae40891b2 100644
--- a/jstests/noPassthroughWithMongod/reconfigwt.js
+++ b/jstests/noPassthroughWithMongod/reconfigwt.js
@@ -33,5 +33,5 @@ if (ss.storageEngine.name !== "wiredTiger") {
assert.commandFailed(reconfigure("eviction_target=a"));
assert.commandFailed(reconfigure("fake_config_key=1"));
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
}
diff --git a/jstests/noPassthroughWithMongod/testing_only_commands.js b/jstests/noPassthroughWithMongod/testing_only_commands.js
index eeacd588974..55187010cc1 100644
--- a/jstests/noPassthroughWithMongod/testing_only_commands.js
+++ b/jstests/noPassthroughWithMongod/testing_only_commands.js
@@ -37,7 +37,7 @@ var conn = MongoRunner.runMongod({});
for (i in testOnlyCommands) {
assertCmdNotFound(conn.getDB('test'), testOnlyCommands[i]);
}
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
// Now enable the commands
jsTest.setOption('enableTestCommands', true);
@@ -46,4 +46,4 @@ var conn = MongoRunner.runMongod({});
for (i in testOnlyCommands) {
assertCmdFound(conn.getDB('test'), testOnlyCommands[i]);
}
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
diff --git a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js
index 45a5d752106..44250c4f1d2 100644
--- a/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js
+++ b/jstests/noPassthroughWithMongod/ttl_repl_maintenance.js
@@ -19,7 +19,7 @@ var primeSystemReplset = function() {
};
var restartWithConfig = function() {
- MongoRunner.stopMongod(conn.port, 15);
+ MongoRunner.stopMongod(conn);
conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: conn.dbpath});
testDB = conn.getDB("test");
var n = 100;
@@ -37,7 +37,7 @@ var restartWithoutConfig = function() {
var localDB = conn.getDB("local");
assert.writeOK(localDB.system.replset.remove({}));
- MongoRunner.stopMongod(conn.port, 15);
+ MongoRunner.stopMongod(conn);
conn = MongoRunner.runMongod({restart: true, cleanData: false, dbpath: conn.dbpath});
@@ -45,7 +45,7 @@ var restartWithoutConfig = function() {
return conn.getDB("test").foo.count() < 100;
}, "never deleted", 75000);
- MongoRunner.stopMongod(conn.port, 15);
+ MongoRunner.stopMongod(conn);
};
print("Create a TTL collection and put doc in local.system.replset");
diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js
index 69bba87a81d..4c4110597c5 100644
--- a/jstests/replsets/auth1.js
+++ b/jstests/replsets/auth1.js
@@ -40,7 +40,6 @@ load("jstests/replsets/rslib.js");
print("should fail with wrong permissions");
assert.eq(
m, _isWindows() ? 100 : 1, "mongod should exit w/ 1 (EXIT_FAILURE): permissions too open");
- MongoRunner.stopMongod(port[0]);
// Pre-populate the data directory for the first replica set node, to be started later, with
// a user's credentials.
diff --git a/jstests/replsets/cloneDb.js b/jstests/replsets/cloneDb.js
index a24b9d80c11..5590dd027f1 100644
--- a/jstests/replsets/cloneDb.js
+++ b/jstests/replsets/cloneDb.js
@@ -117,7 +117,7 @@
'cloneDatabase from standalone to SECONDARY succeeded and should not accept writes');
jsTest.log("Shut down replica set and standalone server");
- MongoRunner.stopMongod(standalone.port);
+ MongoRunner.stopMongod(standalone);
replTest.stopSet();
}
diff --git a/jstests/replsets/initial_sync_invalid_index_spec.js b/jstests/replsets/initial_sync_invalid_index_spec.js
index ce608334e8b..fc6e8dd7f77 100644
--- a/jstests/replsets/initial_sync_invalid_index_spec.js
+++ b/jstests/replsets/initial_sync_invalid_index_spec.js
@@ -22,7 +22,7 @@
{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.
- replTest.add();
+ var init_sync_node = replTest.add();
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(replTest);
@@ -36,8 +36,7 @@
};
assert.soon(assertFn, "Initial sync should have aborted on invalid index specification");
- replTest.stopSet(undefined,
- undefined,
- {allowedExitCodes: [MongoRunner.EXIT_ABRUPT, MongoRunner.EXIT_ABORT]});
+ replTest.stop(init_sync_node, 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 f097c8469df..8e63c0039c1 100644
--- a/jstests/replsets/initial_sync_unsupported_auth_schema.js
+++ b/jstests/replsets/initial_sync_unsupported_auth_schema.js
@@ -19,7 +19,7 @@ function testInitialSyncAbortsWithUnsupportedAuthSchema(schema) {
assert.writeOK(res);
// Add another node to the replica set to allow an initial sync to occur
- rst.add();
+ var init_sync_node = rst.add();
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(rst);
@@ -45,9 +45,8 @@ function testInitialSyncAbortsWithUnsupportedAuthSchema(schema) {
' authSchema version: ' + tojson(schema),
60000);
- rst.stopSet(undefined,
- undefined,
- {allowedExitCodes: [MongoRunner.EXIT_ABRUPT, MongoRunner.EXIT_ABORT]});
+ rst.stop(init_sync_node, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ rst.stopSet();
}
function testInitialSyncAbortsWithExistingUserAndNoAuthSchema() {
@@ -66,7 +65,7 @@ function testInitialSyncAbortsWithExistingUserAndNoAuthSchema() {
assert.writeOK(res);
// Add another node to the replica set to allow an initial sync to occur
- rst.add();
+ var init_sync_node = rst.add();
clearRawMongoProgramOutput();
reInitiateWithoutThrowingOnAbortedMember(rst);
@@ -88,9 +87,8 @@ function testInitialSyncAbortsWithExistingUserAndNoAuthSchema() {
' a missing auth schema',
60000);
- rst.stopSet(undefined,
- undefined,
- {allowedExitCodes: [MongoRunner.EXIT_ABRUPT, MongoRunner.EXIT_ABORT]});
+ rst.stop(init_sync_node, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ rst.stopSet();
}
testInitialSyncAbortsWithUnsupportedAuthSchema({_id: 'authSchema'});
diff --git a/jstests/replsets/invalid_index_spec.js b/jstests/replsets/invalid_index_spec.js
index d227854e6f7..80f5da09055 100644
--- a/jstests/replsets/invalid_index_spec.js
+++ b/jstests/replsets/invalid_index_spec.js
@@ -38,8 +38,6 @@
};
assert.soon(assertFn, "Replication should have aborted on invalid index specification", 60000);
- replTest.stopSet(undefined,
- undefined,
- {allowedExitCodes: [MongoRunner.EXIT_ABRUPT, MongoRunner.EXIT_ABORT]});
-
+ replTest.stop(replTest.getSecondary(), undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ replTest.stopSet();
})();
diff --git a/jstests/replsets/oplog_replay_on_startup_with_bad_op.js b/jstests/replsets/oplog_replay_on_startup_with_bad_op.js
index a58d94ec84b..e238cc05955 100644
--- a/jstests/replsets/oplog_replay_on_startup_with_bad_op.js
+++ b/jstests/replsets/oplog_replay_on_startup_with_bad_op.js
@@ -61,5 +61,5 @@
"If the Timestamps differ, the server may be filling in the null timestamps");
assert.throws(() => rst.restart(0)); // Restart in replSet mode again.
- print('\n\n\t\t^^^^^^^^ This was supposed to fassert ^^^^^^^^^^^\n\n');
+ rst.stopSet();
})();
diff --git a/jstests/replsets/rollback_cmd_unrollbackable.js b/jstests/replsets/rollback_cmd_unrollbackable.js
index 0abc3384db6..4d8acdb312a 100644
--- a/jstests/replsets/rollback_cmd_unrollbackable.js
+++ b/jstests/replsets/rollback_cmd_unrollbackable.js
@@ -74,4 +74,5 @@ assert.soon(function() {
return rawMongoProgramOutput().match(msg);
}, "Did not see a log entry about skipping the nonrollbackable command during rollback");
-replTest.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+replTest.stopSet();
diff --git a/jstests/replsets/rollback_collMod_fatal.js b/jstests/replsets/rollback_collMod_fatal.js
index b73b1e53440..c4409ced190 100644
--- a/jstests/replsets/rollback_collMod_fatal.js
+++ b/jstests/replsets/rollback_collMod_fatal.js
@@ -64,4 +64,5 @@ assert.soon(function() {
return rawMongoProgramOutput().match("cannot rollback a collMod command");
}, "B failed to fassert");
-replTest.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+replTest.stopSet(); \ No newline at end of file
diff --git a/jstests/replsets/rollback_dropdb.js b/jstests/replsets/rollback_dropdb.js
index 3944f7b821e..f3ee7607437 100644
--- a/jstests/replsets/rollback_dropdb.js
+++ b/jstests/replsets/rollback_dropdb.js
@@ -64,4 +64,5 @@ assert.soon(function() {
"rollback : can't rollback drop database full resync will be required");
}, "B failed to fassert");
-replTest.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
+replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+replTest.stopSet(); \ No newline at end of file
diff --git a/jstests/replsets/rollback_too_new.js b/jstests/replsets/rollback_too_new.js
index 131d80a54fe..75aa8ec0fc4 100644
--- a/jstests/replsets/rollback_too_new.js
+++ b/jstests/replsets/rollback_too_new.js
@@ -66,6 +66,6 @@
}
}, "node C failed to fassert", 60 * 1000);
- replTest.stopSet(undefined, undefined, {allowedExitCodes: [MongoRunner.EXIT_ABRUPT]});
-
+ replTest.stop(CID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
+ replTest.stopSet();
}());
diff --git a/jstests/replsets/shutdown.js b/jstests/replsets/shutdown.js
index e16e9af06b3..b35172a808f 100644
--- a/jstests/replsets/shutdown.js
+++ b/jstests/replsets/shutdown.js
@@ -19,10 +19,11 @@ load('jstests/replsets/rslib.js');
rst.initiate(conf);
rst.awaitReplication();
- let id = rst.getNodeId(rst.getSecondary());
- rst.stop(id);
+ let secondary = rst.getSecondary();
+ rst.stop(secondary);
let program = rst.start(
- id, {waitForConnect: false, setParameter: "failpoint.shutdownAtStartup={mode:'alwaysOn'}"});
+ secondary,
+ {waitForConnect: false, setParameter: "failpoint.shutdownAtStartup={mode:'alwaysOn'}"});
// mongod should exit automatically, since failpoint was set.
let exitCode = waitProgram(program.pid);
assert.eq(0, exitCode);
diff --git a/jstests/sharding/auth_no_config_primary.js b/jstests/sharding/auth_no_config_primary.js
index 0fdd2f31a89..a767ce4eee7 100644
--- a/jstests/sharding/auth_no_config_primary.js
+++ b/jstests/sharding/auth_no_config_primary.js
@@ -17,7 +17,7 @@
// Kill all secondaries, forcing the current primary to step down.
st.configRS.getSecondaries().forEach(function(secondaryConn) {
- MongoRunner.stopMongod(secondaryConn.port);
+ MongoRunner.stopMongod(secondaryConn);
});
// Test authenticate through a fresh connection.
diff --git a/jstests/sharding/convert_to_and_from_sharded.js b/jstests/sharding/convert_to_and_from_sharded.js
index e838559e0f8..08024a64104 100644
--- a/jstests/sharding/convert_to_and_from_sharded.js
+++ b/jstests/sharding/convert_to_and_from_sharded.js
@@ -88,7 +88,7 @@
return res.state == 'completed';
});
- MongoRunner.stopMongod(newMongod.port);
+ MongoRunner.stopMongod(newMongod);
checkBasicCRUD(st.s.getDB('test').unsharded);
checkBasicCRUD(st.s.getDB('test').sharded);
diff --git a/jstests/sharding/implicit_db_creation.js b/jstests/sharding/implicit_db_creation.js
index ed202ff2ea5..10442f7e97a 100644
--- a/jstests/sharding/implicit_db_creation.js
+++ b/jstests/sharding/implicit_db_creation.js
@@ -40,7 +40,7 @@
assert.neq(null, configDB.databases.findOne({_id: 'unshardedDB'}));
- MongoRunner.stopMongod(newShardConn.port);
+ MongoRunner.stopMongod(newShardConn);
st.stop();
})();
diff --git a/jstests/sharding/lagged_config_secondary.js b/jstests/sharding/lagged_config_secondary.js
index 0525e24aaae..3d109dd9056 100644
--- a/jstests/sharding/lagged_config_secondary.js
+++ b/jstests/sharding/lagged_config_secondary.js
@@ -26,7 +26,7 @@
assert.writeOK(st.getDB('config').TestConfigColl.insert({TestKey: 'Test value'}));
st.configRS.stopMaster();
- MongoRunner.stopMongod(configSecondaryToKill.port);
+ MongoRunner.stopMongod(configSecondaryToKill);
// Clears all cached info so mongos will be forced to query from the config.
st.s.adminCommand({flushRouterConfig: 1});
diff --git a/jstests/sharding/localhostAuthBypass.js b/jstests/sharding/localhostAuthBypass.js
index cd152410e3c..319c0eb2b79 100644
--- a/jstests/sharding/localhostAuthBypass.js
+++ b/jstests/sharding/localhostAuthBypass.js
@@ -35,7 +35,7 @@
} else {
assert.commandFailed(res, "Add shard");
}
- return m.port;
+ return m;
};
var findEmptyShard = function(st, ns) {
@@ -201,22 +201,22 @@
// information. Therefore, we'll do this manually for now.
for (var i = 0; i < st._mongos.length; i++) {
- var port = st["s" + i].port;
- MongoRunner.stopMongos(port,
+ var conn = st["s" + i];
+ MongoRunner.stopMongos(conn,
/*signal*/ false,
{auth: {user: username, pwd: password}});
}
for (var i = 0; i < st._connections.length; i++) {
- var port = st["shard" + i].port;
- MongoRunner.stopMongod(port,
+ var conn = st["shard" + i];
+ MongoRunner.stopMongod(conn,
/*signal*/ false,
{auth: {user: username, pwd: password}});
}
for (var i = 0; i < st._configServers.length; i++) {
- var c = st["config" + i].port;
- MongoRunner.stopMongod(port,
+ var conn = st["config" + i];
+ MongoRunner.stopMongod(conn,
/*signal*/ false,
{auth: {user: username, pwd: password}});
}
diff --git a/jstests/sharding/shard_aware_init.js b/jstests/sharding/shard_aware_init.js
index d6e27c7297c..386755dd9b2 100644
--- a/jstests/sharding/shard_aware_init.js
+++ b/jstests/sharding/shard_aware_init.js
@@ -37,14 +37,14 @@
var restartAndFixShardIdentityDoc = function(startOptions) {
var options = Object.extend({}, startOptions);
delete options.shardsvr;
- mongodConn = MongoRunner.runMongod(options);
+ var mongodConn = MongoRunner.runMongod(options);
waitForMaster(mongodConn);
var res = mongodConn.getDB('admin').system.version.update({_id: 'shardIdentity'},
shardIdentityDoc);
assert.eq(1, res.nModified);
- MongoRunner.stopMongod(mongodConn.port);
+ MongoRunner.stopMongod(mongodConn);
newMongodOptions.shardsvr = '';
mongodConn = MongoRunner.runMongod(newMongodOptions);
@@ -87,8 +87,7 @@
//
var newMongodOptions = Object.extend(mongodConn.savedOptions, {restart: true});
-
- MongoRunner.stopMongod(mongodConn.port);
+ MongoRunner.stopMongod(mongodConn);
mongodConn = MongoRunner.runMongod(newMongodOptions);
waitForMaster(mongodConn);
@@ -104,7 +103,7 @@
//
// Note: modification of the shardIdentity is allowed only when not running with --shardsvr
- MongoRunner.stopMongod(mongodConn.port);
+ MongoRunner.stopMongod(mongodConn);
delete newMongodOptions.shardsvr;
mongodConn = MongoRunner.runMongod(newMongodOptions);
waitForMaster(mongodConn);
@@ -112,7 +111,7 @@
assert.writeOK(mongodConn.getDB('admin').system.version.update(
{_id: 'shardIdentity'}, {_id: 'shardIdentity', shardName: 'x', clusterId: ObjectId()}));
- MongoRunner.stopMongod(mongodConn.port);
+ MongoRunner.stopMongod(mongodConn);
newMongodOptions.shardsvr = '';
assert.throws(function() {
@@ -124,14 +123,10 @@
// Test that it is possible to fix the invalid shardIdentity doc by not passing --shardsvr
//
- try {
- // The server was terminated not by calling stopMongod earlier, this will cleanup
- // the process from registry in shell_utils_launcher.
- MongoRunner.stopMongod(newMongodOptions.port);
- } catch (ex) {
- if (!(ex instanceof (MongoRunner.StopError))) {
- throw ex;
- }
+ // If mongodConn is not null, the server terminated after MongoRunner.runMongod() had
+ // returned. So we call stopMongod again to clean up the registry in shell_util_launcher.cpp
+ if (mongodConn) {
+ MongoRunner.stopMongod(mongodConn);
}
mongodConn = restartAndFixShardIdentityDoc(newMongodOptions);
@@ -145,7 +140,7 @@
runTest(mongod, st.configRS.getURL());
- MongoRunner.stopMongod(mongod.port);
+ MongoRunner.stopMongod(mongod);
var replTest = new ReplSetTest({nodes: 1});
replTest.startSet({shardsvr: ''});
diff --git a/jstests/sharding/shard_aware_on_add_shard.js b/jstests/sharding/shard_aware_on_add_shard.js
index 11c08349b60..92c490f2982 100644
--- a/jstests/sharding/shard_aware_on_add_shard.js
+++ b/jstests/sharding/shard_aware_on_add_shard.js
@@ -44,7 +44,7 @@
checkShardingStateInitialized(standaloneConn, st.configRS.getURL(), newShardName, clusterId);
checkShardMarkedAsShardAware(st.s, newShardName);
- MongoRunner.stopMongod(standaloneConn.port);
+ MongoRunner.stopMongod(standaloneConn);
// Add a shard that is a replica set.
diff --git a/jstests/sharding/shard_identity_config_update.js b/jstests/sharding/shard_identity_config_update.js
index 6d3b01deb41..dccdd03c669 100644
--- a/jstests/sharding/shard_identity_config_update.js
+++ b/jstests/sharding/shard_identity_config_update.js
@@ -73,7 +73,7 @@
st.rs0.stop(0);
st.rs0.stop(1);
- MongoRunner.stopMongod(newNode.port);
+ MongoRunner.stopMongod(newNode);
replConfig = st.configRS.getReplSetConfigFromNode();
replConfig.version += 1;
diff --git a/jstests/sharding/shard_kill_and_pooling.js b/jstests/sharding/shard_kill_and_pooling.js
index 369ebe6c3ee..54c5e9306bf 100644
--- a/jstests/sharding/shard_kill_and_pooling.js
+++ b/jstests/sharding/shard_kill_and_pooling.js
@@ -57,7 +57,9 @@ for (var test = 0; test < 2; test++) {
// Flush writes to disk, since sometimes we're killing uncleanly
assert(mongos.getDB("admin").runCommand({fsync: 1}).ok);
- MongoRunner.stopMongod(st.shard0, killWith);
+ var exitCode = killWith === 9 ? MongoRunner.EXIT_SIGKILL : MongoRunner.EXIT_CLEAN;
+
+ MongoRunner.stopMongod(st.shard0, killWith, {allowedExitCode: exitCode});
jsTest.log("Restart shard...");
diff --git a/jstests/ssl/libs/ssl_helpers.js b/jstests/ssl/libs/ssl_helpers.js
index 50463d8dec9..225b98a60ce 100644
--- a/jstests/ssl/libs/ssl_helpers.js
+++ b/jstests/ssl/libs/ssl_helpers.js
@@ -50,7 +50,7 @@ var replShouldFail = function(name, opt1, opt2) {
assert.throws(load, [replSetTestFile], "This setup should have failed");
// clean up to continue running...
if (replTest) {
- replTest.stopSet(15);
+ replTest.stopSet();
}
};
diff --git a/jstests/ssl/set_parameter_ssl.js b/jstests/ssl/set_parameter_ssl.js
index 407ed8b0834..a07db207b79 100644
--- a/jstests/ssl/set_parameter_ssl.js
+++ b/jstests/ssl/set_parameter_ssl.js
@@ -13,7 +13,7 @@ function testSSLTransition(oldMode, newMode, shouldSucceed) {
var res = adminDB.runCommand({"setParameter": 1, "sslMode": newMode});
assert(res["ok"] == shouldSucceed, tojson(res));
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
}
function testAuthModeTransition(oldMode, newMode, sslMode, shouldSucceed) {
@@ -30,7 +30,7 @@ function testAuthModeTransition(oldMode, newMode, sslMode, shouldSucceed) {
var res = adminDB.runCommand({"setParameter": 1, "clusterAuthMode": newMode});
assert(res["ok"] == shouldSucceed, tojson(res));
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
}
testSSLTransition("allowSSL", "invalid", false);
diff --git a/jstests/ssl/ssl_cert_password.js b/jstests/ssl/ssl_cert_password.js
index 064669ba2c6..a9590d92777 100644
--- a/jstests/ssl/ssl_cert_password.js
+++ b/jstests/ssl/ssl_cert_password.js
@@ -168,6 +168,6 @@ assert.eq(md5, md5_stored, "hash of stored file does not match the expected valu
if (!_isWindows()) {
// Stop the server
- var exitCode = MongoRunner.stopMongod(md.port, 15);
+ var exitCode = MongoRunner.stopMongod(md);
assert(exitCode == 0);
}
diff --git a/jstests/ssl/ssl_hostname_validation.js b/jstests/ssl/ssl_hostname_validation.js
index 9801e14807c..d61109293ba 100644
--- a/jstests/ssl/ssl_hostname_validation.js
+++ b/jstests/ssl/ssl_hostname_validation.js
@@ -58,7 +58,7 @@ function testCombination(certPath, allowInvalidHost, allowInvalidCert, shouldSuc
assert.eq(
1, mongo, "Connection attempt succeeded when it should fail certPath: " + certPath);
}
- MongoRunner.stopMongod(mongod.port);
+ MongoRunner.stopMongod(mongod);
}
// 1. Test client connections with different server certificates
diff --git a/jstests/ssl/ssl_options.js b/jstests/ssl/ssl_options.js
index 571f854851b..d1c0c04adcd 100644
--- a/jstests/ssl/ssl_options.js
+++ b/jstests/ssl/ssl_options.js
@@ -36,6 +36,6 @@ assert.eq(getCmdLineOptsResult.parsed.net.ssl.clusterPassword,
"<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
-MongoRunner.stopMongod(mongodSource.port);
+MongoRunner.stopMongod(mongodSource);
print(baseName + " succeeded.");
diff --git a/jstests/ssl/ssl_with_system_ca.js b/jstests/ssl/ssl_with_system_ca.js
index 3d96651ff94..194712c98ca 100644
--- a/jstests/ssl/ssl_with_system_ca.js
+++ b/jstests/ssl/ssl_with_system_ca.js
@@ -31,7 +31,7 @@
var exitStatus = runMongoProgram.apply(null, argv);
assert.eq(exitStatus, 0, "successfully connected with SSL");
- MongoRunner.stopMongod(conn.port);
+ MongoRunner.stopMongod(conn);
};
assert.throws(function() {
diff --git a/jstests/ssl/ssl_without_ca.js b/jstests/ssl/ssl_without_ca.js
index 2c7aba380bd..cbc3aaa37f1 100644
--- a/jstests/ssl/ssl_without_ca.js
+++ b/jstests/ssl/ssl_without_ca.js
@@ -32,7 +32,7 @@ var exitStatus = runMongoProgram('mongo',
assert.eq(exitStatus, 0, "authentication via MONGODB-X509 without CA succeeded");
-MongoRunner.stopMongod(conn.port);
+MongoRunner.stopMongod(conn);
jsTest.log("Assert mongod doesn\'t start with CA file missing and clusterAuthMode=x509.");
diff --git a/jstests/ssl/x509_client.js b/jstests/ssl/x509_client.js
index 5842438b98a..ec9b63e6dba 100644
--- a/jstests/ssl/x509_client.js
+++ b/jstests/ssl/x509_client.js
@@ -88,7 +88,7 @@ var x509_options = {sslMode: "requireSSL", sslPEMKeyFile: SERVER_CERT, sslCAFile
var mongo = MongoRunner.runMongod(Object.merge(x509_options, {auth: ""}));
authAndTest(mongo);
-MongoRunner.stopMongod(mongo.port);
+MongoRunner.stopMongod(mongo);
print("2. Testing x.509 auth to mongos");
diff --git a/jstests/sslSpecial/set_parameter_nossl.js b/jstests/sslSpecial/set_parameter_nossl.js
index 74bab379aa0..95b66bc274f 100644
--- a/jstests/sslSpecial/set_parameter_nossl.js
+++ b/jstests/sslSpecial/set_parameter_nossl.js
@@ -7,12 +7,14 @@ function testTransition(newSSLMode, newClusterAuthMode) {
// If no parameters are given sslMode defaults to disabled
var conn = MongoRunner.runMongod({clusterAuthMode: "keyFile"});
var adminDB = conn.getDB("admin");
+ adminDB.createUser({user: "root", pwd: "pwd", roles: ["root"]});
+ adminDB.auth("root", "pwd");
var res = adminDB.runCommand({"setParameter": 1, "sslMode": newSSLMode});
- assert(!res["ok"]);
+ assert.commandFailedWithCode(res, ErrorCodes.BadValue);
var res = adminDB.runCommand({"setParameter": 1, "clusterAuthMode": newClusterAuthMode});
- assert(!res["ok"]);
- MongoRunner.stopMongod(conn.port);
+ assert.commandFailedWithCode(res, ErrorCodes.BadValue);
+ MongoRunner.stopMongod(conn);
}
testTransition("allowSSL", "sendKeyFile");
diff --git a/jstests/tool/dumprestore_excludecollections.js b/jstests/tool/dumprestore_excludecollections.js
index c3f18065ce3..cfda283b46a 100644
--- a/jstests/tool/dumprestore_excludecollections.js
+++ b/jstests/tool/dumprestore_excludecollections.js
@@ -114,7 +114,7 @@ destDB.dropDatabase();
// times, but that is not tested here because right now MongoRunners can only be configured using
// javascript objects which do not allow duplicate keys. See SERVER-14220.
-MongoRunner.stopMongod(mongodDest.port);
-MongoRunner.stopMongod(mongodSource.port);
+MongoRunner.stopMongod(mongodDest);
+MongoRunner.stopMongod(mongodSource);
print(testBaseName + " success!");
diff --git a/src/mongo/shell/bridge.js b/src/mongo/shell/bridge.js
index 74e6e674d71..702d823bf97 100644
--- a/src/mongo/shell/bridge.js
+++ b/src/mongo/shell/bridge.js
@@ -81,7 +81,7 @@ function MongoBridge(options) {
this.connectToBridge = function connectToBridge() {
var failedToStart = false;
assert.soon(() => {
- if (!checkProgram(pid)) {
+ if (!checkProgram(pid).alive) {
failedToStart = true;
return true;
}
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 8ad663b0074..dbad80e7036 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -1715,11 +1715,11 @@ var ReplSetTest = function(opts) {
n = this.getNodeId(n);
- var port = _useBridge ? _unbridgedPorts[n] : this.ports[n];
- print('ReplSetTest stop *** Shutting down mongod in port ' + port + ' ***');
- var ret = MongoRunner.stopMongod(port, signal, opts);
+ var conn = _useBridge ? _unbridgedNodes[n] : this.nodes[n];
+ print('ReplSetTest stop *** Shutting down mongod in port ' + conn.port + ' ***');
+ var ret = MongoRunner.stopMongod(conn, signal, opts);
- print('ReplSetTest stop *** Mongod in port ' + port + ' shutdown with code (' + ret +
+ print('ReplSetTest stop *** Mongod in port ' + conn.port + ' shutdown with code (' + ret +
') ***');
if (_useBridge) {
diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js
index a0f58c5b415..69fecc2aab5 100644
--- a/src/mongo/shell/servers.js
+++ b/src/mongo/shell/servers.js
@@ -6,6 +6,11 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
var shellVersion = version;
+ // Record the exit codes of mongod and mongos processes that crashed during startup keyed by
+ // pid. This map is cleared when MongoRunner._startWithArgs and MongoRunner.stopMongod/s are
+ // called.
+ var serverExitCodeMap = {};
+
var _parsePath = function() {
var dbpath = "";
for (var i = 0; i < arguments.length; ++i)
@@ -788,10 +793,10 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
return mongos;
};
- MongoRunner.StopError = function(message, returnCode) {
+ MongoRunner.StopError = function(returnCode) {
this.name = "StopError";
- this.returnCode = returnCode || "non-zero";
- this.message = message || "MongoDB process stopped with exit code: " + this.returnCode;
+ this.returnCode = returnCode;
+ this.message = "MongoDB process stopped with exit code: " + this.returnCode;
this.stack = this.toString() + "\n" + (new Error()).stack;
};
@@ -805,6 +810,9 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
MongoRunner.EXIT_REPLICATION_ERROR = 3;
MongoRunner.EXIT_NEED_UPGRADE = 4;
MongoRunner.EXIT_SHARDING_ERROR = 5;
+ // SIGKILL is translated to TerminateProcess() on Windows, which causes the program to
+ // terminate with exit code 1.
+ MongoRunner.EXIT_SIGKILL = _isWindows() ? 1 : -9;
MongoRunner.EXIT_KILL = 12;
MongoRunner.EXIT_ABRUPT = 14;
MongoRunner.EXIT_NTSERVICE_ERROR = 20;
@@ -822,7 +830,7 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
/**
* Kills a mongod process.
*
- * @param {number} port the port of the process to kill
+ * @param {Mongo} conn the connection object to the process to kill
* @param {number} signal The signal number to use for killing
* @param {Object} opts Additional options. Format:
* {
@@ -835,44 +843,38 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
* Note: The auth option is required in a authenticated mongod running in Windows since
* it uses the shutdown command, which requires admin credentials.
*/
- MongoRunner.stopMongod = function(port, signal, opts) {
-
- if (!port) {
- print("Cannot stop mongo process " + port);
- return null;
+ MongoRunner.stopMongod = function(conn, signal, opts) {
+ if (!conn.pid) {
+ throw new Error("first arg must have a `pid` property; " +
+ "it is usually the object returned from MongoRunner.runMongod/s");
}
signal = parseInt(signal) || 15;
opts = opts || {};
- var allowedExitCodes = [MongoRunner.EXIT_CLEAN];
-
- if (_isWindows()) {
- // Return code of processes killed with TerminateProcess on Windows
- allowedExitCodes.push(1);
- } else {
- // Return code of processes killed with SIGKILL on POSIX systems
- allowedExitCodes.push(-9);
- }
+ var allowedExitCode = MongoRunner.EXIT_CLEAN;
- if (opts.allowedExitCodes) {
- allowedExitCodes = allowedExitCodes.concat(opts.allowedExitCodes);
+ if (opts.allowedExitCode) {
+ allowedExitCode = opts.allowedExitCode;
}
- if (port.port)
- port = parseInt(port.port);
+ var port = parseInt(conn.port);
- if (port instanceof ObjectId) {
- var opts = MongoRunner.savedOptions(port);
- if (opts)
- port = parseInt(opts.port);
+ var pid = conn.pid;
+ // If the return code is in the serverExitCodeMap, it means the server crashed on startup.
+ // We just use the recorded return code instead of stopping the program.
+ var returnCode;
+ if (pid in serverExitCodeMap) {
+ returnCode = serverExitCodeMap[pid];
+ delete serverExitCodeMap[pid];
+ } else {
+ returnCode = _stopMongoProgram(port, signal, opts);
}
-
- var returnCode = _stopMongoProgram(parseInt(port), signal, opts);
-
- if (!Array.contains(allowedExitCodes, returnCode)) {
- throw new MongoRunner.StopError(
- `MongoDB process on port ${port} exited with error code ${returnCode}`, returnCode);
+ if (allowedExitCode !== returnCode) {
+ throw new MongoRunner.StopError(returnCode);
+ } else if (returnCode !== MongoRunner.EXIT_CLEAN) {
+ print("MongoDB process on port " + port + " intentionally exited with error code ",
+ returnCode);
}
return returnCode;
@@ -1130,6 +1132,7 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
pid = _startMongoProgram({args: argArray, env: env});
}
+ delete serverExitCodeMap[pid];
if (!waitForConnect) {
return {
pid: pid,
@@ -1143,10 +1146,10 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
conn.pid = pid;
return true;
} catch (e) {
- if (!checkProgram(pid)) {
+ var res = checkProgram(pid);
+ if (!res.alive) {
print("Could not start mongo program at " + port + ", process ended");
-
- // Break out
+ serverExitCodeMap[pid] = res.exitCode;
return true;
}
}
@@ -1178,9 +1181,10 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro
assert.soon(function() {
try {
m = new Mongo("127.0.0.1:" + port);
+ m.pid = pid;
return true;
} catch (e) {
- if (!checkProgram(pid)) {
+ if (!checkProgram(pid).alive) {
print("Could not start mongo program at " + port + ", process ended");
// Break out
diff --git a/src/mongo/shell/shell_utils_launcher.cpp b/src/mongo/shell/shell_utils_launcher.cpp
index 8c1efb65a2d..b5c55090ee4 100644
--- a/src/mongo/shell/shell_utils_launcher.cpp
+++ b/src/mongo/shell/shell_utils_launcher.cpp
@@ -745,8 +745,12 @@ BSONObj ClearRawMongoProgramOutput(const BSONObj& args, void* data) {
BSONObj CheckProgram(const BSONObj& args, void* data) {
ProcessId pid = ProcessId::fromNative(singleArg(args).numberInt());
- bool isDead = wait_for_pid(pid, false);
- return BSON(string("") << (!isDead));
+ int exit_code = -123456; // sentinel value
+ bool isDead = wait_for_pid(pid, false, &exit_code);
+ if (!isDead) {
+ return BSON("" << BSON("alive" << true));
+ }
+ return BSON("" << BSON("alive" << false << "exitCode" << exit_code));
}
BSONObj WaitProgram(const BSONObj& a, void* data) {
@@ -1002,8 +1006,8 @@ BSONObj getStopMongodOpts(const BSONObj& a) {
/** stopMongoProgram(port[, signal]) */
BSONObj StopMongoProgram(const BSONObj& a, void* data) {
int nFields = a.nFields();
- verify(nFields >= 1 && nFields <= 3);
- uassert(15853, "stopMongo needs a number", a.firstElement().isNumber());
+ uassert(ErrorCodes::FailedToParse, "wrong number of arguments", nFields >= 1 && nFields <= 3);
+ uassert(ErrorCodes::BadValue, "stopMongoProgram needs a number", a.firstElement().isNumber());
int port = int(a.firstElement().number());
int code = killDb(port, ProcessId::fromNative(0), getSignal(a), getStopMongodOpts(a));
log() << "shell: stopped mongo program on port " << port;
@@ -1011,11 +1015,13 @@ BSONObj StopMongoProgram(const BSONObj& a, void* data) {
}
BSONObj StopMongoProgramByPid(const BSONObj& a, void* data) {
- verify(a.nFields() == 1 || a.nFields() == 2);
- uassert(15852, "stopMongoByPid needs a number", a.firstElement().isNumber());
+ int nFields = a.nFields();
+ uassert(ErrorCodes::FailedToParse, "wrong number of arguments", nFields >= 1 && nFields <= 3);
+ uassert(
+ ErrorCodes::BadValue, "stopMongoProgramByPid needs a number", a.firstElement().isNumber());
ProcessId pid = ProcessId::fromNative(int(a.firstElement().number()));
- int code = killDb(0, pid, getSignal(a));
- log() << "shell: stopped mongo program on pid " << pid;
+ int code = killDb(0, pid, getSignal(a), getStopMongodOpts(a));
+ log() << "shell: stopped mongo program with pid " << pid;
return BSON("" << (double)code);
}