SERVER-117664 Support collection options in ReshardingTest.createShardedCollection (#50351)
GitOrigin-RevId: e3a105c9df884bc43966f43dbf237db8a0730e7e
This commit is contained in:
parent
fefc34b55d
commit
82f724418a
@ -346,13 +346,16 @@ export var ReshardingTest = class {
|
||||
* @param chunks - an array of
|
||||
* {min: <shardKeyValue0>, max: <shardKeyValue1>, shard: <shardName>} objects. The chunks must
|
||||
* form a partition of the {shardKey: MinKey} --> {shardKey: MaxKey} space.
|
||||
* @param shardCollOptions - options that are passed into the shardCollection cmd
|
||||
* @param createCollOPtions - options that are passed into the createCollection cmd before sharding
|
||||
*/
|
||||
createShardedCollection({
|
||||
ns,
|
||||
shardKeyPattern,
|
||||
chunks,
|
||||
primaryShardName = this.donorShardNames[0],
|
||||
collOptions = {},
|
||||
shardCollOptions = {},
|
||||
createCollOptions = {},
|
||||
}) {
|
||||
this._ns = ns;
|
||||
this._currentShardKey = Object.assign({}, shardKeyPattern);
|
||||
@ -369,9 +372,18 @@ export var ReshardingTest = class {
|
||||
);
|
||||
this._primaryShardName = primaryShardName;
|
||||
|
||||
CreateShardedCollectionUtil.shardCollectionWithChunks(sourceCollection, shardKeyPattern, chunks, collOptions);
|
||||
if (Object.keys(createCollOptions).length > 0) {
|
||||
assert.commandWorked(sourceDB.createCollection(sourceCollection.getName(), createCollOptions));
|
||||
}
|
||||
|
||||
const tempCollNamePrefix = this._setupTimeseriesState(sourceDB, sourceCollection.getName(), collOptions);
|
||||
CreateShardedCollectionUtil.shardCollectionWithChunks(
|
||||
sourceCollection,
|
||||
shardKeyPattern,
|
||||
chunks,
|
||||
shardCollOptions,
|
||||
);
|
||||
|
||||
const tempCollNamePrefix = this._setupTimeseriesState(sourceDB, sourceCollection.getName(), shardCollOptions);
|
||||
const sourceCollectionUUIDString = extractUUIDFromObject(this._sourceCollectionUUID);
|
||||
this._tempNs = `${sourceDB.getName()}.${tempCollNamePrefix}.${sourceCollectionUUIDString}`;
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ const collection = reshardingTest.createShardedCollection({
|
||||
ns: ns,
|
||||
shardKeyPattern: {oldKey: 1},
|
||||
chunks: [{min: {oldKey: MinKey}, max: {oldKey: MaxKey}, shard: donorShardNames[0]}],
|
||||
collOptions: {collation: {locale: "simple"}},
|
||||
shardCollOptions: {collation: {locale: "simple"}},
|
||||
});
|
||||
|
||||
const idxSimpleCollationName = "idxSimpleCollation";
|
||||
|
||||
@ -30,7 +30,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -27,7 +27,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -36,7 +36,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -26,7 +26,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -46,7 +46,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {timeseries: timeseriesInfo},
|
||||
shardCollOptions: {timeseries: timeseriesInfo},
|
||||
});
|
||||
const db = coll.getDB();
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ const inputCollection = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": 0}, max: {"meta.x": 100}, shard: donorShardNames[1]},
|
||||
{min: {"meta.x": 100}, max: {"meta.x": MaxKey}, shard: donorShardNames[2]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -29,7 +29,7 @@ const coll = reshardingTest.createShardedCollection({
|
||||
{min: {"meta.x": MinKey}, max: {"meta.x": 0}, shard: donorShardNames[0]},
|
||||
{min: {"meta.x": 0}, max: {"meta.x": MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
collOptions: {
|
||||
shardCollOptions: {
|
||||
timeseries: timeseriesInfo,
|
||||
},
|
||||
});
|
||||
|
||||
@ -21,6 +21,7 @@ const sourceCollection = reshardingTest.createShardedCollection({
|
||||
{min: {oldKey: MinKey}, max: {oldKey: 0}, shard: donorShardNames[0]},
|
||||
{min: {oldKey: 0}, max: {oldKey: MaxKey}, shard: donorShardNames[1]},
|
||||
],
|
||||
createCollOptions: {clusteredIndex: {key: {_id: 1}, unique: true}},
|
||||
});
|
||||
|
||||
// Perform some inserts before resharding starts so there's data to clone.
|
||||
@ -59,4 +60,10 @@ const ops = mongos
|
||||
.toArray();
|
||||
assert.eq(1, ops.length, "failed to find reshardCollection in $currentOp output");
|
||||
|
||||
// Test options parsing
|
||||
const collectionInfos = sourceCollection.getDB().getCollectionInfos({name: sourceCollection.getName()});
|
||||
const collInfo = collectionInfos[0];
|
||||
|
||||
assert(collInfo.options.clusteredIndex, "collection should have a clustered index: " + tojson(collInfo));
|
||||
|
||||
reshardingTest.teardown();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user