summaryrefslogtreecommitdiff
path: root/jstests/core/fsync.js
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2016-05-19 10:47:24 -0400
committerKyle Suarez <kyle.suarez@mongodb.com>2016-05-19 10:48:25 -0400
commitca9cb5e288aec54a62823e22e5e4125d0d1b4f3f (patch)
tree97f126dac111e63882e5bb6491a628cbd82bcbe1 /jstests/core/fsync.js
parent0c2dfa5d4bf8af738465579aba3259c28742d465 (diff)
downloadmongo-ca9cb5e288aec54a62823e22e5e4125d0d1b4f3f.tar.gz
SERVER-23797 remove fsync2.js in favor of fsync.js
Diffstat (limited to 'jstests/core/fsync.js')
-rw-r--r--jstests/core/fsync.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/jstests/core/fsync.js b/jstests/core/fsync.js
index 57762ce8c78..346e75dcd80 100644
--- a/jstests/core/fsync.js
+++ b/jstests/core/fsync.js
@@ -10,11 +10,11 @@
(function() {
"use strict";
- // Start with a clean DB
+ // Start with a clean DB.
var fsyncLockDB = db.getSisterDB('fsyncLockTestDB');
fsyncLockDB.dropDatabase();
- // Tests the db.fsyncLock/fsyncUnlock features
+ // Tests the db.fsyncLock/fsyncUnlock features.
var storageEngine = db.serverStatus().storageEngine.name;
// As of SERVER-18899 fsyncLock/fsyncUnlock will error when called on a storage engine
@@ -34,35 +34,38 @@
var fsyncLockDB = db.getSisterDB('fsyncLockTestDB');
fsyncLockDB.dropDatabase();
- // Test it doesn't work unless invoked against the admin DB
+ // Test that a single, regular write works as expected.
+ assert.writeOK(fsyncLockDB.coll.insert({x: 1}));
+
+ // Test that fsyncLock doesn't work unless invoked against the admin DB.
var resFail = fsyncLockDB.runCommand({fsync: 1, lock: 1});
assert(!resFail.ok, "fsyncLock command succeeded against DB other than admin.");
- // Uses admin automatically and locks the server for writes
+ // Uses admin automatically and locks the server for writes.
var fsyncLockRes = db.fsyncLock();
assert(fsyncLockRes.ok, "fsyncLock command failed against admin DB");
assert(db.currentOp().fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server");
// Make sure writes are blocked. Spawn a write operation in a separate shell and make sure it
- // is blocked. There is really now way to do that currently, so just check that the write didn't
+ // is blocked. There is really no way to do that currently, so just check that the write didn't
// go through.
var writeOpHandle = startParallelShell("db.getSisterDB('fsyncLockTestDB').coll.insert({x:1});");
sleep(1000);
// Make sure reads can still run even though there is a pending write and also that the write
- // didn't get through
- assert.eq(0, fsyncLockDB.coll.count({}));
+ // didn't get through.
+ assert.eq(1, fsyncLockDB.coll.find({}).itcount());
- // Unlock and make sure the insert succeeded
+ // Unlock and make sure the insert succeeded.
var fsyncUnlockRes = db.fsyncUnlock();
assert(fsyncUnlockRes.ok, "fsyncUnlock command failed");
assert(db.currentOp().fsyncLock == null, "fsyncUnlock is not null in db.currentOp");
// Make sure the db is unlocked and the initial write made it through.
writeOpHandle();
- fsyncLockDB.coll.insert({x: 2});
+ assert.writeOK(fsyncLockDB.coll.insert({x: 2}));
- assert.eq(2, fsyncLockDB.coll.count({}));
+ assert.eq(3, fsyncLockDB.coll.count({}));
// Issue the fsyncLock and fsyncUnlock a second time, to ensure that we can
// run this command repeatedly with no problems.
@@ -76,9 +79,9 @@
assert(!db.eval('db.fsyncLock()').ok, "eval('db.fsyncLock()') should fail.");
// Check that the fsyncUnlock pseudo-command (a lookup on cmd.$sys.unlock)
- // still has the same effect as a legitimate 'fsyncUnlock' command
+ // still has the same effect as a legitimate 'fsyncUnlock' command.
// TODO: remove this in in the release following MongoDB 3.2 when pseudo-commands
- // are removed
+ // are removed.
var fsyncCommandRes = db.fsyncLock();
assert(fsyncLockRes.ok, "fsyncLock command failed against admin DB");
assert(db.currentOp().fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server");