diff options
author | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-11-20 18:42:24 -0500 |
---|---|---|
committer | Charlie Swanson <charlie.swanson@mongodb.com> | 2015-11-23 11:11:32 -0500 |
commit | add4a6c58835fc0b1211bdee118f23741bce4807 (patch) | |
tree | 6f3471d0bbbadf1964db97ef92d2a76c1e440415 /jstests/concurrency | |
parent | 56943a545ab503b11b747bb40779ab01be58766b (diff) | |
download | mongo-add4a6c58835fc0b1211bdee118f23741bce4807.tar.gz |
SERVER-21605 Compact command should error on inMemory storage engine
Diffstat (limited to 'jstests/concurrency')
3 files changed, 32 insertions, 17 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/server_types.js b/jstests/concurrency/fsm_workload_helpers/server_types.js index 7a3665a7931..e5f9b648c25 100644 --- a/jstests/concurrency/fsm_workload_helpers/server_types.js +++ b/jstests/concurrency/fsm_workload_helpers/server_types.js @@ -20,11 +20,11 @@ function isMongod(db) { } /** - * Returns true if the current storage engine is mmapv1, - * and false otherwise. + * Returns the name of the current storage engine. * + * Throws an error if db is connected to a mongos, or if there is no reported storage engine. */ -function isMMAPv1(db) { +function getStorageEngineName(db) { var status = db.serverStatus(); assert.commandWorked(status); @@ -33,22 +33,27 @@ function isMMAPv1(db) { assert.neq('undefined', typeof status.storageEngine, 'missing storage engine info in server status'); - return status.storageEngine.name === 'mmapv1'; + return status.storageEngine.name; } /** - * Returns true if the current storage engine is wiredTiger - * and false otherwise. - * + * Returns true if the current storage engine is mmapv1, and false otherwise. */ -function isWiredTiger(db) { - var status = db.serverStatus(); - assert.commandWorked(status); +function isMMAPv1(db) { + return getStorageEngineName(db) === 'mmapv1'; +} - assert(isMongod(db), - 'no storage engine is reported when connected to mongos'); - assert.neq('undefined', typeof status.storageEngine, - 'missing storage engine info in server status'); +/** + * Returns true if the current storage engine is wiredTiger, and false otherwise. + */ +function isWiredTiger(db) { + return getStorageEngineName(db) === 'wiredTiger'; +} - return status.storageEngine.name === 'wiredTiger'; +/** + * Returns true if the current storage engine is ephemeral, and false otherwise. + */ +function isEphemeral(db) { + var engine = getStorageEngineName(db); + return (engine === 'inMemory') || (engine === 'ephemeralForTest'); } diff --git a/jstests/concurrency/fsm_workloads/compact.js b/jstests/concurrency/fsm_workloads/compact.js index f7488c5143f..855cd6e73fa 100644 --- a/jstests/concurrency/fsm_workloads/compact.js +++ b/jstests/concurrency/fsm_workloads/compact.js @@ -9,6 +9,7 @@ */ load('jstests/concurrency/fsm_workload_helpers/drop_utils.js'); // for dropCollections +load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isEphemeral var $config = (function() { var data = { @@ -61,7 +62,11 @@ var $config = (function() { paddingFactor: 1.0, force: true }); - assertAlways.commandWorked(res); + if (!isEphemeral(db)) { + assertAlways.commandWorked(res); + } else { + assertAlways.commandFailedWithCode(res, ErrorCodes.CommandNotSupported); + } } function query(db, collName) { diff --git a/jstests/concurrency/fsm_workloads/compact_simultaneous_padding_bytes.js b/jstests/concurrency/fsm_workloads/compact_simultaneous_padding_bytes.js index 1328fdf5382..dc8d9881f69 100644 --- a/jstests/concurrency/fsm_workloads/compact_simultaneous_padding_bytes.js +++ b/jstests/concurrency/fsm_workloads/compact_simultaneous_padding_bytes.js @@ -10,6 +10,7 @@ load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWorkload load('jstests/concurrency/fsm_workloads/compact.js'); // for $config +load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isEphemeral var $config = extendWorkload($config, function($config, $super) { $config.states.init = function init(db, collName) { @@ -22,7 +23,11 @@ var $config = extendWorkload($config, function($config, $super) { paddingBytes: 1024 * 5, force: true }); - assertAlways.commandWorked(res); + if (!isEphemeral(db)) { + assertAlways.commandWorked(res); + } else { + assertAlways.commandFailedWithCode(res, ErrorCodes.CommandNotSupported); + } }; // no-op the query state because querying while compacting can result in closed cursors |