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 | |
| 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); |
| 146 | check(response, { 'delete CM-handles status equals 200': (r) => r.status === 200 }); |
| 147 | } |
| 148 | |
| 149 | const endTimeInMillis = Date.now(); |
| 150 | const totalDeregistrationTimeInSeconds = (endTimeInMillis - startTimeInMillis) / 1000.0; |
| 151 | |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 152 | cmHandlesDeletedPerSecondTrend.add(TOTAL_CM_HANDLES / totalDeregistrationTimeInSeconds); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 153 | } |
| 154 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame^] | 155 | export function executePassthroughReadScenario() { |
| 156 | const response = passthroughRead(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 157 | if (check(response, { 'passthrough read status equals 200': (r) => r.status === 200 })) { |
| 158 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 159 | passthroughReadNcmpOverheadTrend.add(overhead); |
| 160 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 161 | } |
| 162 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame^] | 163 | export function executePassthroughReadAltIdScenario() { |
| 164 | const response = passthroughRead(true); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 165 | if (check(response, { 'passthrough read with alternate Id status equals 200': (r) => r.status === 200 })) { |
| 166 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 167 | passthroughReadNcmpOverheadTrendWithAlternateId.add(overhead); |
| 168 | } |
seanbeirne | 2855952 | 2024-07-19 16:55:06 +0100 | [diff] [blame] | 169 | } |
| 170 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame^] | 171 | export function executePassthroughWriteScenario() { |
| 172 | const response = passthroughWrite(false); |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 173 | if (check(response, { 'passthrough write status equals 201': (r) => r.status === 201 })) { |
| 174 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 175 | passthroughWriteNcmpOverheadTrend.add(overhead); |
| 176 | } |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 177 | } |
| 178 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame^] | 179 | export function executePassthroughWriteAltIdScenario() { |
| 180 | const response = passthroughWrite(true); |
| 181 | if (check(response, { 'passthrough write with alternate Id status equals 201': (r) => r.status === 201 })) { |
| 182 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 183 | passthroughWriteNcmpOverheadTrendWithAlternateId.add(overhead); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | export function executeCmHandleIdSearchScenario() { |
| 188 | const response = executeCmHandleIdSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 189 | if (check(response, { 'CM handle ID search status equals 200': (r) => r.status === 200 }) |
| 190 | && 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] | 191 | idSearchDurationTrend.add(response.timings.duration); |
| 192 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 193 | } |
| 194 | |
danielhanrahan | f2e1e25 | 2024-08-25 21:35:19 +0100 | [diff] [blame^] | 195 | export function executeCmHandleSearchScenario() { |
| 196 | const response = executeCmHandleSearch('module-and-properties'); |
danielhanrahan | 4dac130 | 2024-08-30 15:03:06 +0100 | [diff] [blame] | 197 | if (check(response, { 'CM handle search status equals 200': (r) => r.status === 200 }) |
| 198 | && 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] | 199 | cmSearchDurationTrend.add(response.timings.duration); |
| 200 | } |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 201 | } |
| 202 | |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 203 | export function data_operation_send_async_http_request() { |
danielhanrahan | 78894db | 2024-08-16 13:56:14 +0100 | [diff] [blame] | 204 | const nextBatchOfCmHandleIds = makeBatchOfCmHandleIds(DATA_OPERATION_READ_BATCH_SIZE, 0); |
| 205 | const response = batchRead(nextBatchOfCmHandleIds); |
halil.cakal | 65b870b | 2024-07-25 11:12:29 +0100 | [diff] [blame] | 206 | check(response, { 'data operation batch read status equals 200': (r) => r.status === 200 }); |
| 207 | } |
| 208 | |
| 209 | export function data_operation_async_batch_read() { |
| 210 | try { |
| 211 | let messages = reader.consume({ limit: DATA_OPERATION_READ_BATCH_SIZE }); |
| 212 | dataOperationsBatchReadCmHandlePerSecondTrend.add(messages.length); |
| 213 | } catch (error) { |
| 214 | dataOperationsBatchReadCmHandlePerSecondTrend.add(0); |
| 215 | console.error(error); |
| 216 | } |
| 217 | } |
| 218 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 219 | export function handleSummary(data) { |
| 220 | return { |
| 221 | stdout: makeCustomSummaryReport(data, options), |
| 222 | }; |
| 223 | } |