diff options
Diffstat (limited to 'jstests/readonly')
-rw-r--r-- | jstests/readonly/temp_collection.js | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/jstests/readonly/temp_collection.js b/jstests/readonly/temp_collection.js index 35ae73dc2a5..3e0eff6ac7f 100644 --- a/jstests/readonly/temp_collection.js +++ b/jstests/readonly/temp_collection.js @@ -1,7 +1,9 @@ -// Tests that the server is able to restart in read-only mode with data files that contain one or -// more temporary collections. See SERVER-24719 for details. -// @tags: [requires_replication] - +/** + * Tests that the server is able to restart in read-only mode with data files that contain one or + * more temporary collections. The temporary collection will be dropped during startup recovery. + * + * @tags: [requires_replication] + */ 'use strict'; load('jstests/readonly/lib/read_only_test.js'); @@ -9,19 +11,17 @@ runReadOnlyTest((function() { return { name: 'temp_collection', - load: function(writableCollection) { - var collName = writableCollection.getName(); - var writableDB = writableCollection.getDB(); - writableDB[collName].drop(); + load: function(collection) { + let collName = collection.getName(); + let db = collection.getDB(); + db[collName].drop(); - assert.commandWorked(writableDB.runCommand({ - applyOps: [ - {op: "c", ns: writableDB.getName() + ".$cmd", o: {create: collName, temp: true}} - ] + assert.commandWorked(db.runCommand({ + applyOps: [{op: "c", ns: db.getName() + ".$cmd", o: {create: collName, temp: true}}] })); - var collectionInfos = writableDB.getCollectionInfos(); - var collectionExists = false; + let collectionInfos = db.getCollectionInfos(); + let collectionExists = false; collectionInfos.forEach(info => { if (info.name === collName) { assert(info.options.temp, @@ -31,12 +31,23 @@ runReadOnlyTest((function() { } }); assert(collectionExists, 'Can not find collection in collectionInfos'); - assert.commandWorked(writableCollection.insert({a: 1})); + assert.commandWorked(collection.insert({a: 1})); }, - exec: function(readableCollection) { - assert.eq( - readableCollection.count(), 1, 'There should be 1 document in the temp collection'); + exec: function(collection) { + // Temporary collections are dropped during startup recovery. + let collName = collection.getName(); + let db = collection.getDB(); + + let collectionInfos = db.getCollectionInfos(); + let collectionExists = false; + collectionInfos.forEach(info => { + if (info.name === collName) { + collectionExists = true; + } + }); + + assert(!collectionExists); } }; })()); |