Adjust timing for Delta Report performance test and make OpenROADM test data determin... 09/142809/4
authorArpit Singh <AS00745003@techmahindra.com>
Thu, 18 Dec 2025 05:21:11 +0000 (10:51 +0530)
committerArpit Singh <AS00745003@techmahindra.com>
Fri, 19 Dec 2025 07:12:40 +0000 (12:42 +0530)
- Adjusted timing for Delta Report performance test to account for changes
  observed after isolating anchors within DeltaPerfTest.
- Change applies to Delta between 2 anchors test
- Modified approach for creating modified OpenROADM test data:
  - Replaced random generation with deterministic logic
  - Ensures consistent and reliable performance test results

Issue-ID: CPS-3101
Change-Id: Ic64e242d400915a958b9817407a3b0fa991b86a7
Signed-off-by: Arpit Singh <AS00745003@techmahindra.com>
integration-test/src/test/groovy/org/onap/cps/integration/performance/base/CpsPerfTestBase.groovy
integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/DeltaPerfTest.groovy

index e5bf7f2..990d8ca 100644 (file)
@@ -21,8 +21,7 @@
 
 package org.onap.cps.integration.performance.base
 
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
+
 import org.onap.cps.api.parameters.FetchDescendantsOption
 import org.onap.cps.integration.ResourceMeter
 import org.onap.cps.rest.utils.MultipartFileUtil
@@ -88,48 +87,4 @@ class CpsPerfTestBase extends PerfTestBase {
             (1..numberOfNodes).collect { innerNode.replace('NODE_ID_HERE', it.toString()) }.join(',') +
             ']}}'
     }
-
-    def generateModifiedOpenRoadData(numberOfNodes, removeNodesCount, addNodesCount, updateCount) {
-        def innerNode = readResourceDataFile('openroadm/innerNode.json')
-        def allIndices = (0..<numberOfNodes).toList()
-        def nodeIdsAfterRemove = removeNodes(allIndices, removeNodesCount)
-        def newNodeIds = addNodes(nodeIdsAfterRemove, addNodesCount)
-        def nodeIds = (nodeIdsAfterRemove + newNodeIds).collect {
-            innerNode.replace('NODE_ID_HERE', it.toString())
-        }
-        def updatedNodes = updateNodes(nodeIds, innerNode, updateCount)
-        return '{ "openroadm-devices": { "openroadm-device": [' +
-            updatedNodes.collect {
-                it.toString()
-            }.join(',') +
-            ']}}'
-    }
-
-    def removeNodes(allIndice, removeNodesCount) {
-        def indicesToRemove = allIndice.findAll{
-            it % 2 == 0
-        }.take(removeNodesCount)
-        return (allIndice - indicesToRemove).collect { it + 1 }
-    }
-
-    def addNodes(nodeIds, addNodesCount) {
-        def maxNodeId = nodeIds ? nodeIds.max() : 0
-        return ((maxNodeId + 1)..(maxNodeId + addNodesCount))
-    }
-
-    def updateNodes(nodeIds, innerNode, updateCount) {
-        def slurper = new JsonSlurper()
-        nodeIds.withIndex().collect { data, idx ->
-            def jsonNode = slurper.parseText(data)
-            if (idx < updateCount) {
-                jsonNode['status'] = 'fail'
-                def childNode = jsonNode['org-openroadm-device']['degree'][0]
-                if (childNode) {
-                    childNode['max-wavelengths'] += 100
-                }
-            }
-            return JsonOutput.toJson(jsonNode)
-        }
-    }
-
 }
index 5a25552..1a2c017 100644 (file)
@@ -74,7 +74,7 @@ class DeltaPerfTest extends CpsPerfTestBase{
             scenario             | xpath                                                             | fetchDescendantsOption  || expectedDuration
             'no descendants'     | '/openroadm-devices/openroadm-device[@device-id=\'C201-7-1A-1\']' | OMIT_DESCENDANTS        || 2.0
             'direct descendants' | '/'                                                               | DIRECT_CHILDREN_ONLY    || 3.0
-            'all descendants'    | '/'                                                               | INCLUDE_ALL_DESCENDANTS || 18.0
+            'all descendants'    | '/'                                                               | INCLUDE_ALL_DESCENDANTS || 23.0
     }
 
     @Ignore
@@ -141,14 +141,35 @@ class DeltaPerfTest extends CpsPerfTestBase{
             recordAndAssertResourceUsage('CPS:Apply delta report to an anchor', 20.0, durationInSeconds, resourceMeter.getTotalMemoryUsageInMB())
     }
     
-    def 'Clean up test data'() {
-        when: 'anchor is deleted'
-            def anchorNames = ['source-anchor1', 'target-anchor1']
-            resourceMeter.start()
-            cpsAnchorService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames)
-            resourceMeter.stop()
-            def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
-        then: 'delete duration is below accepted margin of the expected average'
-            recordAndAssertResourceUsage('CPS: Delta Report test cleanup', 5, durationInSeconds, resourceMeter.getTotalMemoryUsageInMB())
+    def 'Clean up for CPS Delta API'() {
+        cleanup: 'test anchors and data nodes'
+            def anchors = ['source-anchor1', 'target-anchor1']
+            cpsAnchorService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchors)
+    }
+
+    def generateModifiedOpenRoadData(numberOfNodes, removeNodesCount, addNodesCount, updateCount) {
+        def nodeIds = (1..numberOfNodes).toList()
+        def nodeIdsAfterRemove = nodeIds.drop(removeNodesCount)
+        def maxNodeId = nodeIdsAfterRemove.isEmpty() ? 1 : (nodeIdsAfterRemove.max() + 1)
+        def newNodeIds = (maxNodeId..<(maxNodeId + addNodesCount)).toList()
+        def finalNodeIds = nodeIdsAfterRemove + newNodeIds
+        def updatedNodes = updateNodes(finalNodeIds, updateCount)
+        return '{ "openroadm-devices": { "openroadm-device": [' + updatedNodes.join(',') + ']}}'
+    }
+
+    def updateNodes(List<Integer> nodeIds, int updateCount) {
+        nodeIds.withIndex().collect { id, idx ->
+            def changeLeaves = (idx < updateCount)
+            makeInnerNodeJson(id as int, changeLeaves)
+        }
+    }
+
+    def makeInnerNodeJson(int nodeId, boolean changeLeaf) {
+        def innerNodeJson = readResourceDataFile('openroadm/innerNode.json')
+        def nodeJson = innerNodeJson.replace('NODE_ID_HERE', nodeId.toString())
+        if (changeLeaf) {
+            nodeJson = nodeJson.replace('"status": "success"', '"status": "fail"')
+        }
+        return nodeJson
     }
 }