summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/serverstatus_indexbulkbuilder.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js
index d42ae64db58..a2d41ab4f2f 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,27 @@ assert.eq(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection));
assert.eq(indexBulkBuilderSection.filesOpenedForExternalSort, 4, tojson(indexBulkBuilderSection));
assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 4, 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;
+jsTestLog('initial sync server status: ' + tojson(indexBulkBuilderSection));
+// 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 comparable to that for
+// a single index build that spills to disk.
+// Also, 4.2 does not contain the external sorter improvements in SERVER-54761, so the numbers
+// reported in the server status for file handle activity will be a little different from those
+// for similar index builds in 4.4.
+assert.gte(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection));
+assert.gte(indexBulkBuilderSection.filesOpenedForExternalSort, 4, tojson(indexBulkBuilderSection));
+assert.gte(indexBulkBuilderSection.filesClosedForExternalSort, 4, tojson(indexBulkBuilderSection));
+
replSet.stopSet();
})();