summaryrefslogtreecommitdiff
path: root/jstests/libs/wait_for_command.js
blob: c9ce829d5933426cc02e01344dd6f218a2376ff9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const waitForCommand = function(waitingFor, opFilter, myDB) {
    let opId = -1;
    assert.soon(function() {
        print(`Checking for ${waitingFor}`);
        const curopRes = myDB.currentOp();
        assert.commandWorked(curopRes);
        const foundOp = curopRes["inprog"].filter(opFilter);

        if (foundOp.length == 1) {
            opId = foundOp[0]["opid"];
        }
        return (foundOp.length == 1);
    });
    return opId;
};