blob: 6bf0568077803a67f52811112f570bd78b41a0f8 [file] [log] [blame]
danielhanrahan4e9f68c2024-06-28 13:43:35 +01001/*
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
21import { check } from 'k6';
22import { Gauge } from 'k6/metrics';
23import { TOTAL_CM_HANDLES, makeCustomSummaryReport, recordTimeInSeconds } from './common/utils.js';
24import { registerAllCmHandles, deregisterAllCmHandles } from './common/cmhandle-crud.js';
25import { executeCmHandleSearch, executeCmHandleIdSearch } from './common/search-base.js';
halil.cakalfcc81ee2024-07-11 14:54:57 +010026import { passthroughRead, passthroughWrite } from './common/passthrough-crud.js';
danielhanrahan4e9f68c2024-06-28 13:43:35 +010027
28let cmHandlesCreatedPerSecondGauge = new Gauge('cmhandles_created_per_second');
29let cmHandlesDeletedPerSecondGauge = new Gauge('cmhandles_deleted_per_second');
30
31const DURATION = '15m';
32
33export 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.cakalfcc81ee2024-07-11 14:54:57 +010043 passthrough_write: {
44 executor: 'constant-vus',
45 exec: 'passthrough_write',
46 vus: 10,
47 duration: DURATION,
48 },
danielhanrahan4e9f68c2024-06-28 13:43:35 +010049 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.cakalfcc81ee2024-07-11 14:54:57 +010065 'http_reqs{scenario:passthrough_write}': ['rate >= 13'],
halil.cakal90464762024-07-09 17:43:25 +010066 'http_reqs{scenario:passthrough_read}': ['rate >= 25'],
danielhanrahan4e9f68c2024-06-28 13:43:35 +010067 'http_req_failed{scenario:id_search_module}': ['rate == 0'],
68 'http_req_failed{scenario:cm_search_module}': ['rate == 0'],
danielhanrahan4e9f68c2024-06-28 13:43:35 +010069 'http_req_duration{scenario:id_search_module}': ['avg <= 625'],
70 'http_req_duration{scenario:cm_search_module}': ['avg <= 13000'],
71 },
72};
73
74export function setup() {
75 const totalRegistrationTimeInSeconds = recordTimeInSeconds(registerAllCmHandles);
76 cmHandlesCreatedPerSecondGauge.add(TOTAL_CM_HANDLES / totalRegistrationTimeInSeconds);
77}
78
79export function teardown() {
80 const totalDeregistrationTimeInSeconds = recordTimeInSeconds(deregisterAllCmHandles);
81 cmHandlesDeletedPerSecondGauge.add(TOTAL_CM_HANDLES / totalDeregistrationTimeInSeconds);
82}
83
84export function passthrough_read() {
85 const response = passthroughRead();
86 check(response, { 'passthrough read status equals 200': (r) => r.status === 200 });
87}
88
halil.cakalfcc81ee2024-07-11 14:54:57 +010089export function passthrough_write() {
90 const response = passthroughWrite();
91 check(response, { 'passthrough write status equals 200': (r) => r.status === 200 });
92}
93
danielhanrahan4e9f68c2024-06-28 13:43:35 +010094export 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
100export 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
106export function handleSummary(data) {
107 return {
108 stdout: makeCustomSummaryReport(data, options),
109 };
110}