Add performance tests for updateDataLeaves 46/135046/3
authordanielhanrahan <daniel.hanrahan@est.tech>
Wed, 21 Jun 2023 11:22:46 +0000 (12:22 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Wed, 21 Jun 2023 12:37:16 +0000 (13:37 +0100)
Issue-ID: CPS-1675
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I4dcd2ff0d0f6c3acf7373357da0ef7217a691573

integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy

index a02d21c..b3c8841 100644 (file)
@@ -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)
+    }
+
 }