blob: 498e05560202394bc2d8e65dfb882cd962d7d925 (
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
|
// Tests the _runningMongoChildProcessIds shell built-in.
(function() {
'use strict';
/**
* @param {NumberLong[]} expected pids
*/
function assertRunningMongoChildProcessIds(expected) {
const expectedSorted = expected.sort();
const children = MongoRunner.runningChildPids().sort();
assert.eq(expectedSorted, children);
}
// Empty before we start anything.
assertRunningMongoChildProcessIds([]);
(function() {
// Start 1 mongod.
const mongod = MongoRunner.runMongod({});
try {
// Call 3 times just for good-measure.
assertRunningMongoChildProcessIds([mongod.pid]);
assertRunningMongoChildProcessIds([mongod.pid]);
assertRunningMongoChildProcessIds([mongod.pid]);
} finally {
MongoRunner.stopMongod(mongod);
}
})();
(function() {
// Start 2 mongods.
const mongod1 = MongoRunner.runMongod({});
const mongod2 = MongoRunner.runMongod({});
try {
assertRunningMongoChildProcessIds([mongod1.pid, mongod2.pid]);
// Stop mongod1 and only mongod2 should remain.
MongoRunner.stopMongod(mongod1);
assertRunningMongoChildProcessIds([mongod2.pid]);
} finally {
// It is safe to stop multiple times.
MongoRunner.stopMongos(mongod2);
MongoRunner.stopMongos(mongod1);
}
})();
// empty at the end
assertRunningMongoChildProcessIds([]);
})();
|