summaryrefslogtreecommitdiff
path: root/jstests/readonly
diff options
context:
space:
mode:
authorRobert Guo <robertguo@me.com>2016-07-11 18:21:56 -0400
committerRobert Guo <robertguo@me.com>2016-07-14 15:59:36 -0400
commit9730e49b06fc9902bf80207c889b919b157b8f35 (patch)
treeb4e9e8848849f15c6e6df7bfe0e52e46286931aa /jstests/readonly
parent132de7f6e3270321fbbd072c06b05691cbb8baa8 (diff)
downloadmongo-9730e49b06fc9902bf80207c889b919b157b8f35.tar.gz
SERVER-24726 readonly mode should ignore temp collections
Diffstat (limited to 'jstests/readonly')
-rw-r--r--jstests/readonly/temp_collection.js37
1 files changed, 37 insertions, 0 deletions
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');
+ }
+ };
+})());