Merge "CPS-341 Support for multiple data tree instances under 1 anchor"
authorToine Siebelink <toine.siebelink@est.tech>
Fri, 16 Dec 2022 09:15:34 +0000 (09:15 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 16 Dec 2022 09:15:34 +0000 (09:15 +0000)
cps-dependencies/pom.xml
cps-ncmp-rest-stub/pom.xml
cps-parent/pom.xml
cps-ri/src/test/groovy/org/onap/cps/spi/performance/CpsToDataNodePerfTest.groovy
csit/prepare-csit.sh
csit/run-csit.sh

index 5bdf793..fb0638e 100755 (executable)
                 <artifactId>hazelcast-spring</artifactId>
                 <version>4.2.5</version>
             </dependency>
+            <dependency>
+                <groupId>com.google.guava</groupId>
+                <artifactId>guava</artifactId>
+                <version>31.1-jre</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 </project>
index 93c73fc..35784fb 100644 (file)
             <artifactId>slf4j-simple</artifactId>
             <version>1.8.0-beta4</version>
         </dependency>
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-            <version>20.0</version>
-        </dependency>
         <dependency>
             <groupId>cglib</groupId>
             <artifactId>cglib-nodep</artifactId>
index d3fe0f3..b8408f8 100755 (executable)
@@ -39,7 +39,7 @@
         <app>org.onap.cps.Application</app>
         <java.version>11</java.version>
         <minimum-coverage>0.97</minimum-coverage>
-        <postgres.version>42.5.0</postgres.version>
+        <postgres.version>42.5.1</postgres.version>
 
         <jacoco.reportDirectory.aggregate>${project.reporting.outputDirectory}/jacoco-aggregate</jacoco.reportDirectory.aggregate>
         <sonar.coverage.jacoco.xmlReportPaths>
index 387fc1f..b26cef4 100644 (file)
@@ -27,7 +27,11 @@ 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 java.util.concurrent.TimeUnit
+
 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
 
 class CpsToDataNodePerfTest extends CpsPersistenceSpecBase {
 
@@ -36,66 +40,85 @@ class CpsToDataNodePerfTest extends CpsPersistenceSpecBase {
     @Autowired
     CpsDataPersistenceService objectUnderTest
 
-    def PERF_TEST_PARENT = '/perf-parent-1'
+    static def PERF_TEST_PARENT = '/perf-parent-1'
+    static def NUMBER_OF_CHILDREN = 200
+    static def NUMBER_OF_GRAND_CHILDREN = 50
+    static def TOTAL_NUMBER_OF_NODES = 1 + NUMBER_OF_CHILDREN + (NUMBER_OF_CHILDREN * NUMBER_OF_GRAND_CHILDREN)  //  Parent + Children +  Grand-children
+    static def ALLOWED_SETUP_TIME_MS = TimeUnit.SECONDS.toMillis(10)
+    static def ALLOWED_READ_TIME_AL_NODES_MS = 500
 
-    def EXPECTED_NUMBER_OF_NODES = 10051  //  1 Parent + 50 Children + 10000 Grand-children
+    def readStopWatch = new StopWatch()
 
     @Sql([CLEAR_DATA, PERF_TEST_DATA])
-    def 'Get data node by xpath with all descendants with many children'() {
-        given: 'nodes and grandchildren have been persisted'
+    def 'Create a node with many descendants (please note, subsequent tests depend on this running first).'() {
+        given: 'a node with a large number of descendants is created'
             def setupStopWatch = new StopWatch()
             setupStopWatch.start()
             createLineage()
             setupStopWatch.stop()
             def setupDurationInMillis = setupStopWatch.getTime()
-        and: 'setup duration is under 10000 milliseconds'
-            assert setupDurationInMillis < 10000
+        and: 'setup duration is under #ALLOWED_SETUP_TIME_MS milliseconds'
+            assert setupDurationInMillis < ALLOWED_SETUP_TIME_MS
+    }
+
+    def 'Get data node with many descendants by xpath #scenario'() {
         when: 'get parent is executed with all descendants'
-            def readStopWatch = new StopWatch()
             readStopWatch.start()
-            def result = objectUnderTest.getDataNode('PERF-DATASPACE', 'PERF-ANCHOR', PERF_TEST_PARENT, INCLUDE_ALL_DESCENDANTS)
+            def result = objectUnderTest.getDataNode('PERF-DATASPACE', 'PERF-ANCHOR', xpath, INCLUDE_ALL_DESCENDANTS)
             readStopWatch.stop()
             def readDurationInMillis = readStopWatch.getTime()
         then: 'read duration is under 500 milliseconds'
-            assert readDurationInMillis < 500
+            assert readDurationInMillis < ALLOWED_READ_TIME_AL_NODES_MS
         and: 'data node is returned with all the descendants populated'
-            assert countDataNodes(result) == EXPECTED_NUMBER_OF_NODES
-        when: 'get root is executed with all descendants'
+            assert countDataNodes(result) == TOTAL_NUMBER_OF_NODES
+        where: 'the following xPaths are used'
+            scenario || xpath
+            'parent' || PERF_TEST_PARENT
+            'root'   || ''
+    }
+
+    def 'Query parent data node with many descendants by cps-path'() {
+        when: 'query is executed with all descendants'
             readStopWatch.reset()
             readStopWatch.start()
-            result = objectUnderTest.getDataNode('PERF-DATASPACE', 'PERF-ANCHOR', '', INCLUDE_ALL_DESCENDANTS)
+            def result = objectUnderTest.queryDataNodes('PERF-DATASPACE', 'PERF-ANCHOR', '//perf-parent-1' , INCLUDE_ALL_DESCENDANTS)
             readStopWatch.stop()
-            readDurationInMillis = readStopWatch.getTime()
+            def readDurationInMillis = readStopWatch.getTime()
         then: 'read duration is under 500 milliseconds'
-            assert readDurationInMillis < 500
+            assert readDurationInMillis < ALLOWED_READ_TIME_AL_NODES_MS
         and: 'data node is returned with all the descendants populated'
-            assert countDataNodes(result) == EXPECTED_NUMBER_OF_NODES
+            assert countDataNodes(result) == TOTAL_NUMBER_OF_NODES
+    }
+
+    def 'Query many descendants by cps-path with #scenario'() {
         when: 'query is executed with all descendants'
             readStopWatch.reset()
             readStopWatch.start()
-            result = objectUnderTest.queryDataNodes('PERF-DATASPACE', 'PERF-ANCHOR', '//perf-parent-1', INCLUDE_ALL_DESCENDANTS)
+            def result = objectUnderTest.queryDataNodes('PERF-DATASPACE', 'PERF-ANCHOR',  '//perf-test-grand-child-1', descendantsOption)
             readStopWatch.stop()
-            readDurationInMillis = readStopWatch.getTime()
+            def readDurationInMillis = readStopWatch.getTime()
         then: 'read duration is under 500 milliseconds'
-            assert readDurationInMillis < 500
+            assert readDurationInMillis < alowedDuration
         and: 'data node is returned with all the descendants populated'
-            assert countDataNodes(result) == EXPECTED_NUMBER_OF_NODES
+            assert result.size() == NUMBER_OF_CHILDREN
+        where: 'the following options are used'
+            scenario                                        | descendantsOption        || alowedDuration
+            'omit descendants                             ' | OMIT_DESCENDANTS         || 150
+            'include descendants (although there are none)' | INCLUDE_ALL_DESCENDANTS  || 1500
     }
 
     def createLineage() {
-        def numOfChildren = 50
-        def numOfGrandChildren = 200
-        (1..numOfChildren).each {
+        (1..NUMBER_OF_CHILDREN).each {
             def childName = "perf-test-child-${it}".toString()
-            def newChild = goForthAndMultiply(PERF_TEST_PARENT, childName, numOfGrandChildren)
+            def newChild = goForthAndMultiply(PERF_TEST_PARENT, childName)
             objectUnderTest.addChildDataNode('PERF-DATASPACE', 'PERF-ANCHOR', PERF_TEST_PARENT, newChild)
         }
     }
 
-    def goForthAndMultiply(parentXpath, childName, numOfGrandChildren) {
+    def goForthAndMultiply(parentXpath, childName) {
         def children = []
-        (1..numOfGrandChildren).each {
-            def child = new DataNodeBuilder().withXpath("${parentXpath}/${childName}/${it}perf-test-grand-child").build()
+        (1..NUMBER_OF_GRAND_CHILDREN).each {
+            def child = new DataNodeBuilder().withXpath("${parentXpath}/${childName}/perf-test-grand-child-${it}").build()
             children.add(child)
         }
         return new DataNodeBuilder().withXpath("${parentXpath}/${childName}").withChildDataNodes(children).build()
index 67412f3..dde9616 100755 (executable)
@@ -28,6 +28,21 @@ fi
 
 TESTPLANDIR=${WORKSPACE}/${TESTPLAN}
 
+# Version should match those used to setup robot-framework in other jobs/stages
+# Use pyenv for selecting the python version
+if [[ -d "/opt/pyenv" ]]; then
+  echo "Setup pyenv:"
+  export PYENV_ROOT="/opt/pyenv"
+  export PATH="$PYENV_ROOT/bin:$PATH"
+  pyenv versions
+  if command -v pyenv 1>/dev/null 2>&1; then
+    eval "$(pyenv init - --no-rehash)"
+    # Choose the latest numeric Python version from installed list
+    version=$(pyenv versions --bare | sed '/^[^0-9]/d' | sort -V | tail -n 1)
+    pyenv local "${version}"
+  fi
+fi
+
 # Assume that if ROBOT3_VENV is set and virtualenv with system site packages can be activated,
 # ci-management/jjb/integration/include-raw-integration-install-robotframework.sh has already
 # been executed
@@ -48,7 +63,10 @@ fi
 # install eteutils
 mkdir -p ${ROBOT3_VENV}/src/onap
 rm -rf ${ROBOT3_VENV}/src/onap/testsuite
-python3 -m pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.5.1.*' --pre
 
-pip freeze
+python3 -m pip install --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==11.0.0.dev17' --pre
 
+echo "Versioning information:"
+python3 --version
+pip freeze
+python3 -m robot.run --version || :
\ No newline at end of file
index 6703160..9a344c1 100755 (executable)
 
 # Branched from ccsdk/distribution to this repository Feb 23, 2021
 
+echo "---> run-csit.sh"
+
 WORKDIR=$(mktemp -d --suffix=-robot-workdir)
 
+# Version should match those used to setup robot-framework in other jobs/stages
+# Use pyenv for selecting the python version
+if [[ -d "/opt/pyenv" ]]; then
+  echo "Setup pyenv:"
+  export PYENV_ROOT="/opt/pyenv"
+  export PATH="$PYENV_ROOT/bin:$PATH"
+  pyenv versions
+  if command -v pyenv 1>/dev/null 2>&1; then
+    eval "$(pyenv init - --no-rehash)"
+    # Choose the latest numeric Python version from installed list
+    version=$(pyenv versions --bare | sed '/^[^0-9]/d' | sort -V | tail -n 1)
+    pyenv local "${version}"
+  fi
+fi
+
 #
 # functions
 #
 
-echo "---> run-csit.sh"
-
 # wrapper for sourcing a file
 function source_safely() {
     [ -z "$1" ] && return 1
@@ -192,6 +207,12 @@ SUITES=$( xargs -a testplan.txt )
 echo ROBOT_VARIABLES="${ROBOT_VARIABLES}"
 echo "Starting Robot test suites ${SUITES} ..."
 relax_set
+
+echo "Versioning information:"
+python3 --version
+pip freeze
+python3 -m robot.run --version || :
+
 python3 -m robot.run -N ${TESTPLAN} -v WORKSPACE:/tmp ${ROBOT_VARIABLES} ${TESTOPTIONS} ${SUITES}
 RESULT=$?
 load_set