summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js')
-rw-r--r--jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js b/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js
new file mode 100644
index 00000000000..5ec13841a8e
--- /dev/null
+++ b/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js
@@ -0,0 +1,43 @@
+/**
+ * Tests that oplog views for resharding and tenant migration are created when a replica set is
+ * upgraded from 4.4.
+ */
+(function() {
+"use strict";
+load("jstests/multiVersion/libs/multi_rs.js"); // For 'upgradeSet()'
+
+const kReshardingOplogViewName = "system.resharding.slimOplogForGraphLookup";
+const kTenantMigrationOplogViewName = "system.tenantMigration.oplogView";
+
+function assertOplogViewsNotExist(node) {
+ const localDb = node.getDB("local");
+ const reshardingViewRes = localDb.runCommand(
+ {listCollections: 1, filter: {type: "view", name: kReshardingOplogViewName}});
+ assert.eq(0, reshardingViewRes.cursor.firstBatch.length);
+ const tenantMigrationRes = localDb.runCommand(
+ {listCollections: 1, filter: {type: "view", name: kTenantMigrationOplogViewName}});
+ assert.eq(0, tenantMigrationRes.cursor.firstBatch.length);
+}
+
+function assertOplogViewsExist(node) {
+ const localDb = node.getDB("local");
+ const reshardingViewRes = localDb.runCommand(
+ {listCollections: 1, filter: {type: "view", name: kReshardingOplogViewName}});
+ assert.eq(1, reshardingViewRes.cursor.firstBatch.length);
+ const tenantMigrationRes = localDb.runCommand(
+ {listCollections: 1, filter: {type: "view", name: kTenantMigrationOplogViewName}});
+ assert.eq(1, tenantMigrationRes.cursor.firstBatch.length);
+}
+
+// Set up a replica set in v4.4.
+const rst = new ReplSetTest({nodes: 2, nodeOptions: {binVersion: "last-lts"}});
+rst.startSet();
+rst.initiate();
+rst.nodes.forEach(node => assertOplogViewsNotExist(node));
+
+// Upgrade the replica set.
+rst.upgradeSet({binVersion: "latest"});
+rst.nodes.forEach(node => assertOplogViewsExist(node));
+
+rst.stopSet();
+})(); \ No newline at end of file