From 0e006004acf07ee044c9a4c258cee5518ffd0988 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Thu, 6 Jun 2024 20:43:21 +0100 Subject: [k6] Refactor k6 tests for CM handle searches A cleanup of the k6 tests to avoid code duplication Issue-ID: CPS-2208 Signed-off-by: danielhanrahan Change-Id: If1e58ee87300cd28ed72b365d9a86e2709dc6c13 --- k6-tests/ncmp/search-base.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'k6-tests/ncmp/search-base.js') diff --git a/k6-tests/ncmp/search-base.js b/k6-tests/ncmp/search-base.js index 19a6a5aa6f..04b644425d 100644 --- a/k6-tests/ncmp/search-base.js +++ b/k6-tests/ncmp/search-base.js @@ -22,8 +22,37 @@ import http from 'k6/http'; import { check } from 'k6'; import { NCMP_BASE_URL, TOTAL_CM_HANDLES } from './utils.js'; -export function searchRequest(searchType, searchFilter) { - const response = http.post(NCMP_BASE_URL + '/ncmp/v1/ch/' + searchType, searchFilter, { +const SEARCH_PARAMETERS_PER_SCENARIO = { + 'no-filter': {}, + 'module': { + 'cmHandleQueryParameters': [ + { + 'conditionName': 'hasAllModules', + 'conditionParameters': [{'moduleName': 'ietf-yang-types-1'}] + } + ] + }, + 'property': { + 'cmHandleQueryParameters': [ + { + 'conditionName': 'hasAllProperties', + 'conditionParameters': [{'Color': 'yellow'}] + } + ] + } +}; + +export function executeCmHandleSearch(scenario) { + executeSearchRequest('searches', scenario); +} + +export function executeCmHandleIdSearch(scenario) { + executeSearchRequest('id-searches', scenario); +} + +function executeSearchRequest(searchType, scenario) { + const searchParameter = JSON.stringify(SEARCH_PARAMETERS_PER_SCENARIO[scenario]); + const response = http.post(NCMP_BASE_URL + '/ncmp/v1/ch/' + searchType, searchParameter, { headers: {'Content-Type': 'application/json'}, }); check(response, { -- cgit 1.2.3-korg