summaryrefslogtreecommitdiff
path: root/jstests/sharding/store_historical_placement_data.js
blob: 844d46cf54ed25a49d866b784d9836a7e140eb92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * 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]);
assert.eq(undefined, placementDetails.uuid);

st.stop();
}());