0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/noPassthroughWithMongod/fsync2.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2012-06-04 17:45:29 +02:00
function debug( msg ) {
print( "fsync2: " + msg );
}
var loops = 200;
if ( db.getSisterDB("local").slaves.count() > 0 ) {
// replication can cause some write locks on local
// therefore this test is flaky with replication on
loops = 1;
}
2012-06-04 17:37:56 +02:00
function doTest() {
db.fsync2.drop();
// Make write ops asynchronous so the test won't hang when in fsync lock mode.
db.getMongo().forceWriteMode('legacy');
2012-06-04 17:37:56 +02:00
db.fsync2.save( {x:1} );
d = db.getSisterDB( "admin" );
assert.commandWorked( d.runCommand( {fsync:1, lock: 1 } ) );
2012-06-04 17:45:29 +02:00
debug( "after lock" );
2012-06-04 17:37:56 +02:00
for ( var i=0; i<loops; i++) {
2012-06-04 17:45:29 +02:00
debug( "loop: " + i );
2012-06-04 17:37:56 +02:00
assert.eq(1, db.fsync2.count());
2012-06-04 17:45:29 +02:00
sleep(100);
2012-06-04 17:37:56 +02:00
}
2012-06-04 17:45:29 +02:00
debug( "about to save" );
2012-06-04 17:37:56 +02:00
db.fsync2.save( {x:1} );
2012-06-04 17:45:29 +02:00
debug( "save done" );
2012-06-04 17:37:56 +02:00
m = new Mongo( db.getMongo().host );
// Uncomment once SERVER-4243 is fixed
//assert.eq(1, m.getDB(db.getName()).fsync2.count());
assert( m.getDB("admin").fsyncUnlock().ok );
2012-06-04 17:37:56 +02:00
assert.eq( 2, db.fsync2.count() );
2012-02-03 15:28:35 +01:00
}
2012-06-04 17:37:56 +02:00
if (!jsTest.options().auth) { // SERVER-4243
doTest();
2012-02-03 15:28:35 +01:00
}