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'; |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 29 | import { |
| 30 | createCmHandles, |
| 31 | deleteCmHandles, |
| 32 | waitForAllCmHandlesToBeReady |
| 33 | } from './common/cmhandle-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 34 | import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js'; |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 35 | import { passthroughRead, passthroughReadWithAltId, passthroughWrite, batchRead } from './common/passthrough-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 36 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 37 | let cmHandlesCreatedPerSecondTrend = new Trend('cmhandles_created_per_second', false); |
| 38 | let cmHandlesDeletedPerSecondTrend = new Trend('cmhandles_deleted_per_second', false); |
danielhanrahan | a1cdf73 | 2024-08-16 11:09:25 +0100 | [diff] [blame] | 39 | let passthroughReadNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_read', true); |
| 40 | let passthroughReadNcmpOverheadTrendWithAlternateId = new Trend('ncmp_overhead_passthrough_read_alt_id', true); |
| 41 | let passthroughWriteNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_write', true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 42 | let idSearchDurationTrend = new Trend('id_search_duration', true); |
| 43 | let cmSearchDurationTrend = new Trend('cm_search_duration', true); |
| 44 | let dataOperationsBatchReadCmHandlePerSecondTrend = new Trend('data_operations_batch_read_cmhandles_per_second', false); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 45 | |
| 46 | const reader = new Reader({ |
| 47 | brokers: KAFKA_BOOTSTRAP_SERVERS, |
| 48 | topic: TOPIC_DATA_OPERATIONS_BATCH_READ, |
| 49 | }); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 50 | |
| 51 | const DURATION = '15m'; |
| 52 | |
| 53 | export const options = { |
| 54 | setupTimeout: '6m', |
| 55 | teardownTimeout: '6m', |
| 56 | scenarios: { |
| 57 | passthrough_read: { |
| 58 | executor: 'constant-vus', |
| 59 | exec: 'passthrough_read', |
danielhanrahan | a1cdf73 | 2024-08-16 11:09:25 +0100 | [diff] [blame] | 60 | vus: 9, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 61 | duration: DURATION, |
| 62 | }, |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 63 | passthrough_read_alt_id: { |
| 64 | executor: 'constant-vus', |
| 65 | exec: 'passthrough_read_alt_id', |
| 66 | vus: 1, |
| 67 | duration: DURATION, |
| 68 | }, |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 69 | passthrough_write: { |
| 70 | executor: 'constant-vus', |
| 71 | exec: 'passthrough_write', |
| 72 | vus: 10, |
| 73 | duration: DURATION, |
| 74 | }, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 75 | id_search_module: { |
| 76 | executor: 'constant-vus', |
| 77 | exec: 'id_search_module', |
| 78 | vus: 3, |
| 79 | duration: DURATION, |
| 80 | }, |
| 81 | cm_search_module: { |
| 82 | executor: 'constant-vus', |
| 83 | exec: 'cm_search_module', |
| 84 | vus: 3, |
| 85 | duration: DURATION, |
| 86 | }, |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 87 | data_operation_send_async_http_request: { |
| 88 | executor: 'constant-arrival-rate', |
| 89 | exec: 'data_operation_send_async_http_request', |
| 90 | duration: DURATION, |
| 91 | rate: 1, |
| 92 | timeUnit: '1s', |
| 93 | preAllocatedVUs: 1, |
| 94 | }, |
| 95 | data_operation_async_batch_read: { |
| 96 | executor: 'constant-arrival-rate', |
| 97 | exec: 'data_operation_async_batch_read', |
| 98 | duration: DURATION, |
| 99 | rate: 1, |
| 100 | timeUnit: '1s', |
| 101 | preAllocatedVUs: 1, |
| 102 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 103 | }, |
| 104 | thresholds: { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 105 | 'cmhandles_created_per_second': ['avg >= 22'], |
| 106 | 'cmhandles_deleted_per_second': ['avg >= 22'], |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 107 | 'ncmp_overhead_passthrough_read': ['avg <= 100'], |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 108 | 'ncmp_overhead_passthrough_read_alt_id': ['avg <= 100'], |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 109 | 'ncmp_overhead_passthrough_write': ['avg <= 100'], |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 110 | 'id_search_duration': ['avg <= 625'], |
| 111 | 'cm_search_duration': ['avg <= 13000'], |
| 112 | 'data_operations_batch_read_cmhandles_per_second': ['avg >= 150'], |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 113 | 'http_req_failed{scenario:id_search_module}': ['rate == 0'], |
| 114 | 'http_req_failed{scenario:cm_search_module}': ['rate == 0'], |
| 115 | 'http_req_failed{scenario:passthrough_read}': ['rate == 0'], |
| 116 | 'http_req_failed{scenario:passthrough_write}': ['rate == 0'], |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 117 | 'http_req_failed{group:::setup}':['rate == 0'], |
| 118 | 'http_req_failed{group:::teardown}':['rate == 0'], |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 119 | 'http_req_failed{scenario:data_operation_send_async_http_request}': ['rate == 0'], |
| 120 | 'kafka_reader_error_count{scenario:data_operation_consume_kafka_responses}': ['count == 0'], |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 121 | }, |
| 122 | }; |
| 123 | |
| 124 | export function setup() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 125 | const startTimeInMillis = Date.now(); |
| 126 | |
| 127 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 128 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 129 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 130 | const response = createCmHandles(nextBatchOfCmHandleIds); |
| 131 | check(response, { 'create CM-handles status equals 200': (r) => r.status === 200 }); |
| 132 | } |
| 133 | |
| 134 | waitForAllCmHandlesToBeReady(); |
| 135 | |
| 136 | const endTimeInMillis = Date.now(); |
| 137 | const totalRegistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 138 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 139 | cmHandlesCreatedPerSecondTrend.add(TOTAL_CM_HANDLES / totalRegistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | export function teardown() { |
halil.cakal | 1745d20 | 2024-08-06 14:02:49 +0100 | [diff] [blame] | 143 | const startTimeInMillis = Date.now(); |
| 144 | |
| 145 | const TOTAL_BATCHES = Math.ceil(TOTAL_CM_HANDLES / REGISTRATION_BATCH_SIZE); |
| 146 | for (let batchNumber = 0; batchNumber < TOTAL_BATCHES; batchNumber++) { |
| 147 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(REGISTRATION_BATCH_SIZE, batchNumber); |
| 148 | const response = deleteCmHandles(nextBatchOfCmHandleIds); |
| 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 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 155 | cmHandlesDeletedPerSecondTrend.add(TOTAL_CM_HANDLES / totalDeregistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | export function passthrough_read() { |
| 159 | const response = passthroughRead(); |
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 | |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 166 | export function passthrough_read_alt_id() { |
| 167 | const response = passthroughReadWithAltId(); |
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 | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 174 | export function passthrough_write() { |
| 175 | const response = passthroughWrite(); |
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 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 182 | export function id_search_module() { |
| 183 | const response = executeCmHandleIdSearch('module'); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 184 | if (check(response, { 'CM handle ID search status equals 200': (r) => r.status === 200 })) { |
| 185 | check(response, { 'CM handle ID search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES }); |
| 186 | idSearchDurationTrend.add(response.timings.duration); |
| 187 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | export function cm_search_module() { |
| 191 | const response = executeCmHandleSearch('module'); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 192 | if (check(response, { 'CM handle search status equals 200': (r) => r.status === 200 })) { |
| 193 | check(response, { 'CM handle search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES }); |
| 194 | cmSearchDurationTrend.add(response.timings.duration); |
| 195 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 196 | } |
| 197 | |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 198 | export function data_operation_send_async_http_request() { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame^] | 199 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(DATA_OPERATION_READ_BATCH_SIZE, 0); |
| 200 | const response = batchRead(nextBatchOfCmHandleIds); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 201 | check(response, { 'data operation batch read status equals 200': (r) => r.status === 200 }); |
| 202 | } |
| 203 | |
| 204 | export function data_operation_async_batch_read() { |
| 205 | try { |
| 206 | let messages = reader.consume({ limit: DATA_OPERATION_READ_BATCH_SIZE }); |
| 207 | dataOperationsBatchReadCmHandlePerSecondTrend.add(messages.length); |
| 208 | } catch (error) { |
| 209 | dataOperationsBatchReadCmHandlePerSecondTrend.add(0); |
| 210 | console.error(error); |
| 211 | } |
| 212 | } |
| 213 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 214 | export function handleSummary(data) { |
| 215 | return { |
| 216 | stdout: makeCustomSummaryReport(data, options), |
| 217 | }; |
| 218 | } |