Add tests for 32K limit for collection parameters 26/134126/4
authordanielhanrahan <daniel.hanrahan@est.tech>
Thu, 13 Apr 2023 17:53:59 +0000 (18:53 +0100)
committerDaniel Hanrahan <daniel.hanrahan@est.tech>
Fri, 14 Apr 2023 16:17:10 +0000 (16:17 +0000)
SQL queries taking collection parameters currently create a seperate
query parameter for each collection element. There is a limit of
around 2^15 (32,768) query parameters.

- Add tests for cps-service methods exceeding the collection size limit

Issue-ID: CPS-1573
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I7169b3604f4dd0bb23bba8ff33f0102c43052c03

integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimits.groovy [new file with mode: 0644]
integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimits.groovy [new file with mode: 0644]
integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/GetPerfTest.groovy

diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimits.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsAdminServiceLimits.groovy
new file mode 100644 (file)
index 0000000..2c7c6ce
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2023 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.integration.performance.cps
+
+import org.onap.cps.integration.performance.base.CpsPerfTestBase
+import org.springframework.dao.DataAccessResourceFailureException
+
+class CpsAdminServiceLimits extends CpsPerfTestBase {
+
+    def objectUnderTest
+
+    def setup() { objectUnderTest = cpsAdminService }
+
+    def 'Get anchors from multiple schema set names limit exceeded: 32,766 (~ 2^15) schema set names.'() {
+        given: 'more than 32,766 schema set names'
+            def schemaSetNames = (0..32_766).collect { "size-of-this-name-does-not-matter-for-limit-" + it }
+        when: 'single get is executed to get all the anchors'
+            objectUnderTest.getAnchors(CPS_PERFORMANCE_TEST_DATASPACE, schemaSetNames)
+        then: 'a database exception is thrown'
+            thrown(DataAccessResourceFailureException.class)
+    }
+
+    def 'Querying anchor names limit exceeded: 32,766 (~ 2^15) modules.'() {
+        given: 'more than 32,766 module names'
+            def moduleNames = (0..32_766).collect { "size-of-this-name-does-not-matter-for-limit-" + it }
+        when: 'single query is executed to get all the anchors'
+            objectUnderTest.queryAnchorNames(CPS_PERFORMANCE_TEST_DATASPACE, moduleNames)
+        then: 'a database exception is thrown'
+            thrown(DataAccessResourceFailureException.class)
+    }
+
+}
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimits.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/CpsDataServiceLimits.groovy
new file mode 100644 (file)
index 0000000..1cb4ed8
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2023 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.integration.performance.cps
+
+import java.time.OffsetDateTime
+import org.onap.cps.integration.performance.base.CpsPerfTestBase
+import org.springframework.dao.DataAccessResourceFailureException
+import org.springframework.transaction.TransactionSystemException
+
+import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
+
+class CpsDataServiceLimits extends CpsPerfTestBase {
+
+    def objectUnderTest
+
+    def setup() { objectUnderTest = cpsDataService }
+
+    def 'Multiple get limit exceeded: 32,764 (~ 2^15) xpaths.'() {
+        given: 'more than 32,764 xpaths'
+            def xpaths = (0..32_764).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
+        when: 'single operation is executed to get all datanodes with given xpaths'
+            objectUnderTest.getDataNodesForMultipleXpaths(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, INCLUDE_ALL_DESCENDANTS)
+        then: 'a database exception is thrown'
+            thrown(DataAccessResourceFailureException.class)
+    }
+
+    def 'Delete multiple datanodes limit exceeded: 32,767 (~ 2^15) xpaths.'() {
+        given: 'more than 32,767 xpaths'
+            def xpaths = (0..32_767).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
+        when: 'single operation is executed to delete all datanodes with given xpaths'
+            objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, OffsetDateTime.now())
+        then: 'a database exception is thrown'
+            thrown(TransactionSystemException.class)
+    }
+
+    def 'Delete datanodes from multiple anchors limit exceeded: 32,766 (~ 2^15) anchors.'() {
+        given: 'more than 32,766 anchor names'
+            def anchorNames = (0..32_766).collect { "size-of-this-name-does-not-matter-for-limit-" + it }
+        when: 'single operation is executed to delete all datanodes in given anchors'
+            objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames, OffsetDateTime.now())
+        then: 'a database exception is thrown'
+            thrown(DataAccessResourceFailureException.class)
+    }
+
+}
index 4edc1d7..4676c90 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.cps.integration.performance.cps
 
 import org.onap.cps.integration.performance.base.CpsPerfTestBase
-import org.springframework.dao.DataAccessResourceFailureException
 
 import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY
 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
@@ -81,13 +80,4 @@ class GetPerfTest extends CpsPerfTestBase {
             'openroadm top element' | 'openroadm'  | '/openroadm-devices' || 1000          | 1 + 50 * 86
     }
 
-    def 'Multiple get limit exceeded: 32,764 (~ 2^15) xpaths.'() {
-        given: 'more than 32,764 xpaths)'
-            def xpaths = (0..32_764).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
-        when: 'single get is executed to get all the parent objects and their descendants'
-            cpsDataService.getDataNodesForMultipleXpaths(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, INCLUDE_ALL_DESCENDANTS)
-        then: 'an exception is thrown'
-            thrown(DataAccessResourceFailureException.class)
-    }
-
 }