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