diff options
Diffstat (limited to 'integration-test/src/test/groovy/org/onap/cps/integration/performance/base')
3 files changed, 20 insertions, 13 deletions
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy index 5fd27476c..e7a847e13 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy @@ -20,6 +20,7 @@ package org.onap.cps.integration.performance.base +import org.onap.cps.integration.ResourceMeter import org.onap.cps.rest.utils.MultipartFileUtil import org.onap.cps.spi.FetchDescendantsOption import org.springframework.web.multipart.MultipartFile @@ -33,6 +34,8 @@ class CpsPerfTestBase extends PerfTestBase { static final def OPENROADM_DEVICES_PER_ANCHOR = 1000 static final def OPENROADM_DATANODES_PER_DEVICE = 86 + ResourceMeter resourceMeter = new ResourceMeter() + def printTitle() { println('## C P S P E R F O R M A N C E T E S T R E S U L T S ##') } @@ -62,11 +65,11 @@ class CpsPerfTestBase extends PerfTestBase { def addOpenRoadData() { def data = generateOpenRoadData(OPENROADM_DEVICES_PER_ANCHOR) - stopWatch.start() + resourceMeter.start() addAnchorsWithData(OPENROADM_ANCHORS, CPS_PERFORMANCE_TEST_DATASPACE, LARGE_SCHEMA_SET, 'openroadm', data) - stopWatch.stop() - def durationInMillis = stopWatch.getTotalTimeMillis() - recordAndAssertPerformance('Creating openroadm anchors with large data tree', TimeUnit.SECONDS.toMillis(200), durationInMillis) + resourceMeter.stop() + def durationInMillis = resourceMeter.getTotalTimeMillis() + recordAndAssertResourceUsage('Creating openroadm anchors with large data tree', TimeUnit.SECONDS.toMillis(200), durationInMillis, 200, resourceMeter.getTotalMemoryUsageInMB()) } def generateOpenRoadData(numberOfNodes) { @@ -78,13 +81,15 @@ class CpsPerfTestBase extends PerfTestBase { def 'Warm the database'() { when: 'dummy get data nodes runs so that populating the DB does not get included in other test timings' - stopWatch.start() + resourceMeter.start() def result = cpsDataService.getDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm1', '/', FetchDescendantsOption.OMIT_DESCENDANTS) assert countDataNodesInTree(result) == 1 - stopWatch.stop() - def durationInMillis = stopWatch.getTotalTimeMillis() - then: 'all data is read within expected time' - recordAndAssertPerformance("Warming database", TimeUnit.SECONDS.toMillis(200), durationInMillis) + resourceMeter.stop() + def durationInMillis = resourceMeter.getTotalTimeMillis() + then: 'memory used is within #peakMemoryUsage' + assert resourceMeter.getTotalMemoryUsageInMB() <= 30 + and: 'all data is read within expected time' + recordAndAssertResourceUsage("Warming database", TimeUnit.SECONDS.toMillis(200), durationInMillis, 200, resourceMeter.getTotalMemoryUsageInMB()) } } 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 f5d7c5e15..7bacf1d6e 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 @@ -21,6 +21,7 @@ package org.onap.cps.integration.performance.base import java.time.OffsetDateTime +import org.onap.cps.integration.ResourceMeter class NcmpPerfTestBase extends PerfTestBase { @@ -36,6 +37,8 @@ class NcmpPerfTestBase extends PerfTestBase { def numberOfFiltersPerCmHandle = 10 def numberOfCmHandlesPerCmDataSubscription = 200 + ResourceMeter resourceMeter = new ResourceMeter() + // SHORT versions for easier debugging // def subscriberIdPrefix = 'sub' // def xpathPrefix = 'f' diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy index b6ceb91b5..8e5fe0619 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/base/PerfTestBase.groovy @@ -28,8 +28,6 @@ abstract class PerfTestBase extends CpsIntegrationSpecBase { static def LARGE_SCHEMA_SET = 'largeSchemaSet' static def PERFORMANCE_RECORD = [] - def stopWatch = new StopWatch() - def cleanupSpec() { println('#############################################################################') printTitle() @@ -56,15 +54,16 @@ abstract class PerfTestBase extends CpsIntegrationSpecBase { abstract def createInitialData() - def recordAndAssertPerformance(String shortTitle, thresholdInMs, recordedTimeInMs) { + def recordAndAssertResourceUsage(String shortTitle, thresholdInMs, recordedTimeInMs, memoryLimit, memoryUsageInMB) { def pass = recordedTimeInMs <= thresholdInMs if (shortTitle.length() > 40) { shortTitle = shortTitle.substring(0, 40) } - def record = String.format('%2d.%-40s limit%,8d took %,8d ms ', PERFORMANCE_RECORD.size() + 1, shortTitle, thresholdInMs, recordedTimeInMs) + def record = String.format('%2d.%-40s limit%,8d took %,8d ms %,8.2f MB used ', PERFORMANCE_RECORD.size() + 1, shortTitle, thresholdInMs, recordedTimeInMs, memoryUsageInMB) record += pass ? 'PASS' : 'FAIL' PERFORMANCE_RECORD.add(record) assert recordedTimeInMs <= thresholdInMs + assert memoryUsageInMB <= memoryLimit return true } } |