Skip to content

Commit 63a7b05

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 63a7b05

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

TestResultSummaryService/DataManager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class DataManager {
2222
}
2323

2424
async parseOutput(buildName, output) {
25+
logger.verbose('parseOutput');
2526
const parserTypes = await Promise.all(
2627
Object.keys(Parsers).map(async (type) => {
2728
if (Parsers[type].canParse(buildName, output)) {
@@ -37,6 +38,7 @@ class DataManager {
3738
const parser = new DefaultParser();
3839
results = await parser.parse(output);
3940
}
41+
logger.verbose('parseOutput done');
4042
return Object.assign.apply({}, results);
4143
}
4244

@@ -219,7 +221,8 @@ class DataManager {
219221
update.buildOutputId = buildOutputId;
220222
update.hasChildren = false;
221223
}
222-
const result = await testResults.update(criteria, { $set: update });
224+
await testResults.update(criteria, { $set: update });
225+
logger.verbose('updateBuildWithOutput done');
223226
}
224227

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

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: 4 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

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)