danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +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 http from 'k6/http'; |
| 22 | import { check } from 'k6'; |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 23 | import { NCMP_BASE_URL, getRandomCmHandleId, makeCustomSummaryReport } from './utils.js' |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 24 | import { searchRequest } from './search-base.js'; |
| 25 | |
| 26 | export const options = { |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 27 | 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', |
danielhanrahan | acff577 | 2024-05-28 18:28:32 +0100 | [diff] [blame^] | 43 | vus: 4, |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 44 | duration: '1m', |
| 45 | }, |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 46 | }, |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 47 | |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 48 | 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'], |
danielhanrahan | acff577 | 2024-05-28 18:28:32 +0100 | [diff] [blame^] | 52 | '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.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 55 | }, |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | export 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 | |
| 68 | export function id_search_module() { |
| 69 | const search_filter = { |
| 70 | "cmHandleQueryParameters": [ |
| 71 | { |
| 72 | "conditionName": "hasAllModules", |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 73 | "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 74 | } |
| 75 | ] |
| 76 | }; |
| 77 | searchRequest('id-searches', JSON.stringify(search_filter)); |
| 78 | } |
| 79 | |
| 80 | export function cm_search_module() { |
| 81 | const search_filter = { |
| 82 | "cmHandleQueryParameters": [ |
| 83 | { |
| 84 | "conditionName": "hasAllModules", |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 85 | "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] |
danielhanrahan | c0b6f3a | 2024-04-29 16:16:42 +0100 | [diff] [blame] | 86 | } |
| 87 | ] |
| 88 | }; |
| 89 | searchRequest('searches', JSON.stringify(search_filter)); |
| 90 | } |
halil.cakal | 0613fbd | 2024-05-27 16:06:59 +0100 | [diff] [blame] | 91 | |
| 92 | export function handleSummary(data) { |
| 93 | return { |
| 94 | stdout: makeCustomSummaryReport(data, options), |
| 95 | }; |
| 96 | } |