Merge "Node API - GET Method performance issue (disable sql logging)"
diff --git a/checkstyle/pom.xml b/checkstyle/pom.xml
index 9a38968..dd308e2 100644
--- a/checkstyle/pom.xml
+++ b/checkstyle/pom.xml
@@ -26,7 +26,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.onap.cps</groupId>
     <artifactId>checkstyle</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
 
     <profiles>
         <profile>
diff --git a/cps-application/pom.xml b/cps-application/pom.xml
index 20bfb0d..a4d3cbd 100755
--- a/cps-application/pom.xml
+++ b/cps-application/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-bom/pom.xml b/cps-bom/pom.xml
index e80e6b4..004c31e 100644
--- a/cps-bom/pom.xml
+++ b/cps-bom/pom.xml
@@ -25,7 +25,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.onap.cps</groupId>
     <artifactId>cps-bom</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <description>This artifact contains dependencyManagement declarations of all published CPS components.</description>
diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml
index a3d42dd..e04ff02 100755
--- a/cps-dependencies/pom.xml
+++ b/cps-dependencies/pom.xml
@@ -27,7 +27,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.onap.cps</groupId>
     <artifactId>cps-dependencies</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>${project.groupId}:${project.artifactId}</name>
diff --git a/cps-events/pom.xml b/cps-events/pom.xml
index 39f8e49..6cbb7eb 100644
--- a/cps-events/pom.xml
+++ b/cps-events/pom.xml
@@ -24,7 +24,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-ncmp-events/pom.xml b/cps-ncmp-events/pom.xml
index 4658894..193f5d0 100644
--- a/cps-ncmp-events/pom.xml
+++ b/cps-ncmp-events/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-ncmp-rest-stub/pom.xml b/cps-ncmp-rest-stub/pom.xml
index 2a4979a..a1711b5 100644
--- a/cps-ncmp-rest-stub/pom.xml
+++ b/cps-ncmp-rest-stub/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml
index a4c44ba..8473674 100644
--- a/cps-ncmp-rest/pom.xml
+++ b/cps-ncmp-rest/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml
index 6a9d948..0f5a234 100644
--- a/cps-ncmp-service/pom.xml
+++ b/cps-ncmp-service/pom.xml
@@ -27,7 +27,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml
index 8739e2c..a29d624 100755
--- a/cps-parent/pom.xml
+++ b/cps-parent/pom.xml
@@ -32,7 +32,7 @@
 
     <groupId>org.onap.cps</groupId>
     <artifactId>cps-parent</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <properties>
diff --git a/cps-path-parser/pom.xml b/cps-path-parser/pom.xml
index ffac3b0..dce9ace 100644
--- a/cps-path-parser/pom.xml
+++ b/cps-path-parser/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml
index 37b3e46..f42aaaa 100755
--- a/cps-rest/pom.xml
+++ b/cps-rest/pom.xml
@@ -28,7 +28,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
 
diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml
index 5cdbf90..824a8d9 100644
--- a/cps-ri/pom.xml
+++ b/cps-ri/pom.xml
@@ -26,7 +26,7 @@
     <parent>

         <groupId>org.onap.cps</groupId>

         <artifactId>cps-parent</artifactId>

-        <version>3.1.5-SNAPSHOT</version>

+        <version>3.2.0-SNAPSHOT</version>

         <relativePath>../cps-parent/pom.xml</relativePath>

     </parent>

 

diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsToDataNodePerfSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsToDataNodePerfSpec.groovy
new file mode 100644
index 0000000..c36de9a
--- /dev/null
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/impl/CpsToDataNodePerfSpec.groovy
@@ -0,0 +1,89 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 Nordix Foundation
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.ri.performance
+
+import org.apache.commons.lang3.time.StopWatch
+import org.onap.cps.spi.CpsDataPersistenceService
+import org.onap.cps.spi.impl.CpsPersistenceSpecBase
+import org.onap.cps.spi.model.DataNode
+import org.onap.cps.spi.model.DataNodeBuilder
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.jdbc.Sql
+import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+
+class CpsToDataNodePerfSpec extends CpsPersistenceSpecBase {
+
+    @Autowired
+    CpsDataPersistenceService objectUnderTest
+
+    static final String SET_DATA = '/data/fragment.sql'
+    static final String  XPATH_DATA_NODE_WITH_DESCENDANTS = '/parent-1'
+
+    @Sql([CLEAR_DATA, SET_DATA])
+    def 'Get data node by xpath with all descendants with many children'() {
+        given: 'nodes and grandchildren have been persisted'
+            def setupStopWatch = new StopWatch()
+            setupStopWatch.start()
+            createLineage()
+            setupStopWatch.stop()
+            def setupDurationInMillis = setupStopWatch.getTime()
+        when: 'data node is requested with all descendants'
+            def readStopWatch = new StopWatch()
+            readStopWatch.start()
+            def result = objectUnderTest.getDataNode(
+                DATASPACE_NAME, ANCHOR_NAME1, XPATH_DATA_NODE_WITH_DESCENDANTS, INCLUDE_ALL_DESCENDANTS)
+            readStopWatch.stop()
+            def readDurationInMillis = readStopWatch.getTime()
+        then : 'setup duration is under 8 seconds'
+            assert setupDurationInMillis < 8000
+        and: 'read duration is under 3.5 seconds'
+            assert readDurationInMillis < 3500
+        and: 'data node is returned with all the descendants populated'
+            assert countDataNodes(result) == 1533
+    }
+
+    def createLineage() {
+        def numOfChildren = 30
+        def numOfGrandChildren = 50
+        (1..numOfChildren).each {
+            def childName = "perf-test-child-${it}".toString()
+            def newChild = goForthAndMultiply(XPATH_DATA_NODE_WITH_DESCENDANTS, childName, numOfGrandChildren)
+            objectUnderTest.addChildDataNode(DATASPACE_NAME, ANCHOR_NAME1, XPATH_DATA_NODE_WITH_DESCENDANTS, newChild)
+        }
+    }
+
+    def goForthAndMultiply(parentXpath, childName, numOfGrandChildren) {
+        def children = []
+        (1..numOfGrandChildren).each {
+            def child = new DataNodeBuilder().withXpath("${parentXpath}/${childName}/${it}-grand-child").build()
+            children.add(child)
+        }
+        return new DataNodeBuilder().withXpath("${parentXpath}/${childName}").withChildDataNodes(children).build()
+    }
+
+    def countDataNodes(DataNode dataNode) {
+        int nodeCount = 1
+        for (DataNode child : dataNode.childDataNodes) {
+            nodeCount = nodeCount + (countDataNodes(child))
+        }
+        return nodeCount
+    }
+}
\ No newline at end of file
diff --git a/cps-service/pom.xml b/cps-service/pom.xml
index 51cf324..f47a963 100644
--- a/cps-service/pom.xml
+++ b/cps-service/pom.xml
@@ -28,7 +28,7 @@
   <parent>
     <groupId>org.onap.cps</groupId>
     <artifactId>cps-parent</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
     <relativePath>../cps-parent/pom.xml</relativePath>
   </parent>
 
diff --git a/jacoco-report/pom.xml b/jacoco-report/pom.xml
index a783998..3e7af63 100644
--- a/jacoco-report/pom.xml
+++ b/jacoco-report/pom.xml
@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.onap.cps</groupId>
         <artifactId>cps-parent</artifactId>
-        <version>3.1.5-SNAPSHOT</version>
+        <version>3.2.0-SNAPSHOT</version>
         <relativePath>../cps-parent/pom.xml</relativePath>
     </parent>
     <modelVersion>4.0.0</modelVersion>
diff --git a/pom.xml b/pom.xml
index 7ae1542..2f7c157 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
 

     <groupId>org.onap.cps</groupId>

     <artifactId>cps-aggregator</artifactId>

-    <version>3.1.5-SNAPSHOT</version>

+    <version>3.2.0-SNAPSHOT</version>

     <packaging>pom</packaging>

 

     <name>cps</name>

diff --git a/spotbugs/pom.xml b/spotbugs/pom.xml
index c04f89f..306bdff 100644
--- a/spotbugs/pom.xml
+++ b/spotbugs/pom.xml
@@ -25,7 +25,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.onap.cps</groupId>
     <artifactId>spotbugs</artifactId>
-    <version>3.1.5-SNAPSHOT</version>
+    <version>3.2.0-SNAPSHOT</version>
 
     <properties>
         <nexusproxy>https://nexus.onap.org</nexusproxy>
diff --git a/version.properties b/version.properties
index 00839db..0a0cb6c 100755
--- a/version.properties
+++ b/version.properties
@@ -21,8 +21,8 @@
 # because they are used in Jenkins, whose plug-in doesn't support this
 
 major=3
-minor=1
-patch=5
+minor=2
+patch=0
 
 base_version=${major}.${minor}.${patch}