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 | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 22 | import { Gauge, Trend } from 'k6/metrics'; |
| 23 | import { TOTAL_CM_HANDLES, READ_DATA_FOR_CM_HANDLE_DELAY_MS, WRITE_DATA_FOR_CM_HANDLE_DELAY_MS, |
| 24 | makeCustomSummaryReport, recordTimeInSeconds } from './common/utils.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 25 | import { registerAllCmHandles, deregisterAllCmHandles } from './common/cmhandle-crud.js'; |
| 26 | import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js'; |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 27 | import { passthroughRead, passthroughWrite } from './common/passthrough-crud.js'; |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 28 | |
| 29 | let cmHandlesCreatedPerSecondGauge = new Gauge('cmhandles_created_per_second'); |
| 30 | let cmHandlesDeletedPerSecondGauge = new Gauge('cmhandles_deleted_per_second'); |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 31 | let passthroughReadNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_read'); |
| 32 | let passthroughWriteNcmpOverheadTrend = new Trend('ncmp_overhead_passthrough_write'); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 33 | |
| 34 | const DURATION = '15m'; |
| 35 | |
| 36 | export const options = { |
| 37 | setupTimeout: '6m', |
| 38 | teardownTimeout: '6m', |
| 39 | scenarios: { |
| 40 | passthrough_read: { |
| 41 | executor: 'constant-vus', |
| 42 | exec: 'passthrough_read', |
| 43 | vus: 10, |
| 44 | duration: DURATION, |
| 45 | }, |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 46 | passthrough_write: { |
| 47 | executor: 'constant-vus', |
| 48 | exec: 'passthrough_write', |
| 49 | vus: 10, |
| 50 | duration: DURATION, |
| 51 | }, |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 52 | id_search_module: { |
| 53 | executor: 'constant-vus', |
| 54 | exec: 'id_search_module', |
| 55 | vus: 3, |
| 56 | duration: DURATION, |
| 57 | }, |
| 58 | cm_search_module: { |
| 59 | executor: 'constant-vus', |
| 60 | exec: 'cm_search_module', |
| 61 | vus: 3, |
| 62 | duration: DURATION, |
| 63 | }, |
| 64 | }, |
| 65 | thresholds: { |
| 66 | 'cmhandles_created_per_second': ['value >= 22'], |
| 67 | 'cmhandles_deleted_per_second': ['value >= 22'], |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 68 | 'http_reqs{scenario:passthrough_write}': ['rate >= 13'], |
halil.cakal | 9046476 | 2024-07-09 17:43:25 +0100 | [diff] [blame] | 69 | 'http_reqs{scenario:passthrough_read}': ['rate >= 25'], |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 70 | 'ncmp_overhead_passthrough_read': ['avg <= 100'], |
| 71 | 'ncmp_overhead_passthrough_write': ['avg <= 100'], |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 72 | 'http_req_duration{scenario:id_search_module}': ['avg <= 625'], |
| 73 | 'http_req_duration{scenario:cm_search_module}': ['avg <= 13000'], |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 74 | 'http_req_failed{scenario:id_search_module}': ['rate == 0'], |
| 75 | 'http_req_failed{scenario:cm_search_module}': ['rate == 0'], |
| 76 | 'http_req_failed{scenario:passthrough_read}': ['rate == 0'], |
| 77 | 'http_req_failed{scenario:passthrough_write}': ['rate == 0'], |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 78 | }, |
| 79 | }; |
| 80 | |
| 81 | export function setup() { |
| 82 | const totalRegistrationTimeInSeconds = recordTimeInSeconds(registerAllCmHandles); |
| 83 | cmHandlesCreatedPerSecondGauge.add(TOTAL_CM_HANDLES / totalRegistrationTimeInSeconds); |
| 84 | } |
| 85 | |
| 86 | export function teardown() { |
| 87 | const totalDeregistrationTimeInSeconds = recordTimeInSeconds(deregisterAllCmHandles); |
| 88 | cmHandlesDeletedPerSecondGauge.add(TOTAL_CM_HANDLES / totalDeregistrationTimeInSeconds); |
| 89 | } |
| 90 | |
| 91 | export function passthrough_read() { |
| 92 | const response = passthroughRead(); |
| 93 | check(response, { 'passthrough read status equals 200': (r) => r.status === 200 }); |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 94 | const overhead = response.timings.duration - READ_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 95 | passthroughReadNcmpOverheadTrend.add(overhead); |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 96 | } |
| 97 | |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 98 | export function passthrough_write() { |
| 99 | const response = passthroughWrite(); |
danielhanrahan | df58456 | 2024-07-25 16:20:15 +0100 | [diff] [blame] | 100 | check(response, { 'passthrough write status equals 201': (r) => r.status === 201 }); |
danielhanrahan | dbe7b66 | 2024-07-16 11:47:24 +0100 | [diff] [blame] | 101 | const overhead = response.timings.duration - WRITE_DATA_FOR_CM_HANDLE_DELAY_MS; |
| 102 | passthroughWriteNcmpOverheadTrend.add(overhead); |
halil.cakal | fcc81ee | 2024-07-11 14:54:57 +0100 | [diff] [blame] | 103 | } |
| 104 | |
danielhanrahan | 4e9f68c | 2024-06-28 13:43:35 +0100 | [diff] [blame] | 105 | export function id_search_module() { |
| 106 | const response = executeCmHandleIdSearch('module'); |
| 107 | check(response, { 'module ID search status equals 200': (r) => r.status === 200 }); |
| 108 | check(JSON.parse(response.body), { 'module ID search returned expected CM-handles': (arr) => arr.length === TOTAL_CM_HANDLES }); |
| 109 | } |
| 110 | |
| 111 | export function cm_search_module() { |
| 112 | const response = executeCmHandleSearch('module'); |
| 113 | check(response, { 'module search status equals 200': (r) => r.status === 200 }); |
| 114 | check(JSON.parse(response.body), { 'module search returned expected CM-handles': (arr) => arr.length === TOTAL_CM_HANDLES }); |
| 115 | } |
| 116 | |
| 117 | export function handleSummary(data) { |
| 118 | return { |
| 119 | stdout: makeCustomSummaryReport(data, options), |
| 120 | }; |
| 121 | } |