From 0613fbd654bacb9324e07bb2f9f4244302c48aaa Mon Sep 17 00:00:00 2001 From: "halil.cakal" Date: Mon, 27 May 2024 16:06:59 +0100 Subject: Print summary report for K6 tests - add a generic template to print summary of k6 test results - remove container logs since its around 50 mb Issue-ID: CPS-2215 Change-Id: I8971fc30b9dc8be2ed16eda6755d17a91f608b48 Signed-off-by: halil.cakal Signed-off-by: danielhanrahan Signed-off-by: halil.cakal --- k6-tests/ncmp/utils.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'k6-tests/ncmp/utils.js') diff --git a/k6-tests/ncmp/utils.js b/k6-tests/ncmp/utils.js index 3b61b217e6..18a8940523 100644 --- a/k6-tests/ncmp/utils.js +++ b/k6-tests/ncmp/utils.js @@ -39,3 +39,23 @@ export function makeBatchOfCmHandleIds(batchSize, batchNumber) { export function getRandomCmHandleId() { return 'ch-' + (Math.floor(Math.random() * TOTAL_CM_HANDLES) + 1); } + +function removeBracketsAndQuotes(str) { + return str.replace(/\[|\]|"/g, ''); +} + +export function makeCustomSummaryReport(data, options) { + const moduleName = `${__ENV.K6_MODULE_NAME}`; + let body = ``; + for (const condition in options.thresholds) { + let limit = JSON.stringify(options.thresholds[condition]) + limit = removeBracketsAndQuotes(limit) + let limitKey = limit.split(' ')[0] + const actual = Math.ceil(data.metrics[condition].values[limitKey]) + const result = data.metrics[condition].thresholds[limit].ok ? 'PASS' : 'FAIL' + const row = `${moduleName}\t${condition}\t${limit}\t${actual}\t${result}\n`; + body += row; + } + return body; +} + -- cgit 1.2.3-korg