blob: 829219b4e53300c3e7fec347c26acc36ab632548 [file] [log] [blame]
danielhanrahanc0b6f3a2024-04-29 16:16:42 +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 http from 'k6/http';
22import { check } from 'k6';
halil.cakal0613fbd2024-05-27 16:06:59 +010023import { NCMP_BASE_URL, getRandomCmHandleId, makeCustomSummaryReport } from './utils.js'
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010024import { searchRequest } from './search-base.js';
25
26export const options = {
halil.cakal0613fbd2024-05-27 16:06:59 +010027 scenarios: {
28 passthrough_read: {
29 executor: 'constant-vus',
30 exec: 'passthrough_read',
31 vus: 10,
32 duration: '1m',
33 },
34 id_search_module: {
35 executor: 'constant-vus',
36 exec: 'id_search_module',
37 vus: 5,
38 duration: '1m',
39 },
40 cm_search_module: {
41 executor: 'constant-vus',
42 exec: 'cm_search_module',
danielhanrahanacff5772024-05-28 18:28:32 +010043 vus: 4,
halil.cakal0613fbd2024-05-27 16:06:59 +010044 duration: '1m',
45 },
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010046 },
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010047
halil.cakal0613fbd2024-05-27 16:06:59 +010048 thresholds: {
49 'http_req_failed{scenario:passthrough_read}': ['rate == 0'],
50 'http_req_failed{scenario:id_search_module}': ['rate == 0'],
51 'http_req_failed{scenario:cm_search_module}': ['rate == 0'],
danielhanrahanacff5772024-05-28 18:28:32 +010052 'http_req_duration{scenario:passthrough_read}': ['avg <= 2600'], // DMI delay + 100 ms
53 'http_req_duration{scenario:id_search_module}': ['avg <= 500'],
54 'http_req_duration{scenario:cm_search_module}': ['avg <= 30000'],
halil.cakal0613fbd2024-05-27 16:06:59 +010055 },
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010056};
57
58export function passthrough_read() {
59 const cmHandleId = getRandomCmHandleId();
60 const datastoreName = 'ncmp-datastore%3Apassthrough-operational';
61 const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${cmHandleId}/data/ds/${datastoreName}?resourceIdentifier=x&include-descendants=true`
62 const response = http.get(url);
63 check(response, {
64 'status equals 200': (r) => r.status === 200,
65 });
66}
67
68export function id_search_module() {
69 const search_filter = {
70 "cmHandleQueryParameters": [
71 {
72 "conditionName": "hasAllModules",
halil.cakal0613fbd2024-05-27 16:06:59 +010073 "conditionParameters": [{"moduleName": "ietf-yang-types-1"}]
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010074 }
75 ]
76 };
77 searchRequest('id-searches', JSON.stringify(search_filter));
78}
79
80export function cm_search_module() {
81 const search_filter = {
82 "cmHandleQueryParameters": [
83 {
84 "conditionName": "hasAllModules",
halil.cakal0613fbd2024-05-27 16:06:59 +010085 "conditionParameters": [{"moduleName": "ietf-yang-types-1"}]
danielhanrahanc0b6f3a2024-04-29 16:16:42 +010086 }
87 ]
88 };
89 searchRequest('searches', JSON.stringify(search_filter));
90}
halil.cakal0613fbd2024-05-27 16:06:59 +010091
92export function handleSummary(data) {
93 return {
94 stdout: makeCustomSummaryReport(data, options),
95 };
96}