diff options
-rw-r--r-- | jstests/noPassthrough/serverstatus_indexbulkbuilder.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js index a7b6bdbec3f..98d38c88bd5 100644 --- a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js +++ b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js @@ -10,6 +10,8 @@ (function() { 'use strict'; +load('jstests/noPassthrough/libs/index_build.js'); + const replSet = new ReplSetTest({ nodes: 1, nodeOptions: {setParameter: {maxIndexBuildMemoryUsageMegabytes: 50}}, @@ -39,5 +41,22 @@ assert.eq(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.filesOpenedForExternalSort, 1, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 1, tojson(indexBulkBuilderSection)); +// Confirm that metrics are updated during initial sync. +const newNode = replSet.add({setParameter: {maxIndexBuildMemoryUsageMegabytes: 50}}); +replSet.reInitiate(); +replSet.waitForState(newNode, ReplSetTest.State.SECONDARY); +replSet.awaitReplication(); +let newNodeTestDB = newNode.getDB(testDB.getName()); +let newNodeColl = newNodeTestDB.getCollection(coll.getName()); +IndexBuildTest.assertIndexes(newNodeColl, 2, ['_id_', 'a_1']); +indexBulkBuilderSection = newNodeTestDB.serverStatus().indexBulkBuilder; +// We expect initial sync to build at least three indexes for the test collection in addition +// to indexes for internal collections required for the proper running of the server. +// The test collection has the only index that will cause the external sorter to spill to disk, +// so the file descriptor open/closed counters should each report a value of one. +assert.gte(indexBulkBuilderSection.count, 3, tojson(indexBulkBuilderSection)); +assert.eq(indexBulkBuilderSection.filesOpenedForExternalSort, 1, tojson(indexBulkBuilderSection)); +assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 1, tojson(indexBulkBuilderSection)); + replSet.stopSet(); })(); |