mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
771dabd098
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
//
|
|
// Tests that the changelog entry for moveChunk.commit contains stats on the migration.
|
|
//
|
|
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
import {findChunksUtil} from "jstests/sharding/libs/find_chunks_util.js";
|
|
|
|
var st = new ShardingTest({mongos: 1, shards: 2});
|
|
var kDbName = 'db';
|
|
|
|
var mongos = st.s0;
|
|
var shard0 = st.shard0.shardName;
|
|
var shard1 = st.shard1.shardName;
|
|
|
|
assert.commandWorked(mongos.adminCommand({enableSharding: kDbName, primaryShard: shard0}));
|
|
|
|
function assertCountsInChangelog() {
|
|
let changeLog = st.s.getDB('config').changelog.find({what: 'moveChunk.commit'}).toArray();
|
|
assert.gt(changeLog.length, 0);
|
|
for (let i = 0; i < changeLog.length; i++) {
|
|
assert(changeLog[i].details.hasOwnProperty('counts'));
|
|
}
|
|
}
|
|
|
|
var ns = kDbName + '.fooHashed';
|
|
assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {_id: 'hashed'}}));
|
|
|
|
var aChunk = findChunksUtil.findOneChunkByNs(mongos.getDB('config'), ns, {shard: shard0});
|
|
assert(aChunk);
|
|
|
|
// Assert counts field exists in the changelog entry for moveChunk.commit
|
|
assert.commandWorked(
|
|
mongos.adminCommand({moveChunk: ns, bounds: [aChunk.min, aChunk.max], to: shard1}));
|
|
assertCountsInChangelog();
|
|
|
|
mongos.getDB(kDbName).fooHashed.drop();
|
|
|
|
st.stop(); |