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 | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 26 | makeCustomSummaryReport, makeBatchOfCmHandleIds, DATA_OPERATION_READ_BATCH_SIZE, |
| 27 | TOPIC_DATA_OPERATIONS_BATCH_READ, KAFKA_BOOTSTRAP_SERVERS, REGISTRATION_BATCH_SIZE |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 28 | } from './common/utils.js'; |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 29 | import { createCmHandles, deleteCmHandles, waitForAllCmHandlesToBeReady } from './common/cmhandle-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 30 | import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js'; |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 31 | import { passthroughRead, passthroughReadWithAltId, passthroughWrite, batchRead } from './common/passthrough-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 32 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 33 | let cmHandlesCreatedPerSecondTrend = new Trend('cmhandles_created_per_second', false); |
| 34 | let cmHandlesDeletedPerSecondTrend = new Trend('cmhandles_deleted_per_second', false); |
danielhanrahan | a1cdf73 | 2024-08-16 11:09:25 +0100 | [diff] [blame] | 35 | let passthroughReadNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_read', true); |
| 36 | let passthroughReadNcmpOverheadTrendWithAlternateId = new Trend('ncmp_overhead_passthrough_read_alt_id', true); |
| 37 | let passthroughWriteNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_write', true); |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 38 | let passthroughWriteNcmpOverheadTrendWithAlternateId = new Trend('ncmp_overhead_passthrough_write_alt_id', true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 39 | let idSearchDurationTrend = new Trend('id_search_duration', true); |
| 40 | let cmSearchDurationTrend = new Trend('cm_search_duration', true); |
| 41 | let dataOperationsBatchReadCmHandlePerSecondTrend = new Trend('data_operations_batch_read_cmhandles_per_second', false); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 42 | |
| 43 | const reader = new Reader({ |
| 44 | brokers: KAFKA_BOOTSTRAP_SERVERS, |
| 45 | topic: TOPIC_DATA_OPERATIONS_BATCH_READ, |
| 46 | }); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 47 | |
| 48 | const DURATION = '15m'; |
| 49 | |
| 50 | export const options = { |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 51 | setupTimeout: '8m', |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 52 | teardownTimeout: '6m', |
| 53 | scenarios: { |
| 54 | passthrough_read: { |
| 55 | executor: 'constant-vus', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 56 | exec: 'executePassthroughReadScenario', |
| 57 | vus: 4, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 58 | duration: DURATION, |
| 59 | }, |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 60 | passthrough_read_alt_id: { |
| 61 | executor: 'constant-vus', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 62 | exec: 'executePassthroughReadAltIdScenario', |
| 63 | vus: 4, |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 64 | duration: DURATION, |
| 65 | }, |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 66 | passthrough_write: { |
| 67 | executor: 'constant-vus', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 68 | exec: 'executePassthroughWriteScenario', |
| 69 | vus: 4, |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 70 | duration: DURATION, |
| 71 | }, |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 72 | passthrough_write_alt_id: { |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 73 | executor: 'constant-vus', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 74 | exec: 'executePassthroughWriteAltIdScenario', |
| 75 | vus: 4, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 76 | duration: DURATION, |
| 77 | }, |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 78 | cm_handle_id_search: { |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 79 | executor: 'constant-vus', |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 80 | exec: 'executeCmHandleIdSearchScenario', |
| 81 | vus: 5, |
| 82 | duration: DURATION, |
| 83 | }, |
| 84 | cm_handle_search: { |
| 85 | executor: 'constant-vus', |
| 86 | exec: 'executeCmHandleSearchScenario', |
| 87 | vus: 5, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 88 | duration: DURATION, |
| 89 | }, |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 90 | data_operation_send_async_http_request: { |
| 91 | executor: 'constant-arrival-rate', |
| 92 | exec: 'data_operation_send_async_http_request', |
| 93 | duration: DURATION, |
| 94 | rate: 1, |
| 95 | timeUnit: '1s', |
| 96 | preAllocatedVUs: 1, |
| 97 | }, |
| 98 | data_operation_async_batch_read: { |
| 99 | executor: 'constant-arrival-rate', |
| 100 | exec: 'data_operation_async_batch_read', |
| 101 | duration: DURATION, |
| 102 | rate: 1, |
| 103 | timeUnit: '1s', |
| 104 | preAllocatedVUs: 1, |
| 105 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 106 | }, |
| 107 | thresholds: { |
danielhanrahan | 4cb6239 | 2024-08-27 17:57:26 +0100 | [diff] [blame] | 108 | 'http_req_failed': ['rate == 0'], |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 109 | 'cmhandles_created_per_second': ['avg >= 22'], |
| 110 | 'cmhandles_deleted_per_second': ['avg >= 22'], |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 111 | 'ncmp_overhead_passthrough_read': ['avg <= 40'], |
| 112 | 'ncmp_overhead_passthrough_write': ['avg <= 40'], |
| 113 | 'ncmp_overhead_passthrough_read_alt_id': ['avg <= 40'], |
| 114 | 'ncmp_overhead_passthrough_write_alt_id': ['avg <= 40'], |
| 115 | 'id_search_duration': ['avg <= 2000'], |
| 116 | 'cm_search_duration': ['avg <= 15000'], |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 117 | 'data_operations_batch_read_cmhandles_per_second': ['avg >= 150'], |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 118 | }, |
| 119 | }; |
| 120 | |
| 121 | export function setup() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 122 | const startTimeInMillis = Date.now(); |
| 123 | |
| 124 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 125 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 126 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 127 | const response = createCmHandles(nextBatchOfCmHandleIds); |
| 128 | check(response, { 'create CM-handles status equals 200': (r) => r.status === 200 }); |
| 129 | } |
| 130 | |
| 131 | waitForAllCmHandlesToBeReady(); |
| 132 | |
| 133 | const endTimeInMillis = Date.now(); |
| 134 | const totalRegistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 135 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 136 | cmHandlesCreatedPerSecondTrend.add(TOTAL_CM_HANDLES / totalRegistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | export function teardown() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 140 | const startTimeInMillis = Date.now(); |
| 141 | |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame^] | 142 | let DEREGISTERED_CM_HANDLES = 0 |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 143 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 144 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 145 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 146 | const response = deleteCmHandles(nextBatchOfCmHandleIds); |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame^] | 147 | if (response.error_code === 0) { |
| 148 | DEREGISTERED_CM_HANDLES += REGISTRATION_BATCH_SIZE |
| 149 | } |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 150 | check(response, { 'delete CM-handles status equals 200': (r) => r.status === 200 }); |
| 151 | } |
| 152 | |
| 153 | const endTimeInMillis = Date.now(); |
| 154 | const totalDeregistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 155 | |
egernug | 2bdef26 | 2024-09-06 12:09:31 +0100 | [diff] [blame^] | 156 | cmHandlesDeletedPerSecondTrend.add(DEREGISTERED_CM_HANDLES / totalDeregistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 157 | } |
| 158 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 159 | export function executePassthroughReadScenario() { |
| 160 | const response = passthroughRead(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 161 | if (check(response, { 'passthrough read status equals 200': (r) => r.status === 200 })) { |
| 162 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 163 | passthroughReadNcmpOverheadTrend.add(overhead); |
| 164 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 165 | } |
| 166 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 167 | export function executePassthroughReadAltIdScenario() { |
| 168 | const response = passthroughRead(true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 169 | if (check(response, { 'passthrough read with alternate Id status equals 200': (r) => r.status === 200 })) { |
| 170 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 171 | passthroughReadNcmpOverheadTrendWithAlternateId.add(overhead); |
| 172 | } |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 173 | } |
| 174 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 175 | export function executePassthroughWriteScenario() { |
| 176 | const response = passthroughWrite(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 177 | if (check(response, { 'passthrough write status equals 201': (r) => r.status === 201 })) { |
| 178 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 179 | passthroughWriteNcmpOverheadTrend.add(overhead); |
| 180 | } |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 181 | } |
| 182 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 183 | export function executePassthroughWriteAltIdScenario() { |
| 184 | const response = passthroughWrite(true); |
| 185 | if (check(response, { 'passthrough write with alternate Id status equals 201': (r) => r.status === 201 })) { |
| 186 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 187 | passthroughWriteNcmpOverheadTrendWithAlternateId.add(overhead); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | export function executeCmHandleIdSearchScenario() { |
| 192 | const response = executeCmHandleIdSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 193 | if (check(response, { 'CM handle ID search status equals 200': (r) => r.status === 200 }) |
| 194 | && 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] | 195 | idSearchDurationTrend.add(response.timings.duration); |
| 196 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 197 | } |
| 198 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame] | 199 | export function executeCmHandleSearchScenario() { |
| 200 | const response = executeCmHandleSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 201 | if (check(response, { 'CM handle search status equals 200': (r) => r.status === 200 }) |
| 202 | && 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] | 203 | cmSearchDurationTrend.add(response.timings.duration); |
| 204 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 205 | } |
| 206 | |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 207 | export function data_operation_send_async_http_request() { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 208 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(DATA_OPERATION_READ_BATCH_SIZE, 0); |
| 209 | const response = batchRead(nextBatchOfCmHandleIds); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 210 | check(response, { 'data operation batch read status equals 200': (r) => r.status === 200 }); |
| 211 | } |
| 212 | |
| 213 | export function data_operation_async_batch_read() { |
| 214 | try { |
| 215 | let messages = reader.consume({ limit: DATA_OPERATION_READ_BATCH_SIZE }); |
| 216 | dataOperationsBatchReadCmHandlePerSecondTrend.add(messages.length); |
| 217 | } catch (error) { |
| 218 | dataOperationsBatchReadCmHandlePerSecondTrend.add(0); |
| 219 | console.error(error); |
| 220 | } |
| 221 | } |
| 222 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 223 | export function handleSummary(data) { |
| 224 | return { |
| 225 | stdout: makeCustomSummaryReport(data, options), |
| 226 | }; |
| 227 | } |