Skip to content

Commit

Permalink
SERVER-27549 Print message on intentional server crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Guo committed May 23, 2017
1 parent 7c53bb1 commit df10adb
Show file tree
Hide file tree
Showing 94 changed files with 226 additions and 229 deletions.
4 changes: 4 additions & 0 deletions buildscripts/resmokeconfig/suites/disk_mmapv1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/access_control_with_unreachable_configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/authz_modifications_access_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/basic_role_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/clac_system_colls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/copyauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
}
Expand Down
6 changes: 3 additions & 3 deletions jstests/auth/getMore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions jstests/auth/killop_own_ops.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/localhostAuthBypass.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions jstests/auth/log_user_basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/log_userid_off.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/mergeAuthCollsCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/pseudo_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/role_management_commands_edge_cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/role_management_commands_standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

var conn = MongoRunner.runMongod({auth: '', useHostname: false});
runAllRoleManagementCommandsTests(conn);
MongoRunner.stopMongod(conn.port);
MongoRunner.stopMongod(conn);
})();
2 changes: 1 addition & 1 deletion jstests/auth/server-4892.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function withMongod(extraMongodArgs, operation) {
try {
operation(mongod);
} finally {
MongoRunner.stopMongod(mongod.port);
MongoRunner.stopMongod(mongod);
}
}

Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/user_defined_roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/user_management_commands_edge_cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
Expand Down
2 changes: 1 addition & 1 deletion jstests/auth/user_management_commands_standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

var conn = MongoRunner.runMongod({auth: '', useHostname: false});
runAllUserManagementCommandsTests(conn);
MongoRunner.stopMongod(conn.port);
MongoRunner.stopMongod(conn);
})();
6 changes: 3 additions & 3 deletions jstests/disk/repair.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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(
Expand All @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions jstests/disk/repair2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -109,7 +109,7 @@ m = MongoRunner.runMongod({
});
db = m.getDB(longDBName);
check();
MongoRunner.stopMongod(m.port);
MongoRunner.stopMongod(m);

resetDbpath(repairpath);
returnCode = runMongoProgram("mongod",
Expand All @@ -131,7 +131,7 @@ m = MongoRunner.runMongod({
});
db = m.getDB(baseName);
check();
MongoRunner.stopMongod(m.port);
MongoRunner.stopMongod(m);

resetDbpath(repairpath);
returnCode =
Expand Down
4 changes: 2 additions & 2 deletions jstests/disk/repair3.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ if (doIt) {
}

check();
MongoRunner.stopMongod(m.port);
MongoRunner.stopMongod(m);

resetDbpath(repairpath);
var rc = runMongoProgram("mongod",
Expand All @@ -73,5 +73,5 @@ if (doIt) {
});
db = m.getDB(baseName);
check();
MongoRunner.stopMongod(m.port);
MongoRunner.stopMongod(m);
}
2 changes: 1 addition & 1 deletion jstests/disk/repair4.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ if (doIt) {
}

check();
MongoRunner.stopMongod(port);
MongoRunner.stopMongod(m);
}
2 changes: 1 addition & 1 deletion jstests/dur/a_quick.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 3 additions & 24 deletions jstests/dur/checksum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion jstests/dur/dropdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion jstests/dur/dur1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion jstests/dur/dur1_tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion jstests/dur/dur2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion jstests/dur/lsn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit df10adb

Please sign in to comment.