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 java.time.OffsetDateTime
24 import org.onap.cps.api.CpsDataService
25 import org.onap.cps.integration.performance.base.CpsPerfTestBase
27 class DeletePerfTest extends CpsPerfTestBase {
29 CpsDataService objectUnderTest
31 def setup() { objectUnderTest = cpsDataService }
33 def 'Create test data (please note, subsequent tests depend on this running first).'() {
34 when: 'multiple anchors with a node with a large number of descendants is created'
36 def data = generateOpenRoadData(50)
37 addAnchorsWithData(9, CPS_PERFORMANCE_TEST_DATASPACE, LARGE_SCHEMA_SET, 'delete', data)
39 def setupDurationInMillis = stopWatch.getTotalTimeMillis()
40 then: 'setup duration is under 40 seconds'
41 recordAndAssertPerformance('Delete test setup', 40_000, setupDurationInMillis)
44 def 'Delete 10 container nodes'() {
45 when: 'child nodes are deleted'
48 def childPath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device"
49 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete1', childPath, OffsetDateTime.now())
52 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
53 then: 'delete duration is under 300 milliseconds'
54 recordAndAssertPerformance('Delete 10 containers', 300, deleteDurationInMillis)
57 def 'Batch delete 50 container nodes'() {
58 given: 'a list of xpaths to delete'
59 def xpathsToDelete = (1..50).collect {
60 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device"
62 when: 'child nodes are deleted'
64 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete2', xpathsToDelete, OffsetDateTime.now())
66 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
67 then: 'delete duration is under 300 milliseconds'
68 recordAndAssertPerformance('Batch delete 50 containers', 300, deleteDurationInMillis)
71 def 'Delete 20 list elements'() {
72 when: 'list elements are deleted'
75 def listElementXpath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-1']/org-openroadm-device/degree[@degree-number=" + it + "]"
76 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete3', listElementXpath, OffsetDateTime.now())
79 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
80 then: 'delete duration is under 300 milliseconds'
81 recordAndAssertPerformance('Delete 20 lists elements', 300, deleteDurationInMillis)
84 def 'Batch delete 1000 list elements'() {
85 given: 'a list of xpaths to delete'
86 def xpathsToDelete = []
87 for (int childIndex = 1; childIndex <= 50; childIndex++) {
88 xpathsToDelete.addAll((1..20).collect {
89 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-${childIndex}']/org-openroadm-device/degree[@degree-number=${it}]".toString()
92 when: 'list elements are deleted'
94 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete4', xpathsToDelete, OffsetDateTime.now())
96 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
97 then: 'delete duration is under 300 milliseconds'
98 recordAndAssertPerformance('Batch delete 1000 lists elements', 300, deleteDurationInMillis)
101 def 'Delete 10 whole lists'() {
102 when: 'lists are deleted'
105 def childPath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device/degree"
106 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete5', childPath, OffsetDateTime.now())
109 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
110 then: 'delete duration is under 300 milliseconds'
111 recordAndAssertPerformance('Delete 10 whole lists', 300, deleteDurationInMillis)
114 def 'Batch delete 30 whole lists'() {
115 given: 'a list of xpaths to delete'
116 def xpathsToDelete = (1..30).collect {
117 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']/org-openroadm-device/degree"
119 when: 'lists are deleted'
121 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete6', xpathsToDelete, OffsetDateTime.now())
123 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
124 then: 'delete duration is under 300 milliseconds'
125 recordAndAssertPerformance('Batch delete 30 whole lists', 300, deleteDurationInMillis)
128 def 'Delete 1 large data node'() {
129 when: 'parent node is deleted'
131 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete7', '/openroadm-devices', OffsetDateTime.now())
133 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
134 then: 'delete duration is under 300 milliseconds'
135 recordAndAssertPerformance('Delete one large node', 300, deleteDurationInMillis)
138 def 'Delete root node with many descendants'() {
139 when: 'root node is deleted'
141 objectUnderTest.deleteDataNode(CPS_PERFORMANCE_TEST_DATASPACE, 'delete8', '/', OffsetDateTime.now())
143 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
144 then: 'delete duration is under 300 milliseconds'
145 recordAndAssertPerformance('Delete root node', 300, deleteDurationInMillis)
148 def 'Delete data nodes for an anchor'() {
149 when: 'data nodes are deleted'
151 objectUnderTest.deleteDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, 'delete9', OffsetDateTime.now())
153 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
154 then: 'delete duration is under 300 milliseconds'
155 recordAndAssertPerformance('Delete data nodes for anchor', 300, deleteDurationInMillis)
158 def 'Clean up test data'() {
159 given: 'a list of anchors to delete'
160 def anchorNames = (1..9).collect {'delete' + it}
161 when: 'data nodes are deleted'
163 cpsAdminService.deleteAnchors(CPS_PERFORMANCE_TEST_DATASPACE, anchorNames)
165 def deleteDurationInMillis = stopWatch.getTotalTimeMillis()
166 then: 'delete duration is under 1000 milliseconds'
167 recordAndAssertPerformance('Delete test cleanup', 1000, deleteDurationInMillis)