Merge "Add write performance tests"
[cps.git] / integration-test / src / test / groovy / org / onap / cps / integration / performance / cps / CpsDataServiceLimitsPerfTest.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.onap.cps.spi.exceptions.DataNodeNotFoundException
27
28 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
29
30 class CpsDataServiceLimitsPerfTest extends CpsPerfTestBase {
31
32     CpsDataService objectUnderTest
33
34     def setup() { objectUnderTest = cpsDataService }
35
36     def 'Multiple get limit exceeded: 32,764 (~ 2^15) xpaths.'() {
37         given: 'more than 32,764 xpaths'
38             def xpaths = (0..40_000).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
39         when: 'single operation is executed to get all datanodes with given xpaths'
40             objectUnderTest.getDataNodesForMultipleXpaths(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, INCLUDE_ALL_DESCENDANTS)
41         then: 'a database exception is not thrown'
42             noExceptionThrown()
43     }
44
45     def 'Delete multiple datanodes limit exceeded: 32,767 (~ 2^15) xpaths.'() {
46         given: 'more than 32,767 xpaths'
47             def xpaths = (0..40_000).collect { "/size/of/this/path/does/not/matter/for/limit[@id='" + it + "']" }
48         when: 'single operation is executed to delete all datanodes with given xpaths'
49             objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'bookstore1', xpaths, OffsetDateTime.now())
50         then: 'a database exception is not thrown (but a CPS DataNodeNotFoundException is thrown)'
51             thrown(DataNodeNotFoundException.class)
52     }
53
54     def 'Delete datanodes from multiple anchors limit exceeded: 32,766 (~ 2^15) anchors.'() {
55         given: 'more than 32,766 anchor names'
56             def anchorNames = (0..40_000).collect { "size-of-this-name-does-not-matter-for-limit-" + it }
57         when: 'single operation is executed to delete all datanodes in given anchors'
58             objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames, OffsetDateTime.now())
59         then: 'a database exception is not thrown'
60             noExceptionThrown()
61     }
62
63 }