jstests/noPassthrough/server_write_concern_metrics.js
// expect, and no other changes occurred. This function modifies its inputs.
expect, and no other changes occurred. This function modifies its inputs.
expect and no other changes occurred . This function modifies its inputs .
function verifyServerStatusChange(initialStats, newStats, paths, expectedIncrement) {
    paths.forEach(path => {
        let pathComponents = path.split(".");
        let initialParent = initialStats;
        let newParent = newStats;
        for (let i = 0; i < pathComponents.length - 1; i++) {
            assert(initialParent.hasOwnProperty(pathComponents[i]),
                   "initialStats did not contain component " + i + " of path " + path +
                       ", initialStats: " + tojson(initialStats));
            initialParent = initialParent[pathComponents[i]];
            assert(newParent.hasOwnProperty(pathComponents[i]),
                   "newStats did not contain component " + i + " of path " + path +
                       ", newStats: " + tojson(newStats));
            newParent = newParent[pathComponents[i]];
        }
        let lastPathComponent = pathComponents[pathComponents.length - 1];
        let initialValue = 0;
        if (initialParent.hasOwnProperty(lastPathComponent)) {
            initialValue = initialParent[lastPathComponent];
        }
        assert(newParent.hasOwnProperty(lastPathComponent),
               "newStats did not contain last component of path " + path +
                   ", newStats: " + tojson(newStats));
        assert.eq(initialValue + expectedIncrement,
                  newParent[lastPathComponent],
                  "expected " + path + " to increase by " + expectedIncrement + ", initialStats: " +
                      tojson(initialStats) + ", newStats: " + tojson(newStats));
        delete initialParent[lastPathComponent];
        delete newParent[lastPathComponent];
    });
    assert.eq(0,
              bsonWoCompare(initialStats, newStats),
              "expected initialStats and newStats to be equal after removing " + tojson(paths) +
                  ", initialStats: " + tojson(initialStats) + ", newStats: " + tojson(newStats));
}
function verifyServerStatusChange ( initialStats , newStats , paths , expectedIncrement ) { paths . forEach ( path => { let pathComponents = path . split ( "." ) ; let initialParent = initialStats ; let newParent = newStats ; for ( let i = 0 ; i < pathComponents . length - 1 ; i ++ ) { assert ( initialParent . hasOwnProperty ( pathComponents [ i ] ) , "initialStats did not contain component " + i + " of path " + path + ", initialStats: " + tojson ( initialStats ) ) ; initialParent = initialParent [ pathComponents [ i ] ] ; assert ( newParent . hasOwnProperty ( pathComponents [ i ] ) , "newStats did not contain component " + i + " of path " + path + ", newStats: " + tojson ( newStats ) ) ; newParent = newParent [ pathComponents [ i ] ] ; } let lastPathComponent = pathComponents [ pathComponents . length - 1 ] ; let initialValue = 0 ; if ( initialParent . hasOwnProperty ( lastPathComponent ) ) { initialValue = initialParent [ lastPathComponent ] ; } assert ( newParent . hasOwnProperty ( lastPathComponent ) , "newStats did not contain last component of path " + path + ", newStats: " + tojson ( newStats ) ) ; assert . eq ( initialValue + expectedIncrement , newParent [ lastPathComponent ] , "expected " + path + " to increase by " + expectedIncrement + ", initialStats: " + tojson ( initialStats ) + ", newStats: " + tojson ( newStats ) ) ; delete initialParent [ lastPathComponent ] ; delete newParent [ lastPathComponent ] ; } ) ; assert . eq ( 0 , bsonWoCompare ( initialStats , newStats ) , "expected initialStats and newStats to be equal after removing " + tojson ( paths ) + ", initialStats: " + tojson ( initialStats ) + ", newStats: " + tojson ( newStats ) ) ; }
expect, and no other changes occurred.
expect and no other changes occurred .
// Traverse to the parent of the changed element. // Test the expected increment of the changed element. The element may not exist in the // initial stats, in which case it is treated as 0. // Delete the changed element. // The stats objects should be equal without the changed element.