import org.onap.cps.spi.model.DataNode
import org.onap.cps.spi.model.DataNodeBuilder
+import org.springframework.util.StopWatch
class CpsPersistencePerfSpecBase extends CpsPersistenceSpecBase {
static def xpathsToAllGrandChildren = []
+ static def PERFORMANCE_RECORD = []
+
+ def stopWatch = new StopWatch()
+
+ def cleanupSpec() {
+ println('#############################################################################')
+ println('## P E R F O R M A N C E T E S T R E S U L T S ##')
+ println('#############################################################################')
+ PERFORMANCE_RECORD.sort().each { println(it) }
+ PERFORMANCE_RECORD.clear()
+ }
+
def createLineage(cpsDataPersistenceService, numberOfChildren, numberOfGrandChildren, createLists) {
xpathsToAllGrandChildren = []
(1..numberOfChildren).each {
}
return nodeCount
}
+
+ def recordAndAssertPerformance(String shortTitle, thresholdInMs, recordedTimeInMs) {
+ def pass = recordedTimeInMs <= thresholdInMs
+ if (shortTitle.length()>40) {
+ shortTitle = shortTitle.substring(0,40)
+ }
+ def record = String.format('%2d.%-40s limit%,7d took %,7d ms ', PERFORMANCE_RECORD.size()+1, shortTitle, thresholdInMs, recordedTimeInMs)
+ record += pass?'PASS':'FAIL'
+ PERFORMANCE_RECORD.add(record)
+ assert recordedTimeInMs <= thresholdInMs
+ return true
+ }
}