[k6] Fix incorrect results when errors occur in k6 tests (case 2) 12/138912/3
authoregernug <gerard.nugent@est.tech>
Fri, 6 Sep 2024 11:09:31 +0000 (12:09 +0100)
committerDaniel Hanrahan <daniel.hanrahan@est.tech>
Tue, 10 Sep 2024 18:53:36 +0000 (18:53 +0000)
De-registration is reported as 200,000 handles per second if all operations fail
- Added a running total for successful de-registrations of CM Handles

Issue-ID: CPS-2346

Change-Id: Ib4302d3b605ff1eaf4ecadac11b4e851a69210df
Signed-off-by: egernug <gerard.nugent@est.tech>
k6-tests/ncmp/ncmp-kpi.js

index ef3d0c6..1d084f2 100644 (file)
@@ -139,17 +139,21 @@ export function setup() {
 export function teardown() {
     const startTimeInMillis = Date.now();
 
+    let DEREGISTERED_CM_HANDLES = 0
     const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE);
     for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) {
         const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber);
         const response = deleteCmHandles(nextBatchOfCmHandleIds);
+        if (response.error_code === 0) {
+              DEREGISTERED_CM_HANDLES += REGISTRATION_BATCH_SIZE
+        }
         check(response, { 'delete CM-handles status equals 200': (r) => r.status === 200 });
     }
 
     const endTimeInMillis = Date.now();
     const totalDeregistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0;
 
-    cmHandlesDeletedPerSecondTrend.add(TOTAL_CM_HANDLES / totalDeregistrationTimeInSeconds);
+    cmHandlesDeletedPerSecondTrend.add(DEREGISTERED_CM_HANDLES / totalDeregistrationTimeInSeconds);
 }
 
 export function executePassthroughReadScenario() {