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)
}
}
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)
}
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'() {
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'() {
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'() {
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
}
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
class CmHandleQueryPerfTest extends NcmpPerfTestBase {
- static def MILLISECONDS = 0.001
-
CpsQueryService objectUnderTest
ResourceMeter resourceMeter = new ResourceMeter()
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'
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'
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.'() {
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()
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.'() {
{
- "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": "",
{
- "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": "",
}
}
}
-}
\ No newline at end of file
+}