diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2024-06-06 20:43:21 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2024-06-06 20:43:21 +0100 |
commit | 0e006004acf07ee044c9a4c258cee5518ffd0988 (patch) | |
tree | bccdc93713c756dbb5327fdd4773bfc6f4fc16ee | |
parent | 43d0451a27311e4154536a66cb22eb4d68a21e7a (diff) |
[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 <daniel.hanrahan@est.tech>
Change-Id: If1e58ee87300cd28ed72b365d9a86e2709dc6c13
-rw-r--r-- | k6-tests/ncmp/10-mixed-load-test.js | 22 | ||||
-rw-r--r-- | k6-tests/ncmp/4-id-search-no-filter.js | 5 | ||||
-rw-r--r-- | k6-tests/ncmp/5-search-no-filter.js | 4 | ||||
-rw-r--r-- | k6-tests/ncmp/6-id-search-public-property.js | 12 | ||||
-rw-r--r-- | k6-tests/ncmp/7-search-public-property.js | 12 | ||||
-rw-r--r-- | k6-tests/ncmp/8-id-search-module.js | 12 | ||||
-rw-r--r-- | k6-tests/ncmp/9-search-module.js | 12 | ||||
-rw-r--r-- | k6-tests/ncmp/search-base.js | 33 |
8 files changed, 46 insertions, 66 deletions
diff --git a/k6-tests/ncmp/10-mixed-load-test.js b/k6-tests/ncmp/10-mixed-load-test.js index 829219b4e5..4bb0297d63 100644 --- a/k6-tests/ncmp/10-mixed-load-test.js +++ b/k6-tests/ncmp/10-mixed-load-test.js @@ -21,7 +21,7 @@ import http from 'k6/http'; import { check } from 'k6'; import { NCMP_BASE_URL, getRandomCmHandleId, makeCustomSummaryReport } from './utils.js' -import { searchRequest } from './search-base.js'; +import { executeCmHandleSearch, executeCmHandleIdSearch } from './search-base.js'; export const options = { scenarios: { @@ -66,27 +66,11 @@ export function passthrough_read() { } export function id_search_module() { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllModules", - "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] - } - ] - }; - searchRequest('id-searches', JSON.stringify(search_filter)); + executeCmHandleIdSearch('module'); } export function cm_search_module() { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllModules", - "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] - } - ] - }; - searchRequest('searches', JSON.stringify(search_filter)); + executeCmHandleSearch('module'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/4-id-search-no-filter.js b/k6-tests/ncmp/4-id-search-no-filter.js index 1c96665c0b..ed8d77f2e7 100644 --- a/k6-tests/ncmp/4-id-search-no-filter.js +++ b/k6-tests/ncmp/4-id-search-no-filter.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleIdSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -30,9 +30,8 @@ export const options = { }, }; -// The function that defines VU logic. export default function () { - searchRequest('id-searches', '{}') + executeCmHandleIdSearch('no-filter'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/5-search-no-filter.js b/k6-tests/ncmp/5-search-no-filter.js index 4ef8a57b3b..73fa82787b 100644 --- a/k6-tests/ncmp/5-search-no-filter.js +++ b/k6-tests/ncmp/5-search-no-filter.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -31,7 +31,7 @@ export const options = { }; export default function () { - searchRequest('searches', '{}') + executeCmHandleSearch('no-filter'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/6-id-search-public-property.js b/k6-tests/ncmp/6-id-search-public-property.js index 0c5fcc667d..543ee1a87d 100644 --- a/k6-tests/ncmp/6-id-search-public-property.js +++ b/k6-tests/ncmp/6-id-search-public-property.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleIdSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -31,15 +31,7 @@ export const options = { }; export default function () { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllProperties", - "conditionParameters": [{"Color": "yellow"}, {"Size": "small"}] - } - ] - }; - searchRequest('id-searches', JSON.stringify(search_filter)); + executeCmHandleIdSearch('property'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/7-search-public-property.js b/k6-tests/ncmp/7-search-public-property.js index 6a46a03290..cb39b54d9c 100644 --- a/k6-tests/ncmp/7-search-public-property.js +++ b/k6-tests/ncmp/7-search-public-property.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -31,15 +31,7 @@ export const options = { }; export default function () { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllProperties", - "conditionParameters": [{"Color": "yellow"}, {"Size": "small"}] - } - ] - }; - searchRequest('searches', JSON.stringify(search_filter)); + executeCmHandleSearch('property'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/8-id-search-module.js b/k6-tests/ncmp/8-id-search-module.js index 4c9e03e3f6..d058a1bf14 100644 --- a/k6-tests/ncmp/8-id-search-module.js +++ b/k6-tests/ncmp/8-id-search-module.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleIdSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -31,15 +31,7 @@ export const options = { }; export default function () { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllModules", - "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] - } - ] - }; - searchRequest('id-searches', JSON.stringify(search_filter)); + executeCmHandleIdSearch('module'); } export function handleSummary(data) { diff --git a/k6-tests/ncmp/9-search-module.js b/k6-tests/ncmp/9-search-module.js index 3237e6a822..c6bbb06db1 100644 --- a/k6-tests/ncmp/9-search-module.js +++ b/k6-tests/ncmp/9-search-module.js @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -import { searchRequest } from './search-base.js'; +import { executeCmHandleSearch } from './search-base.js'; import { makeCustomSummaryReport } from "./utils.js"; export const options = { @@ -31,15 +31,7 @@ export const options = { }; export default function () { - const search_filter = { - "cmHandleQueryParameters": [ - { - "conditionName": "hasAllModules", - "conditionParameters": [{"moduleName": "ietf-yang-types-1"}] - } - ] - }; - searchRequest('searches', JSON.stringify(search_filter)); + executeCmHandleSearch('module'); } export function handleSummary(data) { 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, { |