summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-01-15 23:03:01 -0500
committerBenety Goh <benety@mongodb.com>2015-01-16 17:01:57 -0500
commit020cc851f48cca51ba2ac6c94ca93119a4563c4f (patch)
treecf1f7e2d25dfb9c8397109412791e79ddf669df3 /jstests
parent6bab2f390cfbae08bf0801668f54a5fd35db2bfc (diff)
downloadmongo-020cc851f48cca51ba2ac6c94ca93119a4563c4f.tar.gz
SERVER-16906 storage engines without directoryperdb support should fail to start up with --directoryperdb
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/directoryperdb.js75
1 files changed, 47 insertions, 28 deletions
diff --git a/jstests/noPassthrough/directoryperdb.js b/jstests/noPassthrough/directoryperdb.js
index cbfd30c328d..6e2522d62a2 100644
--- a/jstests/noPassthrough/directoryperdb.js
+++ b/jstests/noPassthrough/directoryperdb.js
@@ -1,28 +1,47 @@
-var baseDir = "jstests_directoryperdb";
-port = allocatePorts( 1 )[ 0 ];
-dbpath = MongoRunner.dataPath + baseDir + "/";
-
-var m = MongoRunner.runMongod({
- dbpath: dbpath,
- port: port,
- directoryperdb: ''});
-db = m.getDB( "foo" );
-db.bar.insert( { x : 1 } );
-assert.eq( 1, db.bar.count() );
-
-db.adminCommand( {fsync:1} );
-files = listFiles( dbpath ).filter( function(z) {
- return z.name.endsWith( "/foo" );
-} );
-assert.eq( 1, files.length );
-
-files = listFiles( files[0].name );
-assert( files.length > 0 );
-
-MongoRunner.stopMongod(port);
-
-// Subsequent attempt to start server using same dbpath without directoryperdb should fail.
-assert.isnull(MongoRunner.runMongod({
- dbpath: dbpath,
- port: port,
- restart: true}));
+(function() {
+ 'use strict';
+ var baseDir = "jstests_directoryperdb";
+ var port = allocatePorts( 1 )[ 0 ];
+ var dbpath = MongoRunner.dataPath + baseDir + "/";
+
+ var isDirectoryPerDBSupported =
+ jsTest.options().storageEngine == "mmapv1" ||
+ jsTest.options().storageEngine == "wiredTiger" ||
+ !jsTest.options().storageEngine;
+
+ var m = MongoRunner.runMongod({
+ dbpath: dbpath,
+ port: port,
+ directoryperdb: ''});
+
+ if (!isDirectoryPerDBSupported) {
+ assert.isnull(m, 'storage engine without directoryperdb support should fail to start up');
+ return;
+ }
+ else {
+ assert(m, 'storage engine with directoryperdb support failed to start up');
+ }
+
+ var db = m.getDB( "foo" );
+ db.bar.insert( { x : 1 } );
+ assert.eq( 1, db.bar.count() );
+
+ db.adminCommand( {fsync:1} );
+ var dbpathFiles = listFiles(dbpath);
+ var files = dbpathFiles.filter( function(z) {
+ return z.name.endsWith( "/foo" );
+ } );
+ assert.eq(1, files.length,
+ 'dbpath does not contain "foo" directory: ' + tojson(dbpathFiles));
+
+ files = listFiles( files[0].name );
+ assert( files.length > 0 );
+
+ MongoRunner.stopMongod(port);
+
+ // Subsequent attempt to start server using same dbpath without directoryperdb should fail.
+ assert.isnull(MongoRunner.runMongod({
+ dbpath: dbpath,
+ port: port,
+ restart: true}));
+}());