blob: 92d84b4ee3736cfa8476f9c07587b06bf266f7dc (
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
|
/**
* Tests that maxTimeMS is respected even in an inner $unionWith pipeline.
*/
(function() {
"use strict";
const testDB = db.getSiblingDB(jsTestName());
const collA = testDB.A;
collA.drop();
const collB = testDB.B;
collB.drop();
for (let i = 0; i < 10; i++) {
assert.commandWorked(collA.insert({val: i}));
assert.commandWorked(collB.insert({val: i * 2}));
}
function sleepAndIncrement(val) {
sleep(2000);
return val + 1;
}
assert.commandFailedWithCode(testDB.runCommand({
aggregate: collA.getName(),
pipeline: [{
$unionWith: {
coll: collB.getName(),
pipeline: [{
$project:
{newVal: {$function: {args: ["$val"], body: sleepAndIncrement, lang: "js"}}}
}]
}
}],
cursor: {},
maxTimeMS: 3 * 1000
}),
ErrorCodes.MaxTimeMSExpired);
})();
|