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'; |
| 23 | import { NCMP_BASE_URL, getRandomCmHandleId } from './utils.js' |
| 24 | import { searchRequest } from './search-base.js'; |
| 25 | |
| 26 | export const options = { |
| 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', |
| 43 | vus: 5, |
| 44 | duration: '1m', |
| 45 | }, |
| 46 | }, |
| 47 | |
| 48 | thresholds: { |
| 49 | http_req_failed: ['rate==0'], |
| 50 | 'http_req_duration{scenario:passthrough_read}': ['avg <= 2540'], // DMI delay + 40 ms |
| 51 | 'http_req_duration{scenario:id_search_module}': ['avg <= 200'], |
| 52 | 'http_req_duration{scenario:cm_search_module}': ['avg <= 35_000'], |
| 53 | }, |
| 54 | }; |
| 55 | |
| 56 | export function passthrough_read() { |
| 57 | const cmHandleId = getRandomCmHandleId(); |
| 58 | const datastoreName = 'ncmp-datastore%3Apassthrough-operational'; |
| 59 | const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${cmHandleId}/data/ds/${datastoreName}?resourceIdentifier=x&include-descendants=true` |
| 60 | const response = http.get(url); |
| 61 | check(response, { |
| 62 | 'status equals 200': (r) => r.status === 200, |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | export function id_search_module() { |
| 67 | const search_filter = { |
| 68 | "cmHandleQueryParameters": [ |
| 69 | { |
| 70 | "conditionName": "hasAllModules", |
| 71 | "conditionParameters": [ {"moduleName": "ietf-yang-types-1"} ] |
| 72 | } |
| 73 | ] |
| 74 | }; |
| 75 | searchRequest('id-searches', JSON.stringify(search_filter)); |
| 76 | } |
| 77 | |
| 78 | export function cm_search_module() { |
| 79 | const search_filter = { |
| 80 | "cmHandleQueryParameters": [ |
| 81 | { |
| 82 | "conditionName": "hasAllModules", |
| 83 | "conditionParameters": [ {"moduleName": "ietf-yang-types-1"} ] |
| 84 | } |
| 85 | ] |
| 86 | }; |
| 87 | searchRequest('searches', JSON.stringify(search_filter)); |
| 88 | } |