summaryrefslogtreecommitdiff
path: root/jstests/readonly
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2022-04-22 19:42:03 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-22 20:12:32 +0000
commit90d6271d2f663a4aaf633de5e362972e50e90c21 (patch)
treed24da0cee090d7d92972fa8f43fa4f0eb41ac915 /jstests/readonly
parent983a7174c6d792049ef0f54e36a55f93801df89c (diff)
downloadmongo-90d6271d2f663a4aaf633de5e362972e50e90c21.tar.gz
SERVER-60761 Move the global read-only flag to be an OperationContext function
Diffstat (limited to 'jstests/readonly')
-rw-r--r--jstests/readonly/temp_collection.js47
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);
}
};
})());