From ab779ad129336e46e7b754529eb261b6f02708c3 Mon Sep 17 00:00:00 2001 From: Lan Xia Date: Mon, 4 Nov 2024 16:09:17 -0500 Subject: [PATCH] Add test summary from TRSS (#930) resolves: https://github.com/adoptium/aqa-test-tools/issues/929 Signed-off-by: Lan Xia --- TestResultSummaryService/parsers/Parser.js | 6 ++-- TestResultSummaryService/parsers/Test.js | 41 +++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/TestResultSummaryService/parsers/Parser.js b/TestResultSummaryService/parsers/Parser.js index ca8d6e56..e2c1302e 100644 --- a/TestResultSummaryService/parsers/Parser.js +++ b/TestResultSummaryService/parsers/Parser.js @@ -142,7 +142,7 @@ 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); @@ -150,8 +150,10 @@ class Parser { 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) { diff --git a/TestResultSummaryService/parsers/Test.js b/TestResultSummaryService/parsers/Test.js index 291a74b0..9199354a 100644 --- a/TestResultSummaryService/parsers/Test.js +++ b/TestResultSummaryService/parsers/Test.js @@ -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); @@ -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); @@ -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) { @@ -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({ @@ -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', + }, }; } }