danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * Copyright (C) 2024 Nordix Foundation |
| 4 | * ================================================================================ |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | * SPDX-License-Identifier: Apache-2.0 |
| 18 | * ============LICENSE_END========================================================= |
| 19 | */ |
| 20 | |
| 21 | import { check } from 'k6'; |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 22 | import { Trend } from 'k6/metrics'; |
danielhanrahan | a1cdf73 | 2024-08-16 11:09:25 +0100 | [diff] [blame] | 23 | import { Reader } from 'k6/x/kafka'; |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 24 | import { |
| 25 | TOTAL_CM_HANDLES, READ_DATA_FOR_CM_HANDLE_DELAY_MS, WRITE_DATA_FOR_CM_HANDLE_DELAY_MS, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 26 | makeCustomSummaryReport, makeBatchOfCmHandleIds, LEGACY_BATCH_THROUGHPUT_TEST_BATCH_SIZE, |
| 27 | LEGACY_BATCH_TOPIC_NAME, KAFKA_BOOTSTRAP_SERVERS, REGISTRATION_BATCH_SIZE, |
| 28 | LEGACY_BATCH_THROUGHPUT_TEST_NUMBER_OF_REQUESTS |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 29 | } from './common/utils.js'; |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 30 | import { createCmHandles, deleteCmHandles, waitForAllCmHandlesToBeReady } from './common/cmhandle-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 31 | import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js'; |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 32 | import { passthroughRead, passthroughWrite, legacyBatchRead } from './common/passthrough-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 33 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 34 | let cmHandlesCreatedPerSecondTrend = new Trend('cmhandles_created_per_second', false); |
| 35 | let cmHandlesDeletedPerSecondTrend = new Trend('cmhandles_deleted_per_second', false); |
danielhanrahan | a1cdf73 | 2024-08-16 11:09:25 +0100 | [diff] [blame] | 36 | let passthroughReadNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_read', true); |
| 37 | let passthroughReadNcmpOverheadTrendWithAlternateId = new Trend('ncmp_overhead_passthrough_read_alt_id', true); |
| 38 | let passthroughWriteNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_write', true); |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 39 | let passthroughWriteNcmpOverheadTrendWithAlternateId = new Trend('ncmp_overhead_passthrough_write_alt_id', true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 40 | let idSearchDurationTrend = new Trend('id_search_duration', true); |
| 41 | let cmSearchDurationTrend = new Trend('cm_search_duration', true); |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 42 | let legacyBatchReadCmHandlesPerSecondTrend = new Trend('legacy_batch_read_cmhandles_per_second', false); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 43 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 44 | const legacyBatchEventReader = new Reader({ |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 45 | brokers: KAFKA_BOOTSTRAP_SERVERS, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 46 | topic: LEGACY_BATCH_TOPIC_NAME, |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 47 | }); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 48 | |
| 49 | const DURATION = '15m'; |
| 50 | |
| 51 | export const options = { |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 52 | setupTimeout: '8m', |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 53 | teardownTimeout: '6m', |
| 54 | scenarios: { |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 55 | passthrough_read_scenario: { |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 56 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 57 | exec: 'passthroughReadScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 58 | vus: 4, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 59 | duration: DURATION, |
| 60 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 61 | passthrough_read_alt_id_scenario: { |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 62 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 63 | exec: 'passthroughReadAltIdScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 64 | vus: 4, |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 65 | duration: DURATION, |
| 66 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 67 | passthrough_write_scenario: { |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 68 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 69 | exec: 'passthroughWriteScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 70 | vus: 4, |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 71 | duration: DURATION, |
| 72 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 73 | passthrough_write_alt_id_scenario: { |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 74 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 75 | exec: 'passthroughWriteAltIdScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 76 | vus: 4, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 77 | duration: DURATION, |
| 78 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 79 | cm_handle_id_search_scenario: { |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 80 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 81 | exec: 'cmHandleIdSearchScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 82 | vus: 5, |
| 83 | duration: DURATION, |
| 84 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 85 | cm_handle_search_scenario: { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 86 | executor: 'constant-vus', |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 87 | exec: 'cmHandleSearchScenario', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 88 | vus: 5, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 89 | duration: DURATION, |
| 90 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 91 | legacy_batch_produce_scenario: { |
| 92 | executor: 'shared-iterations', |
| 93 | exec: 'legacyBatchProduceScenario', |
| 94 | vus: 2, |
| 95 | iterations: LEGACY_BATCH_THROUGHPUT_TEST_NUMBER_OF_REQUESTS, |
| 96 | maxDuration: DURATION, |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 97 | }, |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 98 | legacy_batch_consume_scenario: { |
| 99 | executor: 'per-vu-iterations', |
| 100 | exec: 'legacyBatchConsumeScenario', |
| 101 | vus: 1, |
| 102 | iterations: 1, |
| 103 | maxDuration: DURATION, |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 104 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 105 | }, |
| 106 | thresholds: { |
danielhanrahan | 4cb6239 | 2024-08-27 17:57:26 +0100 | [diff] [blame] | 107 | 'http_req_failed': ['rate == 0'], |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 108 | 'cmhandles_created_per_second': ['avg >= 22'], |
| 109 | 'cmhandles_deleted_per_second': ['avg >= 22'], |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 110 | 'ncmp_overhead_passthrough_read': ['avg <= 40'], |
| 111 | 'ncmp_overhead_passthrough_write': ['avg <= 40'], |
| 112 | 'ncmp_overhead_passthrough_read_alt_id': ['avg <= 40'], |
| 113 | 'ncmp_overhead_passthrough_write_alt_id': ['avg <= 40'], |
| 114 | 'id_search_duration': ['avg <= 2000'], |
| 115 | 'cm_search_duration': ['avg <= 15000'], |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 116 | 'legacy_batch_read_cmhandles_per_second': ['avg >= 150'], |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 117 | }, |
| 118 | }; |
| 119 | |
| 120 | export function setup() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 121 | const startTimeInMillis = Date.now(); |
| 122 | |
| 123 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 124 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 125 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 126 | const response = createCmHandles(nextBatchOfCmHandleIds); |
| 127 | check(response, { 'create CM-handles status equals 200': (r) => r.status === 200 }); |
| 128 | } |
| 129 | |
| 130 | waitForAllCmHandlesToBeReady(); |
| 131 | |
| 132 | const endTimeInMillis = Date.now(); |
| 133 | const totalRegistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 134 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 135 | cmHandlesCreatedPerSecondTrend.add(TOTAL_CM_HANDLES / totalRegistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | export function teardown() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 139 | const startTimeInMillis = Date.now(); |
| 140 | |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame] | 141 | let DEREGISTERED_CM_HANDLES = 0 |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 142 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 143 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 144 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 145 | const response = deleteCmHandles(nextBatchOfCmHandleIds); |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame] | 146 | if (response.error_code === 0) { |
| 147 | DEREGISTERED_CM_HANDLES += REGISTRATION_BATCH_SIZE |
| 148 | } |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 149 | check(response, { 'delete CM-handles status equals 200': (r) => r.status === 200 }); |
| 150 | } |
| 151 | |
| 152 | const endTimeInMillis = Date.now(); |
| 153 | const totalDeregistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 154 | |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame] | 155 | cmHandlesDeletedPerSecondTrend.add(DEREGISTERED_CM_HANDLES / totalDeregistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 156 | } |
| 157 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 158 | export function passthroughReadScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 159 | const response = passthroughRead(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 160 | if (check(response, { 'passthrough read status equals 200': (r) => r.status === 200 })) { |
| 161 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 162 | passthroughReadNcmpOverheadTrend.add(overhead); |
| 163 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 164 | } |
| 165 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 166 | export function passthroughReadAltIdScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 167 | const response = passthroughRead(true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 168 | if (check(response, { 'passthrough read with alternate Id status equals 200': (r) => r.status === 200 })) { |
| 169 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 170 | passthroughReadNcmpOverheadTrendWithAlternateId.add(overhead); |
| 171 | } |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 172 | } |
| 173 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 174 | export function passthroughWriteScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 175 | const response = passthroughWrite(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 176 | if (check(response, { 'passthrough write status equals 201': (r) => r.status === 201 })) { |
| 177 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 178 | passthroughWriteNcmpOverheadTrend.add(overhead); |
| 179 | } |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 180 | } |
| 181 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 182 | export function passthroughWriteAltIdScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 183 | const response = passthroughWrite(true); |
| 184 | if (check(response, { 'passthrough write with alternate Id status equals 201': (r) => r.status === 201 })) { |
| 185 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 186 | passthroughWriteNcmpOverheadTrendWithAlternateId.add(overhead); |
| 187 | } |
| 188 | } |
| 189 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 190 | export function cmHandleIdSearchScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 191 | const response = executeCmHandleIdSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 192 | if (check(response, { 'CM handle ID search status equals 200': (r) => r.status === 200 }) |
| 193 | && check(response, { 'CM handle ID search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 194 | idSearchDurationTrend.add(response.timings.duration); |
| 195 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 196 | } |
| 197 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 198 | export function cmHandleSearchScenario() { |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 199 | const response = executeCmHandleSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 200 | if (check(response, { 'CM handle search status equals 200': (r) => r.status === 200 }) |
| 201 | && check(response, { 'CM handle search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 202 | cmSearchDurationTrend.add(response.timings.duration); |
| 203 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 204 | } |
| 205 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 206 | export function legacyBatchProduceScenario() { |
| 207 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(LEGACY_BATCH_THROUGHPUT_TEST_BATCH_SIZE, 0); |
| 208 | const response = legacyBatchRead(nextBatchOfCmHandleIds); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 209 | check(response, { 'data operation batch read status equals 200': (r) => r.status === 200 }); |
| 210 | } |
| 211 | |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 212 | export function legacyBatchConsumeScenario() { |
| 213 | const TOTAL_MESSAGES_TO_CONSUME = LEGACY_BATCH_THROUGHPUT_TEST_NUMBER_OF_REQUESTS * LEGACY_BATCH_THROUGHPUT_TEST_BATCH_SIZE; |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 214 | try { |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 215 | let messagesConsumed = 0; |
| 216 | let startTime = Date.now(); |
| 217 | |
| 218 | while (messagesConsumed < TOTAL_MESSAGES_TO_CONSUME) { |
| 219 | let messages = legacyBatchEventReader.consume({ limit: 1000 }); |
| 220 | |
| 221 | if (messages.length > 0) { |
| 222 | messagesConsumed += messages.length; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | let endTime = Date.now(); |
| 227 | const timeToConsumeMessagesInSeconds = (endTime - startTime) / 1000.0; |
| 228 | legacyBatchReadCmHandlesPerSecondTrend.add(TOTAL_MESSAGES_TO_CONSUME / timeToConsumeMessagesInSeconds); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 229 | } catch (error) { |
halil.cakal | fc49910 | 2024-08-28 10:19:26 +0100 | [diff] [blame^] | 230 | legacyBatchReadCmHandlesPerSecondTrend.add(0); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 231 | console.error(error); |
| 232 | } |
| 233 | } |
| 234 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 235 | export function handleSummary(data) { |
| 236 | return { |
| 237 | stdout: makeCustomSummaryReport(data, options), |
| 238 | }; |
| 239 | } |