Extend capability of distributed cache
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / performance / cps / CpsDataServiceLimits.groovy
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2023 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the 'License');
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an 'AS IS' BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.integration.performance.cps
22
23 import java.time.OffsetDateTime
24 import org.onap.cps.api.CpsDataService
25 import org.onap.cps.integration.performance.base.CpsPerfTestBase
26 import org.springframework.dao.DataAccessResourceFailureException
27 import org.springframework.transaction.TransactionSystemException
28
29 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
30
31 class CpsDataServiceLimits extends CpsPerfTestBase {
32
33     CpsDataService objectUnderTest
34
35     def setup() { objectUnderTest = cpsDataService }
36
37     def 'Multiple get limit exceeded: 32,764 (~ 2^15) xpaths.'() {
38         given: 'more than 32,764 xpaths'
39             def xpaths = (0..32_764).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
40         when: 'single operation is executed to get all datanodes with given xpaths'
41             objectUnderTest.getDataNodesForMultipleXpaths(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, INCLUDE_ALL_DESCENDANTS)
42         then: 'a database exception is thrown'
43             thrown(DataAccessResourceFailureException.class)
44     }
45
46     def 'Delete multiple datanodes limit exceeded: 32,767 (~ 2^15) xpaths.'() {
47         given: 'more than 32,767 xpaths'
48             def xpaths = (0..32_767).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
49         when: 'single operation is executed to delete all datanodes with given xpaths'
50             objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, OffsetDateTime.now())
51         then: 'a database exception is thrown'
52             thrown(TransactionSystemException.class)
53     }
54
55     def 'Delete datanodes from multiple anchors limit exceeded: 32,766 (~ 2^15) anchors.'() {
56         given: 'more than 32,766 anchor names'
57             def anchorNames = (0..32_766).collect { "size-of-this-name-does-not-matter-for-limit-" + it }
58         when: 'single operation is executed to delete all datanodes in given anchors'
59             objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames, OffsetDateTime.now())
60         then: 'a database exception is thrown'
61             thrown(DataAccessResourceFailureException.class)
62     }
63
64 }