Skip to content

Commit e7e54a5

Browse files
committed
Improve regex in TRSS to handle long CSV output
Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
1 parent 10f7312 commit e7e54a5

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

TestResultSummaryService/DataManager.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ class DataManager {
2222
}
2323

2424
async parseOutput(buildName, output) {
25+
logger.verbose('parseOutput 0');
2526
const parserTypes = await Promise.all(
2627
Object.keys(Parsers).map(async (type) => {
28+
logger.verbose('parseOutput type', type);
2729
if (Parsers[type].canParse(buildName, output)) {
2830
const parser = new Parsers[type](buildName);
31+
logger.verbose('parseOutput parser', parser);
2932
return await parser.parse(output, buildName);
3033
}
3134
})
3235
);
36+
logger.verbose('parseOutput 1');
3337
let results = parserTypes.filter((element) => {
3438
return element !== undefined;
3539
});
3640
if (results.length === 0) {
3741
const parser = new DefaultParser();
3842
results = await parser.parse(output);
3943
}
44+
logger.verbose('parseOutput 2');
4045
return Object.assign.apply({}, results);
4146
}
4247

@@ -133,6 +138,7 @@ class DataManager {
133138
buildName,
134139
output
135140
);
141+
logger.verbose('updateBuildWithOutput 1');
136142
const testResults = new TestResultsDB();
137143
const outputDB = new OutputDB();
138144
let update = {
@@ -141,6 +147,7 @@ class DataManager {
141147
};
142148
if (!rootBuildId) {
143149
const rootBuildId = await testResults.getRootBuildId(_id);
150+
logger.verbose('updateBuildWithOutput 2');
144151
update.rootBuildId = new ObjectID(rootBuildId);
145152
}
146153
if (builds && builds.length > 0) {
@@ -171,6 +178,7 @@ class DataManager {
171178
});
172179
})
173180
);
181+
logger.verbose('updateBuildWithOutput 3');
174182

175183
const outputData = {
176184
id: data.buildOutputId ? data.buildOutputId : null,
@@ -219,7 +227,8 @@ class DataManager {
219227
update.buildOutputId = buildOutputId;
220228
update.hasChildren = false;
221229
}
222-
const result = await testResults.update(criteria, { $set: update });
230+
await testResults.update(criteria, { $set: update });
231+
logger.verbose('done updateBuildWithOutput');
223232
}
224233

225234
// create build only if the build does not exist in database

TestResultSummaryService/EventHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class EventHandler {
4040
logger.debug(
4141
'EventHandler: processBuild() is waiting for 1 secs before processing the next build'
4242
);
43-
await Promise.delay(1 * 1000);
43+
await Promise.delay(0.5 * 1000);
4444
}
4545
} catch (e) {
4646
logger.error('Exception in database query: ', e);

TestResultSummaryService/JenkinsInfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class JenkinsInfo {
6969
});
7070
const size = await logStream.getSize();
7171
logger.debug(
72-
'JenkinsInfo: getBuildOutput() is waiting for 5 secs after getSize()'
72+
'JenkinsInfo: getBuildOutput() is waiting for 1 secs after getSize()'
7373
);
7474
await Promise.delay(1 * 1000);
7575

TestResultSummaryService/parsers/Parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Parser {
1414
/=JAVA VERSION OUTPUT BEGIN=[\r\n]+([\s\S]*?)[\r\n]+.*=JAVA VERSION OUTPUT END=/;
1515
const javaBuildDateRegex =
1616
/\s([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01])/;
17-
const sdkResourceRegex = /.*?SDK_RESOURCE\=(.*)[\r\n]+/;
17+
const sdkResourceRegex = /SDK_RESOURCE\=(.*)[\r\n]+/;
1818
let curRegexResult = null;
1919
let javaVersion, jdkDate, sdkResource;
2020
if ((curRegexResult = javaVersionRegex.exec(output)) !== null) {
@@ -142,7 +142,7 @@ class Parser {
142142
let disabled = 0;
143143
// An example of test result summary: "TOTAL: 69 EXECUTED: 64 PASSED: 64 FAILED: 0 DISABLED: 0 SKIPPED: 5\n"
144144
const summaryRegex =
145-
/\S*\s*?TOTAL:\s*([0-9]*)\s*EXECUTED:\s*([0-9]*)\s*PASSED:\s*([0-9]*)\s*FAILED:\s*([0-9]*)\s*DISABLED:\s*([0-9]*)\s*SKIPPED:\s*([0-9]*)\s*(\r\n|\r|\n)/;
145+
/TOTAL:\s*([0-9]*)\s*EXECUTED:\s*([0-9]*)\s*PASSED:\s*([0-9]*)\s*FAILED:\s*([0-9]*)\s*DISABLED:\s*([0-9]*)\s*SKIPPED:\s*([0-9]*)\s*(\r\n|\r|\n)/;
146146
if ((m = summaryRegex.exec(output)) !== null) {
147147
total = parseInt(m[1], 10);
148148
executed = parseInt(m[2], 10);

TestResultSummaryService/parsers/Test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const Parser = require('./Parser');
2-
const regexRunningTest = /.*?Running test (.*?) \.\.\.\r?/;
3-
const testSeparator = /.*?===============================================\r?/;
4-
const regexFinishTime = /(.*?) Finish Time\: .* Epoch Time \(ms\)\: (\d+).*/;
5-
const regexStartTime = /(.*?) Start Time\: .* Epoch Time \(ms\)\: (\d+).*/;
2+
const regexRunningTest = /Running test (.*?) \.\.\.\r?/;
3+
const testSeparator = /===============================================\r?/;
4+
const regexFinishTime = /^(.*?) Finish Time\: .* Epoch Time \(ms\)\: (\d+).*/;
5+
const regexStartTime = /^(.*?) Start Time\: .* Epoch Time \(ms\)\: (\d+).*/;
66
const TestBenchmarkParser = require(`./TestBenchmarkParser`);
77
const ExternalTestParser = require(`./ExternalTestParser`);
88

@@ -44,6 +44,7 @@ class Test extends Parser {
4444
}
4545

4646
async extract(str) {
47+
console.log('extract');
4748
const preTest = 'Pre Test';
4849
const postTest = 'Post Test';
4950
let m,
@@ -121,6 +122,7 @@ class Test extends Parser {
121122
? finishTime - startTime
122123
: null,
123124
startTime: parseInt(startTime),
125+
finishTime: parseInt(finishTime),
124126
});
125127
if (testResult == 'FAILED') {
126128
executed++;
@@ -187,13 +189,16 @@ class Test extends Parser {
187189
);
188190
if (isPerf) {
189191
results = TestBenchmarkParser.parsePerf(results);
192+
console.log('TestBenchmarkParser.parsePerf done');
190193
buildResult = Utils.perfBuildResult(results);
194+
console.log('Utils.perfBuildResult done');
191195
}
192196

193197
const isExternal = ExternalTestParser.canParse(this.buildName);
194198
if (isExternal) {
195199
results = new ExternalTestParser().parseExternal(results);
196200
}
201+
console.log('isExternal done');
197202

198203
return {
199204
tests: results,

TestResultSummaryService/parsers/TestBenchmarkParser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ class TestBenchmarkParser extends Parser {
4141
this.getBenchmarkInfo(result.testName);
4242
result.benchmarkName = benchmarkName;
4343
result.benchmarkVariant = benchmarkVariant;
44+
console.log('parsePerf', benchmarkName);
4445
result.testData = Utils.parseOutput(
4546
benchmarkParserKey,
4647
result.testOutput
4748
);
49+
console.log('benchmarkParserKey', benchmarkParserKey);
4850
}
4951
}
5052
}
53+
console.log('parsePerf done');
5154
return results;
5255
}
5356
}

TestResultSummaryService/parsers/Utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class Utils {
3434
// if outerRegex is undefined, all runs should be measured. Parse metrics in every run
3535
// if outerRegex is defined, any runs before outerRegex will be ignored. Parse metrics in warm runs only
3636
if (curBenchVariant.outerRegex !== undefined) {
37+
console.log(
38+
'curBenchVariant.outerRegex',
39+
curBenchVariant.outerRegex
40+
);
3741
if (
3842
(curRegexResult =
3943
curBenchVariant.outerRegex.exec(testOutput)) !== null

0 commit comments

Comments
 (0)