From: ToineSiebelink Date: Tue, 20 May 2025 08:50:41 +0000 (+0100) Subject: Make Groovy Performance Test Stable X-Git-Tag: 3.6.3~11 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=6c17c31956445465f9ca83893650aca85df7907d;p=cps.git Make Groovy Performance Test Stable - Tweak/correct more graphs - Fix functional issue in test for alt-id lookup Issue-ID: CPS-2743 Change-Id: I6f7a8d7cdac5b32a0a988fdac88c33b36f621499 Signed-off-by: ToineSiebelink --- diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy index 857488cfa7..fbfa85f7f7 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/NcmpPerfTestBase.groovy @@ -82,7 +82,7 @@ class NcmpPerfTestBase extends PerfTestBase { def cmHandleJsonTemplate = readResourceDataFile('inventory/cmHandleTemplate.json') def batchSize = 100 for (def i = 0; i < TOTAL_CM_HANDLES; i += batchSize) { - def data = '{ "cm-handles": [' + (1..batchSize).collect { cmHandleJsonTemplate.replace('CM_HANDLE_ID_HERE', (it + i).toString()) }.join(',') + ']}' + def data = '{ "cm-handles": [' + (1..batchSize).collect { cmHandleJsonTemplate.replace('CM_HANDLE_ID_POSTFIX', (it + i).toString()) }.join(',') + ']}' cpsDataService.saveListElements(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, REGISTRY_PARENT, data, now, ContentType.JSON) } } @@ -92,8 +92,8 @@ class NcmpPerfTestBase extends PerfTestBase { def batchSize = 10 for (def i = 0; i < TOTAL_CM_HANDLES; i += batchSize) { def data = '{ "cm-handles": [' + (1..batchSize).collect { - cmHandleWithAlternateIdTemplate.replace('CM_HANDLE_ID_HERE', (it + i).toString()) - .replace('ALTERNATE_ID_AS_PATH', (it + i).toString()) + cmHandleWithAlternateIdTemplate.replace('CM_HANDLE_ID_POSTFIX', (it + i).toString()) + .replace('ALTERNATE_ID_POSTFIX', (it + i).toString()) }.join(',') + ']}' cpsDataService.saveListElements(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, REGISTRY_PARENT, data, now, ContentType.JSON) } diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy index 5d7b58cf54..94e809eda2 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeletePerfTest.groovy @@ -71,7 +71,7 @@ class DeletePerfTest extends CpsPerfTestBase { resourceMeter.stop() def deleteDurationInSeconds = resourceMeter.getTotalTimeInSeconds() then: 'delete duration is within expected time and memory used is within limit' - recordAndAssertResourceUsage('Batch delete 100 containers', 0.7, deleteDurationInSeconds, 2, resourceMeter.getTotalMemoryUsageInMB()) + recordAndAssertResourceUsage('Batch delete 100 containers', 0.65, deleteDurationInSeconds, 2, resourceMeter.getTotalMemoryUsageInMB()) } def 'Delete 100 list elements'() { @@ -175,7 +175,7 @@ class DeletePerfTest extends CpsPerfTestBase { resourceMeter.stop() def deleteDurationInSeconds = resourceMeter.getTotalTimeInSeconds() then: 'delete duration is within expected time and memory used is within limit' - recordAndAssertResourceUsage('Batch delete 100 non-existing', 2.6, deleteDurationInSeconds, 3, resourceMeter.getTotalMemoryUsageInMB()) + recordAndAssertResourceUsage('Batch delete 100 non-existing', 2, deleteDurationInSeconds, 3, resourceMeter.getTotalMemoryUsageInMB()) } def 'Clean up test data'() { diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy index 3d6437ffdb..ba2c9cab2f 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy @@ -60,7 +60,7 @@ class GetPerfTest extends CpsPerfTestBase { then: 'requested nodes and their descendants are returned' assert countDataNodesInTree(result) == OPENROADM_DEVICES_PER_ANCHOR * OPENROADM_DATANODES_PER_DEVICE and: 'all data is read within expected time and memory used is within limit' - recordAndAssertResourceUsage("Read datatrees for multiple xpaths", 0.55, durationInSeconds, 300, resourceMeter.getTotalMemoryUsageInMB(),3) + recordAndAssertResourceUsage("Read datatrees for multiple xpaths", 2.1, durationInSeconds, 300, resourceMeter.getTotalMemoryUsageInMB(),3) } def 'Read for multiple xpaths to non-existing datanodes'() { diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy index 9d09439b04..183c634abc 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy @@ -79,10 +79,10 @@ class UpdatePerfTest extends CpsPerfTestBase { recordAndAssertResourceUsage(scenario, expectedTime, resourceMeter.getTotalTimeInSeconds(), memoryLimit, resourceMeter.getTotalMemoryUsageInMB()) where: scenario | totalNodes | startId | changeLeaves || expectedTime | memoryLimit - 'Replace 0 nodes with 100' | 100 | 1 | false || 3.0 | 200 - 'Replace 100 using same data' | 100 | 1 | false || 2.3 | 200 - 'Replace 100 with new leaf values' | 100 | 1 | true || 2.3 | 200 - 'Replace 100 with 100 new nodes' | 100 | 101 | false || 13.85 | 200 + 'Replace 0 nodes with 100' | 100 | 1 | false || 2.85 | 200 + 'Replace 100 using same data' | 100 | 1 | false || 2.0 | 200 + 'Replace 100 with new leaf values' | 100 | 1 | true || 2.0 | 200 + 'Replace 100 with 100 new nodes' | 100 | 101 | false || 6.2 | 200 'Replace 50 existing and 50 new' | 100 | 151 | true || 4.2 | 200 'Replace 100 nodes with 0' | 0 | 1 | false || 3.5 | 200 } @@ -106,8 +106,8 @@ class UpdatePerfTest extends CpsPerfTestBase { where: scenario | totalNodes | startId | changeLeaves || expectedTime | memoryLimit 'Replace list of 0 with 100' | 100 | 1 | false || 3.0 | 200 - 'Replace list of 100 using same data' | 100 | 1 | false || 3.32 | 200 - 'Replace list of 100 with new leaf values' | 100 | 1 | true || 4.2 | 200 + 'Replace list of 100 using same data' | 100 | 1 | false || 2.0 | 200 + 'Replace list of 100 with new leaf values' | 100 | 1 | true || 2.3 | 200 'Replace list with 100 new nodes' | 100 | 101 | false || 6.1 | 200 'Replace list with 50 existing and 50 new' | 100 | 151 | true || 4.0 | 200 'Replace list of 100 nodes with 1' | 1 | 1 | false || 3.34 | 200 diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy index 27ec66f30d..2f73023f07 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleQueryPerfTest.groovy @@ -31,8 +31,6 @@ import static org.onap.cps.api.parameters.FetchDescendantsOption.OMIT_DESCENDANT class CmHandleQueryPerfTest extends NcmpPerfTestBase { - static def MILLISECONDS = 0.001 - CpsQueryService objectUnderTest ResourceMeter resourceMeter = new ResourceMeter() @@ -40,11 +38,11 @@ class CmHandleQueryPerfTest extends NcmpPerfTestBase { def 'JVM warmup.'() { when: 'the JVM is warmed up' - def iterations = 2500 // set this to 15000 for very accurate results (but test takes much longer) + def iterations = TOTAL_CM_HANDLES * 0.1 resourceMeter.start() (1..iterations).forEach { - cpsDataService.getDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, '/dmi-registry/cm-handles[@id="cm-' + it + '"]', OMIT_DESCENDANTS) - objectUnderTest.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, '/dmi-registry/cm-handles[@alternate-id="alt=' + it + '"]', OMIT_DESCENDANTS) + cpsDataService.getDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, "/dmi-registry/cm-handles[@id='cm-${it}']", OMIT_DESCENDANTS) + objectUnderTest.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, "/dmi-registry/cm-handles[@alternate-id='alt-${it}']", OMIT_DESCENDANTS) } resourceMeter.stop() then: 'resource usage is as expected' @@ -63,7 +61,7 @@ class CmHandleQueryPerfTest extends NcmpPerfTestBase { resourceMeter.stop() def durationInSeconds = resourceMeter.getTotalTimeInSeconds() then: 'the required operations are performed within required time' - recordAndAssertResourceUsage("CpsPath Registry attributes Query", 2.4, durationInSeconds, 400, resourceMeter.getTotalMemoryUsageInMB()) + recordAndAssertResourceUsage("CpsPath Registry attributes Query", 3, durationInSeconds, 400, resourceMeter.getTotalMemoryUsageInMB()) and: 'all nodes are returned' result.size() == TOTAL_CM_HANDLES and: 'the tree contains all the expected descendants too' @@ -83,7 +81,7 @@ class CmHandleQueryPerfTest extends NcmpPerfTestBase { assert count == 100 and: 'average performance is as expected' def averageResponseTime = resourceMeter.totalTimeInSeconds / 100 - recordAndAssertResourceUsage('Look up CM-handle by id', 0.003, averageResponseTime, 15, resourceMeter.totalMemoryUsageInMB) + recordAndAssertResourceUsage('Look up CM-handle by id', 0.009, averageResponseTime, 15, resourceMeter.totalMemoryUsageInMB) } def 'CM-handle is looked up by alternate-id.'() { @@ -92,19 +90,19 @@ class CmHandleQueryPerfTest extends NcmpPerfTestBase { resourceMeter.start() (1..1000).each { count += cpsQueryService.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, - '/dmi-registry/cm-handles[@alternate-id="alt=/a/b/c/d-' + it + '"]', OMIT_DESCENDANTS).size() + "/dmi-registry/cm-handles[@alternate-id='alt-${it}']", OMIT_DESCENDANTS).size() } resourceMeter.stop() then: assert count == 1000 and: 'average performance is as expected' def averageResponseTime = resourceMeter.totalTimeInSeconds / 1000 - recordAndAssertResourceUsage('Look up CM-handle by alternate-id', 0.001, averageResponseTime, 15, resourceMeter.totalMemoryUsageInMB) + recordAndAssertResourceUsage('Look up CM-handle by alternate-id', 0.02, averageResponseTime, 15, resourceMeter.totalMemoryUsageInMB) } def 'A batch of CM-handles is looked up by alternate-id.'() { given: 'a CPS Path Query to look up 100 alternate-ids in a single operation' - def cpsPathQuery = '/dmi-registry/cm-handles[' + (1..100).collect { "@alternate-id='alt=${it}'" }.join(' or ') + ']' + def cpsPathQuery = '/dmi-registry/cm-handles[' + (1..100).collect { "@alternate-id='alt-${it}'" }.join(' or ') + ']' when: 'CM-handles are looked up by alternate-ids in a single query' resourceMeter.start() def count = cpsQueryService.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, cpsPathQuery, OMIT_DESCENDANTS).size() @@ -113,11 +111,7 @@ class CmHandleQueryPerfTest extends NcmpPerfTestBase { assert count == 100 then: 'average performance is as expected' def averageResponseTime = resourceMeter.totalTimeInSeconds / 100 - recordAndAssertResourceUsage('Batch look up CM-handle by alternate-id', - expectedAverageResponseTime, averageResponseTime, - 15, resourceMeter.totalMemoryUsageInMB) - where: - expectedAverageResponseTime = 4 * MILLISECONDS + recordAndAssertResourceUsage('Batch look up CM-handle by alternate-id', 0.004, averageResponseTime, 15, resourceMeter.totalMemoryUsageInMB) } def 'Find any CM-handle given moduleSetTag when there are 20K READY handles with same moduleSetTag.'() { diff --git a/integration-test/src/test/resources/data/inventory/cmHandleTemplate.json b/integration-test/src/test/resources/data/inventory/cmHandleTemplate.json index 6577f4e560..7953d1a6ec 100644 --- a/integration-test/src/test/resources/data/inventory/cmHandleTemplate.json +++ b/integration-test/src/test/resources/data/inventory/cmHandleTemplate.json @@ -1,6 +1,6 @@ { - "id": "cm-CM_HANDLE_ID_HERE", - "alternate-id": "alt-CM_HANDLE_ID_HERE", + "id": "cm-CM_HANDLE_ID_POSTFIX", + "alternate-id": "alt-CM_HANDLE_ID_POSTFIX", "module-set-tag": "my-module-set-tag", "dmi-service-name": "http://ncmp-dmi-plugin-stub:8080", "dmi-data-service-name": "", diff --git a/integration-test/src/test/resources/data/inventory/cmHandleWithAlternateIdTemplate.json b/integration-test/src/test/resources/data/inventory/cmHandleWithAlternateIdTemplate.json index 88446c4a0f..60d28f15d4 100644 --- a/integration-test/src/test/resources/data/inventory/cmHandleWithAlternateIdTemplate.json +++ b/integration-test/src/test/resources/data/inventory/cmHandleWithAlternateIdTemplate.json @@ -1,6 +1,6 @@ { - "id": "cm-handle-CM_HANDLE_ID_HERE", - "alternate-id": "/a/b/c/d-ALTERNATE_ID_AS_PATH", + "id": "cm-handle-CM_HANDLE_ID_POSTFIX", + "alternate-id": "/a/b/c/d-ALTERNATE_ID_POSTFIX", "module-set-tag": "my-module-set-tag", "dmi-service-name": "http://ncmp-dmi-plugin-stub:8080", "dmi-data-service-name": "", @@ -21,4 +21,4 @@ } } } -} \ No newline at end of file +}