(function() {
|
'use strict';
|
|
const numberOfCollections = 5000;
|
|
// Configure initial sharding cluster
|
const st = new ShardingTest({shards: 3});
|
const mongos = st.s;
|
const dbName = "test";
|
const db = mongos.getDB(dbName);
|
|
let iterator = 1000;
|
let total = 0;
|
while (total < numberOfCollections) {
|
// Insert data to validate the aggregation stage
|
for (let i = 0; i < iterator; i++) {
|
const coll = "coll" + total;
|
// assert.commandWorked(db.createCollection(coll));
|
assert(st.adminCommand({shardcollection: dbName + "." + coll, key: {skey: 1}}));
|
total++;
|
}
|
|
let it = 0;
|
const start = new Date();
|
const cursor = mongos.getDB("admin").aggregate([{$shardedDataDistribution: {}}]);
|
while (cursor.hasNext()) {
|
const data = cursor.next();
|
it++;
|
}
|
const end = new Date();
|
|
const time = new Date(end - start).toISOString().slice(11, 19);
|
print(`performance test $shardedDataDistribution: ` + total + ` ` + time);
|
|
assert.eq(it, total + 1);
|
}
|
|
st.stop();
|
})();
|