diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-26 18:42:24 -0400 |
commit | c1a45ebbb0530e3d0201321d725527f1eb83ffce (patch) | |
tree | f523079dc5ded3052eefbdcaae424b7502df5b25 /jstests/core/fsync.js | |
parent | c9599d8610c3da0b7c3da65667aff821063cf5b9 (diff) | |
download | mongo-c1a45ebbb0530e3d0201321d725527f1eb83ffce.tar.gz |
Apply formatting per `clang-format-7.0.1`
Diffstat (limited to 'jstests/core/fsync.js')
-rw-r--r-- | jstests/core/fsync.js | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/jstests/core/fsync.js b/jstests/core/fsync.js index 2f116364c34..bd5526b8bc9 100644 --- a/jstests/core/fsync.js +++ b/jstests/core/fsync.js @@ -9,107 +9,107 @@ * @tags: [requires_fastcount, requires_fsync] */ (function() { - "use strict"; - - // Start with a clean DB. - var fsyncLockDB = db.getSisterDB('fsyncLockTestDB'); - fsyncLockDB.dropDatabase(); - - // 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 - // that does not support the begin/end backup commands. - var supportsFsync = db.fsyncLock(); - - if (!supportsFsync.ok) { - assert.commandFailedWithCode(supportsFsync, ErrorCodes.CommandNotSupported); - jsTestLog("Skipping test for " + storageEngine + " as it does not support fsync"); - return; - } - db.fsyncUnlock(); - - var resFail = fsyncLockDB.runCommand({fsync: 1, lock: 1}); - - // Start with a clean DB - var fsyncLockDB = db.getSisterDB('fsyncLockTestDB'); - fsyncLockDB.dropDatabase(); - - // 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. - 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 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(3000); - - // Make sure reads can still run even though there is a pending write and also that the write - // didn't get through. - assert.eq(1, fsyncLockDB.coll.find({}).itcount()); - - // 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(); - assert.writeOK(fsyncLockDB.coll.insert({x: 2})); - - 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. - var fsyncLockRes = db.fsyncLock(); - assert(fsyncLockRes.ok, "Second execution of fsyncLock command failed"); - - var fsyncUnlockRes = db.fsyncUnlock(); - assert(fsyncUnlockRes.ok, "Second execution of fsyncUnlock command failed"); - - // Make sure that insert attempts made during multiple fsyncLock requests will not execute until - // all locks have been released. - fsyncLockRes = db.fsyncLock(); - assert.commandWorked(fsyncLockRes); - assert(fsyncLockRes.lockCount == 1, tojson(fsyncLockRes)); - let currentOp = db.currentOp(); - assert.commandWorked(currentOp); - assert(currentOp.fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server"); - - let shellHandle1 = - startParallelShell("db.getSisterDB('fsyncLockTestDB').multipleLock.insert({x:1});"); - - fsyncLockRes = db.fsyncLock(); - assert.commandWorked(fsyncLockRes); - assert(fsyncLockRes.lockCount == 2, tojson(fsyncLockRes)); - currentOp = db.currentOp(); - assert.commandWorked(currentOp); - assert(currentOp.fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server"); - - let shellHandle2 = - startParallelShell("db.getSisterDB('fsyncLockTestDB').multipleLock.insert({x:1});"); - sleep(3000); - assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); - - fsyncUnlockRes = db.fsyncUnlock(); - assert.commandWorked(fsyncUnlockRes); - assert(fsyncUnlockRes.lockCount == 1, tojson(fsyncLockRes)); - sleep(3000); - assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); - - fsyncUnlockRes = db.fsyncUnlock(); - assert.commandWorked(fsyncUnlockRes); - assert(fsyncUnlockRes.lockCount == 0, tojson(fsyncLockRes)); - shellHandle1(); - shellHandle2(); - assert.eq(2, fsyncLockDB.multipleLock.find({}).itcount()); +"use strict"; + +// Start with a clean DB. +var fsyncLockDB = db.getSisterDB('fsyncLockTestDB'); +fsyncLockDB.dropDatabase(); + +// 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 +// that does not support the begin/end backup commands. +var supportsFsync = db.fsyncLock(); + +if (!supportsFsync.ok) { + assert.commandFailedWithCode(supportsFsync, ErrorCodes.CommandNotSupported); + jsTestLog("Skipping test for " + storageEngine + " as it does not support fsync"); + return; +} +db.fsyncUnlock(); + +var resFail = fsyncLockDB.runCommand({fsync: 1, lock: 1}); + +// Start with a clean DB +var fsyncLockDB = db.getSisterDB('fsyncLockTestDB'); +fsyncLockDB.dropDatabase(); + +// 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. +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 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(3000); + +// Make sure reads can still run even though there is a pending write and also that the write +// didn't get through. +assert.eq(1, fsyncLockDB.coll.find({}).itcount()); + +// 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(); +assert.writeOK(fsyncLockDB.coll.insert({x: 2})); + +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. +var fsyncLockRes = db.fsyncLock(); +assert(fsyncLockRes.ok, "Second execution of fsyncLock command failed"); + +var fsyncUnlockRes = db.fsyncUnlock(); +assert(fsyncUnlockRes.ok, "Second execution of fsyncUnlock command failed"); + +// Make sure that insert attempts made during multiple fsyncLock requests will not execute until +// all locks have been released. +fsyncLockRes = db.fsyncLock(); +assert.commandWorked(fsyncLockRes); +assert(fsyncLockRes.lockCount == 1, tojson(fsyncLockRes)); +let currentOp = db.currentOp(); +assert.commandWorked(currentOp); +assert(currentOp.fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server"); + +let shellHandle1 = + startParallelShell("db.getSisterDB('fsyncLockTestDB').multipleLock.insert({x:1});"); + +fsyncLockRes = db.fsyncLock(); +assert.commandWorked(fsyncLockRes); +assert(fsyncLockRes.lockCount == 2, tojson(fsyncLockRes)); +currentOp = db.currentOp(); +assert.commandWorked(currentOp); +assert(currentOp.fsyncLock, "Value in db.currentOp incorrect for fsyncLocked server"); + +let shellHandle2 = + startParallelShell("db.getSisterDB('fsyncLockTestDB').multipleLock.insert({x:1});"); +sleep(3000); +assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); + +fsyncUnlockRes = db.fsyncUnlock(); +assert.commandWorked(fsyncUnlockRes); +assert(fsyncUnlockRes.lockCount == 1, tojson(fsyncLockRes)); +sleep(3000); +assert.eq(0, fsyncLockDB.multipleLock.find({}).itcount()); + +fsyncUnlockRes = db.fsyncUnlock(); +assert.commandWorked(fsyncUnlockRes); +assert(fsyncUnlockRes.lockCount == 0, tojson(fsyncLockRes)); +shellHandle1(); +shellHandle2(); +assert.eq(2, fsyncLockDB.multipleLock.find({}).itcount()); }()); |