summaryrefslogtreecommitdiff
path: root/jstests/multiVersion
diff options
context:
space:
mode:
authorYuhong Zhang <34732434+YuhongZhang98@users.noreply.github.com>2022-02-25 14:55:33 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-25 16:22:49 +0000
commitd6367f3a32a3d5e2c88762992a03da3a691aeb51 (patch)
treeb1bb96a4a16c3a276e29fd69ba8ff215332747bf /jstests/multiVersion
parent586663fec7c3a7d4a8b0185ff24825bd15e80dff (diff)
downloadmongo-d6367f3a32a3d5e2c88762992a03da3a691aeb51.tar.gz
SERVER-63876 Add multiversion test to make sure collMod ttl works on 5.0 secondaries
Diffstat (limited to 'jstests/multiVersion')
-rw-r--r--jstests/multiVersion/targetedTestsLastLtsFeatures/mixed_replica_set_collmod_ttl.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/mixed_replica_set_collmod_ttl.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/mixed_replica_set_collmod_ttl.js
new file mode 100644
index 00000000000..e5dd908b4db
--- /dev/null
+++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/mixed_replica_set_collmod_ttl.js
@@ -0,0 +1,50 @@
+/**
+ * Tests that a last-lts secondary can apply collMod convert to ttl.
+ */
+
+(function() {
+"use strict";
+load('./jstests/multiVersion/libs/multi_rs.js');
+
+const lastLTSVersion = "last-lts";
+const latestVersion = "latest";
+
+const nodes = {
+ 0: {binVersion: latestVersion},
+ 1: {binVersion: lastLTSVersion},
+ 2: {binVersion: lastLTSVersion}
+};
+
+const rst = new ReplSetTest({nodes: nodes});
+
+rst.startSet();
+rst.initiate();
+
+const primary = rst.getPrimary();
+const testDB = primary.getDB('test');
+const collName = 'mixed_replica_set_collmod_ttl';
+const coll = testDB.getCollection(collName);
+coll.drop();
+
+function findTTL(coll, key, expireAfterSeconds) {
+ let all = coll.getIndexes();
+ all = all.filter(function(z) {
+ return z.expireAfterSeconds == expireAfterSeconds && friendlyEqual(z.key, key);
+ });
+ return all.length == 1;
+}
+
+assert.commandWorked(coll.createIndex({a: 1}));
+assert.commandWorked(testDB.runCommand({
+ collMod: collName,
+ index: {keyPattern: {a: 1}, expireAfterSeconds: 100},
+ writeConcern: {w: 3}
+}));
+
+for (let i = 0; i < rst.nodes.length; i++) {
+ const coll = rst.nodes[i].getDB(testDB.getName()).getCollection(collName);
+ assert(findTTL(coll, {a: 1}, 100), "TTL index should be 100 now");
+}
+
+rst.stopSet();
+})();