0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00
mongodb/jstests/sharding/hash_single_shard.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

25 lines
984 B
JavaScript

// Test hashed presplit with 1 shard.
import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {findChunksUtil} from "jstests/sharding/libs/find_chunks_util.js";
var st = new ShardingTest({shards: 1});
var testDB = st.getDB('test');
// create hashed shard key and enable sharding
testDB.adminCommand({enablesharding: "test"});
testDB.adminCommand({shardCollection: "test.collection", key: {a: "hashed"}});
let expectedChunkCount = 1;
// TODO SERVER-81884: update once 8.0 becomes last LTS.
if (!FeatureFlagUtil.isPresentAndEnabled(testDB,
"OneChunkPerShardEmptyCollectionWithHashedShardKey")) {
expectedChunkCount = 2;
}
// check the number of initial chunks.
assert.eq(expectedChunkCount,
findChunksUtil.countChunksForNs(st.getDB('config'), "test.collection"),
'Using hashed shard key but failing to do correct presplitting');
st.stop();