Skip to content

Commit

Permalink
Add test summary from TRSS (#930)
Browse files Browse the repository at this point in the history
resolves: #929

Signed-off-by: Lan Xia <[email protected]>
  • Loading branch information
llxia authored Nov 4, 2024
1 parent 7ea2daf commit ab779ad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
6 changes: 4 additions & 2 deletions TestResultSummaryService/parsers/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,18 @@ class Parser {
let disabled = 0;
// An example of test result summary: "TOTAL: 69 EXECUTED: 64 PASSED: 64 FAILED: 0 DISABLED: 0 SKIPPED: 5\n"
const summaryRegex =
/\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)/;
/\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)/;
if ((m = summaryRegex.exec(output)) !== null) {
total = parseInt(m[1], 10);
executed = parseInt(m[2], 10);
passed = parseInt(m[3], 10);
failed = parseInt(m[4], 10);
disabled = parseInt(m[5], 10);
skipped = parseInt(m[6], 10);
const data = 'TKG';
return { total, executed, passed, failed, disabled, skipped, data };
}
return { total, executed, passed, failed, disabled, skipped };
return null;
}

extractStartedBy(output) {
Expand Down
41 changes: 40 additions & 1 deletion TestResultSummaryService/parsers/Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class Test extends Parser {
tests.jdkDate = jdkDate;
tests.sdkResource = sdkResource;
tests.machine = this.extractMachineInfo(output);
tests.testSummary = this.extractTestSummary(output);
const tkgTestSummary = this.extractTestSummary(output);

// Use test summary from TKG as default. If not, use test summary from TRSS.
if (tkgTestSummary) {
tests.testSummary = tkgTestSummary;
}
tests.startBy = this.extractStartedBy(output);
tests.artifactory = this.extractArtifact(output);
tests.rerunLink = this.extractRerunLink(output);
Expand All @@ -49,6 +54,12 @@ class Test extends Parser {
finishTime,
testResultRegex;
let results = [];
let total = 0,
executed = 0,
passed = 0,
failed = 0,
skipped = 0,
disabled = 0;
const readline = require('readline');
const stream = require('stream');
let buf = Buffer.from(str);
Expand Down Expand Up @@ -111,9 +122,24 @@ class Test extends Parser {
: null,
startTime: parseInt(startTime),
});
if (testResult == 'FAILED') {
executed++;
failed++;
} else if (testResult == 'PASSED') {
executed++;
passed++;
} else if (testResult == 'DISABLED') {
disabled++;
} else if (testResult == 'SKIPPED') {
skipped++;
}
total++;

// reset values
testName = null;
testStr = null;
nonTestStr = '';
testResult = '';
}
} else {
if (!preTestDone || !postTestDone) {
Expand All @@ -131,6 +157,9 @@ class Test extends Parser {
testData: null,
startTime,
});
executed++;
failed++;
total++;
} else if (!results || results.length === 0) {
// No test has been executed after reading all test output.
results.push({
Expand Down Expand Up @@ -170,6 +199,16 @@ class Test extends Parser {
tests: results,
...(buildResult && { buildResult }),
type: isPerf ? 'Perf' : 'Test',
// test summary from TRSS extract()
testSummary: {
total,
executed,
passed,
failed,
disabled,
skipped,
data: 'TRSS',
},
};
}
}
Expand Down

0 comments on commit ab779ad

Please sign in to comment.