From def884b5dabc692ceb11e878f4b4ce28335f4804 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Sun, 28 Aug 2022 08:32:16 -0400 Subject: SERVER-64659 add initial sync test case for indexBulkBuilder server status section (cherry picked from commit 4adfa1a54c9cba165525caf4a4200a891945637c) --- .../noPassthrough/serverstatus_indexbulkbuilder.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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(); })(); -- cgit v1.2.1