summaryrefslogtreecommitdiff
path: root/jstests/sharding/store_historical_placement_data.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/store_historical_placement_data.js')
-rw-r--r--jstests/sharding/store_historical_placement_data.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/jstests/sharding/store_historical_placement_data.js b/jstests/sharding/store_historical_placement_data.js
new file mode 100644
index 00000000000..65a02f70f2a
--- /dev/null
+++ b/jstests/sharding/store_historical_placement_data.js
@@ -0,0 +1,39 @@
+/*
+ * The test verifies that each Sharding DDL operation that gets successfully completed
+ * also produces a document detailing the changes to the placement of the targeted nss.
+ *
+ *
+ */
+(function() {
+"use strict";
+load("jstests/libs/feature_flag_util.js");
+
+const st = new ShardingTest({shards: 2});
+// TODO SERVER-69106 remove the logic to skip the test execution
+const historicalPlacementDataFeatureFlag = FeatureFlagUtil.isEnabled(
+ st.configRS.getPrimary().getDB('admin'), "HistoricalPlacementShardingCatalog");
+if (!historicalPlacementDataFeatureFlag) {
+ jsTestLog("Skipping as featureFlagHistoricalPlacementShardingCatalog is disabled");
+ st.stop();
+ return;
+}
+
+const dbName = 'test';
+const configDB = st.s.getDB('config');
+
+jsTest.log('Verifying placement data generated by createDatabase()');
+assert.commandWorked(
+ st.s.adminCommand({enableSharding: dbName, primaryShard: st.shard0.shardName}));
+
+const placementHistoryEntries = configDB.placementHistory.find().toArray();
+assert.eq(placementHistoryEntries.length, 1);
+const placementDetails = placementHistoryEntries[0];
+const databaseEntries = configDB.databases.find({_id: placementDetails.nss}).toArray();
+assert.eq(1, databaseEntries.length);
+const databaseDetails = databaseEntries[0];
+assert(timestampCmp(databaseDetails.version.timestamp, placementDetails.timestamp) == 0);
+assert.eq(1, placementDetails.shards.length);
+assert.eq(databaseDetails.primary, placementDetails.shards[0]);
+
+st.stop();
+}());