Add memory usage to integration tests [UPDATED]
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / performance / ncmp / CmHandleQueryPerfTest.groovy
index 8732703..02881fe 100644 (file)
 
 package org.onap.cps.integration.performance.ncmp
 
+import org.onap.cps.integration.ResourceMeter
 import java.util.stream.Collectors
-import org.onap.cps.integration.performance.base.NcmpRegistryPerfTestBase
-import org.springframework.dao.DataAccessResourceFailureException
+import org.onap.cps.api.CpsQueryService
+import org.onap.cps.integration.performance.base.NcmpPerfTestBase
 import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
 
-class CmHandleQueryPerfTest extends NcmpRegistryPerfTestBase {
+class CmHandleQueryPerfTest extends NcmpPerfTestBase {
 
-    def objectUnderTest
+    CpsQueryService objectUnderTest
+    ResourceMeter resourceMeter = new ResourceMeter()
 
     def setup() { objectUnderTest = cpsQueryService }
 
     def 'Query CM Handle IDs by a property name and value.'() {
         when: 'a cps-path query on name-value pair is performed (without getting descendants)'
-            stopWatch.start()
+            resourceMeter.start()
             def cpsPath = '//additional-properties[@name="neType" and @value="RadioNode"]/ancestor::cm-handles'
-            def dataNodes = cpsQueryService.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, cpsPath, OMIT_DESCENDANTS)
+            def dataNodes = objectUnderTest.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, cpsPath, OMIT_DESCENDANTS)
         and: 'the ids of the result are extracted and converted to xpath'
             def xpaths = dataNodes.stream().map(dataNode -> "/dmi-registry/cm-handles[@id='${dataNode.leaves.id}']".toString() ).collect(Collectors.toSet())
         and: 'a single get is executed to get all the parent objects and their descendants'
             def result = cpsDataService.getDataNodesForMultipleXpaths(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS)
-            stopWatch.stop()
-            def durationInMillis = stopWatch.getTotalTimeMillis()
-        then: 'the required operations are performed within 3 seconds'
-            recordAndAssertPerformance("CpsPath Registry attributes Query", 3_000, durationInMillis)
+            resourceMeter.stop()
+            def durationInMillis = resourceMeter.getTotalTimeMillis()
+        then: 'the required operations are performed within 1200 ms'
+            recordAndAssertResourceUsage("CpsPath Registry attributes Query", 250, durationInMillis, 150, resourceMeter.getTotalMemoryUsageInMB())
         and: 'all but 1 (other node) are returned'
             result.size() == 999
         and: 'the tree contains all the expected descendants too'
             assert countDataNodesInTree(result) == 5 * 999
     }
 
-    def 'Multiple get limit exceeded: 32,764 (~ 2^15) xpaths.'() {
-        given: 'more than 32,764 xpaths)'
-            def xpaths = (0..32_764).collect(i -> "/size/of/this/path/does/not/matter/for/limit[@id='" + i + "']")
-        when: 'single get is executed to get all the parent objects and their descendants'
-            cpsDataService.getDataNodesForMultipleXpaths(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS)
-        then: 'an exception is thrown'
-            thrown(DataAccessResourceFailureException.class)
-    }
-
 }