blob: 5d4e002fb926a8d8df2d58ba738e3a295e17aa34 (
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
|
// mongotop_common.js; contains variables used by mongotop tests
/* exported executeProgram */
/* exported extractJSON */
load('jstests/common/topology_helper.js');
load('jstests/libs/extended_assert.js');
var executeProgram = function(args) {
clearRawMongoProgramOutput();
var pid = startMongoProgramNoConnect.apply(this, args);
var exitCode = waitProgram(pid);
var prefix = 'sh'+pid+'| ';
var getOutput = function() {
return rawMongoProgramOutput().split('\n').filter(function(line) {
return line.indexOf(prefix) === 0;
}).join('\n');
};
return {
exitCode: exitCode,
getOutput: getOutput,
};
};
var extractJSON = function(shellOutput) {
return shellOutput.substring(shellOutput.indexOf('{'), shellOutput.lastIndexOf('}') + 1);
};
|