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 UpdatePerfTest extends CpsPerfTestBase {
29 CpsDataService objectUnderTest
31 def setup() { objectUnderTest = cpsDataService }
33 def 'Update 1 data node with descendants'() {
34 given: 'a list of data nodes to update as JSON'
35 def parentNodeXpath = "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-10']"
36 def jsonData = readResourceDataFile('openroadm/innerNode.json').replace('NODE_ID_HERE', '10')
37 when: 'the fragment entities are updated by the data nodes'
39 objectUnderTest.updateDataNodeAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm1', parentNodeXpath, jsonData, OffsetDateTime.now())
41 def updateDurationInMillis = stopWatch.getTotalTimeMillis()
42 then: 'update duration is under 1000 milliseconds'
43 recordAndAssertPerformance('Update 1 data node', 600, updateDurationInMillis)
46 def 'Batch update 10 data nodes with descendants'() {
47 given: 'a list of data nodes to update as JSON'
48 def innerNodeJson = readResourceDataFile('openroadm/innerNode.json')
49 def nodesJsonData = (20..30).collectEntries {[
50 "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']",
51 innerNodeJson.replace('NODE_ID_HERE', it.toString())
53 when: 'the fragment entities are updated by the data nodes'
55 objectUnderTest.updateDataNodesAndDescendants(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm2', nodesJsonData, OffsetDateTime.now())
57 def updateDurationInMillis = stopWatch.getTotalTimeMillis()
58 then: 'update duration is under 5000 milliseconds'
59 recordAndAssertPerformance('Update 10 data nodes', 4000, updateDurationInMillis)