From 765de151f09345e96fac3e3254071718289b8359 Mon Sep 17 00:00:00 2001 From: danielhanrahan Date: Wed, 21 Jun 2023 12:22:46 +0100 Subject: [PATCH] Add performance tests for updateDataLeaves Issue-ID: CPS-1675 Signed-off-by: danielhanrahan Change-Id: I4dcd2ff0d0f6c3acf7373357da0ef7217a691573 --- .../performance/cps/UpdatePerfTest.groovy | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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 a02d21c41..b3c884127 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 @@ -27,6 +27,7 @@ import org.onap.cps.integration.performance.base.CpsPerfTestBase class UpdatePerfTest extends CpsPerfTestBase { CpsDataService objectUnderTest + def now = OffsetDateTime.now() def setup() { objectUnderTest = cpsDataService } @@ -36,7 +37,7 @@ class UpdatePerfTest extends CpsPerfTestBase { def jsonData = readResourceDataFile('openroadm/innerNode.json').replace('NODE_ID_HERE', '10') when: 'the fragment entities are updated by the data nodes' stopWatch.start() - objectUnderTest.updateDataNodeAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm1', parentNodeXpath, jsonData, OffsetDateTime.now()) + objectUnderTest.updateDataNodeAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm1', parentNodeXpath, jsonData, now) stopWatch.stop() def updateDurationInMillis = stopWatch.getTotalTimeMillis() then: 'update duration is under 1000 milliseconds' @@ -52,11 +53,39 @@ class UpdatePerfTest extends CpsPerfTestBase { ]} when: 'the fragment entities are updated by the data nodes' stopWatch.start() - objectUnderTest.updateDataNodesAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm2', nodesJsonData, OffsetDateTime.now()) + objectUnderTest.updateDataNodesAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm2', nodesJsonData, now) stopWatch.stop() def updateDurationInMillis = stopWatch.getTotalTimeMillis() then: 'update duration is under 5000 milliseconds' recordAndAssertPerformance('Update 10 data nodes', 4000, updateDurationInMillis) } + def 'Update leaves for 1 data node'() { + given: 'Updated json for openroadm data' + def jsonDataUpdated = "{'openroadm-device':{'device-id':'C201-7-1A-10','status':'fail','ne-state':'jeopardy'}}" + def jsonDataOriginal = "{'openroadm-device':{'device-id':'C201-7-1A-10','status':'success','ne-state':'inservice'}}" + when: 'update is performed for leaves' + stopWatch.start() + objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm3', "/openroadm-devices", jsonDataUpdated, now) + objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm3', "/openroadm-devices", jsonDataOriginal, now) + stopWatch.stop() + def updateDurationInMillis = stopWatch.getTotalTimeMillis() + then: 'update duration is under 750 milliseconds' + recordAndAssertPerformance('Update leaves for 1 data node', 750, updateDurationInMillis) + } + + def 'Batch update leaves for 50 data nodes'() { + given: 'Updated json for openroadm data' + def jsonDataUpdated = "{'openroadm-device':[" + (1..50).collect { "{'device-id':'C201-7-1A-" + it + "','status':'fail','ne-state':'jeopardy'}" }.join(",") + "]}" + def jsonDataOriginal = "{'openroadm-device':[" + (1..50).collect { "{'device-id':'C201-7-1A-" + it + "','status':'success','ne-state':'inservice'}" }.join(",") + "]}" + when: 'update is performed for leaves' + stopWatch.start() + objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm4', "/openroadm-devices", jsonDataUpdated, now) + objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm4', "/openroadm-devices", jsonDataOriginal, now) + stopWatch.stop() + def updateDurationInMillis = stopWatch.getTotalTimeMillis() + then: 'update duration is under 3500 milliseconds' + recordAndAssertPerformance('Batch update leaves for 50 data nodes', 3500, updateDurationInMillis) + } + } -- 2.16.6