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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.integration.performance.cps
23 import org.onap.cps.spi.exceptions.DataNodeNotFoundException
25 import java.time.OffsetDateTime
26 import org.onap.cps.api.CpsDataService
27 import org.onap.cps.integration.performance.base.CpsPerfTestBase
29 class DeletePerfTest extends CpsPerfTestBase {
31 CpsDataService objectUnderTest
33 def setup() { objectUnderTest = cpsDataService }
35 def 'Create test data (please note, subsequent tests depend on this running first).'() {
36 when: 'multiple anchors with a node with a large number of descendants is created'
38 def data = generateOpenRoadData(50)
39 addAnchorsWithData(10, CPS_PERFORMANCE_TEST_DATASPACE, LARGE_SCHEMA_SET, 'delete', data)
41 def setupDurationInMillis = stopWatch.getTotalTimeMillis()
42 then: 'setup duration is under 40 seconds'
43 recordAndAssertPerformance('Delete test setup', 40_000, setupDurationInMillis)
46 def 'Delete 10 container nodes'() {
47 when: 'child nodes are deleted'
50 def childPath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device"
51 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete1', childPath, OffsetDateTime.now())
54 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
55 then: 'delete duration is under 300 milliseconds'
56 recordAndAssertPerformance('Delete 10 containers', 300, deleteDurationInMillis)
59 def 'Batch delete 50 container nodes'() {
60 given: 'a list of xpaths to delete'
61 def xpathsToDelete = (1..50).collect {
62 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device"
64 when: 'child nodes are deleted'
66 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete2', xpathsToDelete, OffsetDateTime.now())
68 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
69 then: 'delete duration is under 300 milliseconds'
70 recordAndAssertPerformance('Batch delete 50 containers', 300, deleteDurationInMillis)
73 def 'Delete 20 list elements'() {
74 when: 'list elements are deleted'
77 def listElementXpath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-1']/org-openroadm-device/degree[@degree-number=" + it + "]"
78 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete3', listElementXpath, OffsetDateTime.now())
81 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
82 then: 'delete duration is under 300 milliseconds'
83 recordAndAssertPerformance('Delete 20 lists elements', 300, deleteDurationInMillis)
86 def 'Batch delete 1000 list elements'() {
87 given: 'a list of xpaths to delete'
88 def xpathsToDelete = []
89 for (int childIndex = 1; childIndex <= 50; childIndex++) {
90 xpathsToDelete.addAll((1..20).collect {
91 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-${childIndex}']/org-openroadm-device/degree[@degree-number=${it}]".toString()
94 when: 'list elements are deleted'
96 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete4', xpathsToDelete, OffsetDateTime.now())
98 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
99 then: 'delete duration is under 300 milliseconds'
100 recordAndAssertPerformance('Batch delete 1000 lists elements', 300, deleteDurationInMillis)
103 def 'Delete 10 whole lists'() {
104 when: 'lists are deleted'
107 def childPath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device/degree"
108 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete5', childPath, OffsetDateTime.now())
111 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
112 then: 'delete duration is under 300 milliseconds'
113 recordAndAssertPerformance('Delete 10 whole lists', 300, deleteDurationInMillis)
116 def 'Batch delete 30 whole lists'() {
117 given: 'a list of xpaths to delete'
118 def xpathsToDelete = (1..30).collect {
119 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device/degree"
121 when: 'lists are deleted'
123 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete6', xpathsToDelete, OffsetDateTime.now())
125 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
126 then: 'delete duration is under 300 milliseconds'
127 recordAndAssertPerformance('Batch delete 30 whole lists', 300, deleteDurationInMillis)
130 def 'Delete 1 large data node'() {
131 when: 'parent node is deleted'
133 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete7', '/openroadm-devices', OffsetDateTime.now())
135 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
136 then: 'delete duration is under 300 milliseconds'
137 recordAndAssertPerformance('Delete one large node', 300, deleteDurationInMillis)
140 def 'Delete root node with many descendants'() {
141 when: 'root node is deleted'
143 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete8', '/', OffsetDateTime.now())
145 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
146 then: 'delete duration is under 300 milliseconds'
147 recordAndAssertPerformance('Delete root node', 300, deleteDurationInMillis)
150 def 'Delete data nodes for an anchor'() {
151 when: 'data nodes are deleted'
153 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete9', OffsetDateTime.now())
155 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
156 then: 'delete duration is under 300 milliseconds'
157 recordAndAssertPerformance('Delete data nodes for anchor', 300, deleteDurationInMillis)
160 def 'Batch delete 100 non-existing nodes'() {
161 given: 'a list of xpaths to delete'
162 def xpathsToDelete = (1..100).collect { "/path/to/non-existing/node[@id='" + it + "']" }
163 when: 'child nodes are deleted'
166 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete10', xpathsToDelete, OffsetDateTime.now())
167 } catch (DataNodeNotFoundException ignored) {}
169 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
170 then: 'delete duration is under 300 milliseconds'
171 recordAndAssertPerformance('Batch delete 100 non-existing', 300, deleteDurationInMillis)
174 def 'Clean up test data'() {
175 given: 'a list of anchors to delete'
176 def anchorNames = (1..10).collect {'delete' + it}
177 when: 'data nodes are deleted'
179 cpsAdminService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames)
181 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
182 then: 'delete duration is under 1000 milliseconds'
183 recordAndAssertPerformance('Delete test cleanup', 1000, deleteDurationInMillis)