diff options
Diffstat (limited to 'jstests/readonly/lib')
-rw-r--r-- | jstests/readonly/lib/read_only_test.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/readonly/lib/read_only_test.js b/jstests/readonly/lib/read_only_test.js new file mode 100644 index 00000000000..6d144d6e0f8 --- /dev/null +++ b/jstests/readonly/lib/read_only_test.js @@ -0,0 +1,35 @@ +'use_strict'; + +function runReadOnlyTest(test) { + + assert.eq(typeof(test.exec), "function"); + assert.eq(typeof(test.load), "function"); + assert.eq(typeof(test.name), "string"); + + // TODO: read storageEngine from testData when read-only mode is supported in WiredTiger. + var options = { + storageEngine: 'mmapv1', + nopreallocj: '' + }; + + var writableMongod = MongoRunner.runMongod(options); + var dbpath = writableMongod.dbpath; + + jsTest.log("starting load phase for test: " + test.name); + test.load(writableMongod.getDB("test")[test.name]); + + MongoRunner.stopMongod(writableMongod); + + // TODO: change directory to read-only permissions when RO is implemented in MMAPv1. + var readOnlyOptions = Object.extend(options, + {readOnly: '', + dbpath: dbpath, + noCleanData: true}); + + var readOnlyMongod = MongoRunner.runMongod(readOnlyOptions); + + jsTest.log("starting execution phase for test: " + test.name); + test.exec(readOnlyMongod.getDB("test")[test.name]); + + MongoRunner.stopMongod(readOnlyMongod); +} |