From 9730e49b06fc9902bf80207c889b919b157b8f35 Mon Sep 17 00:00:00 2001 From: Robert Guo Date: Mon, 11 Jul 2016 18:21:56 -0400 Subject: SERVER-24726 readonly mode should ignore temp collections --- jstests/readonly/temp_collection.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 jstests/readonly/temp_collection.js (limited to 'jstests/readonly') diff --git a/jstests/readonly/temp_collection.js b/jstests/readonly/temp_collection.js new file mode 100644 index 00000000000..9c24b5ed4ef --- /dev/null +++ b/jstests/readonly/temp_collection.js @@ -0,0 +1,37 @@ +// 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. + +'use strict'; +load('jstests/readonly/lib/read_only_test.js'); + +runReadOnlyTest((function() { + return { + name: 'temp_collection', + + load: function(writableCollection) { + var collName = writableCollection.getName(); + var writableDB = writableCollection.getDB(); + writableDB[collName].drop(); + + assert.commandWorked(writableDB.createCollection(collName, {temp: true})); + + var collectionInfos = writableDB.getCollectionInfos(); + var collectionExists = false; + collectionInfos.forEach(info => { + if (info.name === collName) { + assert(info.options.temp, + 'The collection is not marked as a temporary one\n' + + tojson(collectionInfos)); + collectionExists = true; + } + }); + assert(collectionExists, 'Can not find collection in collectionInfos'); + assert.writeOK(writableCollection.insert({a: 1})); + }, + + exec: function(readableCollection) { + assert.eq( + readableCollection.count(), 1, 'There should be 1 document in the temp collection'); + } + }; +})()); -- cgit v1.2.1