diff options
author | Daniel Hanrahan <daniel.hanrahan@est.tech> | 2024-05-28 10:16:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2024-05-28 10:16:20 +0000 |
commit | 1e4bf345c21586491ee4767ed9f44de22a99a8c2 (patch) | |
tree | 3a660fba69b3d44331c709ccc0e489fd1b22b970 /k6-tests/ncmp/utils.js | |
parent | c69ce470ecabedc9df59b9a9d3888338850fd502 (diff) | |
parent | 0613fbd654bacb9324e07bb2f9f4244302c48aaa (diff) |
Merge "Print summary report for K6 tests"
Diffstat (limited to 'k6-tests/ncmp/utils.js')
-rw-r--r-- | k6-tests/ncmp/utils.js | 20 |
1 files changed, 20 insertions, 0 deletions
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; +} + |