blob: b2b80379bce4ba3c8f9e92b3f91f51468240c1cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* Verifies that the 'dataThroughputLastSecond' and 'dataThroughputAverage' fields appear in the
* currentOp output while running validation.
*
* ephemeralForTest does not support background validation, which is needed to report the
* 'dataThroughputLastSecond' and 'dataThroughputAverage' fields in currentOp.
*
* @tags: [incompatible_with_eft]
*/
(function() {
const dbName = "test";
const collName = "currentOpValidation";
const conn = MongoRunner.runMongod();
let db = conn.getDB(dbName);
let coll = db.getCollection(collName);
coll.drop();
assert.commandWorked(coll.createIndex({a: 1}));
for (let i = 0; i < 5; i++) {
assert.commandWorked(coll.insert({a: i}));
}
// The throttle is off by default.
assert.commandWorked(db.adminCommand({setParameter: 1, maxValidateMBperSec: 1}));
// Simulate each record being 512KB.
assert.commandWorked(db.adminCommand(
{configureFailPoint: "fixedCursorDataSizeOf512KBForDataThrottle", mode: "alwaysOn"}));
// This fail point comes after we've traversed the record store, so currentOp should have some
// validation statistics once we hit this fail point.
assert.commandWorked(
db.adminCommand({configureFailPoint: "pauseCollectionValidationWithLock", mode: "alwaysOn"}));
TestData.dbName = dbName;
TestData.collName = collName;
const awaitValidation = startParallelShell(() => {
assert.commandWorked(
db.getSiblingDB(TestData.dbName).getCollection(TestData.collName).validate({
background: true
}));
}, conn.port);
checkLog.containsJson(conn, 20304);
const curOpFilter = {
'command.validate': collName
};
let curOp = assert.commandWorked(db.currentOp(curOpFilter));
assert(curOp.inprog.length == 1);
assert(curOp.inprog[0].hasOwnProperty("dataThroughputLastSecond") &&
curOp.inprog[0].hasOwnProperty("dataThroughputAverage"));
curOp = conn.getDB("admin").aggregate([{$currentOp: {}}, {$match: curOpFilter}]).toArray();
assert(curOp.length == 1);
assert(curOp[0].hasOwnProperty("dataThroughputLastSecond") &&
curOp[0].hasOwnProperty("dataThroughputAverage"));
// Finish up validating the collection.
assert.commandWorked(db.adminCommand(
{configureFailPoint: "fixedCursorDataSizeOf512KBForDataThrottle", mode: "off"}));
assert.commandWorked(
db.adminCommand({configureFailPoint: "pauseCollectionValidationWithLock", mode: "off"}));
// Setting this to 0 turns off the throttle.
assert.commandWorked(db.adminCommand({setParameter: 1, maxValidateMBperSec: 0}));
awaitValidation();
MongoRunner.stopMongod(conn);
}());
|