forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogprocessdetails.js
48 lines (41 loc) · 1.4 KB
/
logprocessdetails.js
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
/**
* SERVER-7140 test. Checks that process info is re-logged on log rotation
* @tags: [
* # The test runs commands that are not allowed with security token: getLog, logRotate.
* not_allowed_with_signed_security_token,
* assumes_superuser_permissions,
* does_not_support_stepdowns,
* no_selinux,
* # This test searches for a MongoRPC-specific log string (*conn).
* grpc_incompatible,
* ]
*/
/**
* Checks an array for match against regex.
* Returns true if regex matches a string in the array
*/
let doesLogMatchRegex = function(logArray, regex) {
for (var i = (logArray.length - 1); i >= 0; i--) {
var regexInLine = regex.exec(logArray[i]);
if (regexInLine != null) {
return true;
}
}
return false;
};
let doTest = function() {
var log = db.adminCommand({getLog: 'global'});
// this regex will need to change if output changes
var re = new RegExp(".*conn.*options.*");
assert.neq(null, log);
var lineCount = log.totalLinesWritten;
assert.neq(0, lineCount);
var result = db.adminCommand({logRotate: 1});
assert.eq(1, result.ok);
var log2 = db.adminCommand({getLog: 'global'});
assert.neq(null, log2);
assert.gte(log2.totalLinesWritten, lineCount);
var informationIsLogged = doesLogMatchRegex(log2.log, re);
assert.eq(informationIsLogged, true, "Process details not present in RAM log");
};
doTest();