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.integration.performance.base.CpsPerfTestBase
25 import static org.onap.cps.spi.FetchDescendantsOption.DIRECT_CHILDREN_ONLY
26 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
27 import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
29 class GetPerfTest extends CpsPerfTestBase {
33 def setup() { objectUnderTest = cpsDataService }
35 def 'Read top-level node with #scenario.'() {
36 when: 'get data nodes from 1 anchor'
38 def result = objectUnderTest.getDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchor, '/openroadm-devices', fetchDescendantsOption)
40 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
41 def durationInMillis = stopWatch.getTotalTimeMillis()
42 then: 'all data is read within #durationLimit ms'
43 recordAndAssertPerformance("Read datatrees with ${scenario}", durationLimit, durationInMillis)
44 where: 'the following parameters are used'
45 scenario | fetchDescendantsOption | anchor || durationLimit | expectedNumberOfDataNodes
46 'no descendants' | OMIT_DESCENDANTS | 'openroadm1' || 100 | 1
47 'direct descendants' | DIRECT_CHILDREN_ONLY | 'openroadm2' || 100 | 1 + 50
48 'all descendants' | INCLUDE_ALL_DESCENDANTS | 'openroadm3' || 350 | 1 + 50 * 86
51 def 'Read data trees for multiple xpaths'() {
52 given: 'a collection of xpaths to get'
53 def xpaths = (1..50).collect { "/openroadm-devices/openroadm-device[@device-id='C201-7-1A-" + it + "']" }
54 when: 'get data nodes from 1 anchor'
56 def result = objectUnderTest.getDataNodesForMultipleXpaths(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm4', xpaths, INCLUDE_ALL_DESCENDANTS)
58 assert countDataNodesInTree(result) == 50 * 86
59 def durationInMillis = stopWatch.getTotalTimeMillis()
60 then: 'all data is read within 350 ms'
61 recordAndAssertPerformance("Read datatrees for multiple xpaths", 350, durationInMillis)
64 def 'Read complete data trees using #scenario.'() {
65 when: 'get data nodes for 5 anchors'
68 def result = objectUnderTest.getDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchorPrefix + it, xpath, INCLUDE_ALL_DESCENDANTS)
69 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
72 def durationInMillis = stopWatch.getTotalTimeMillis()
73 then: 'all data is read within #durationLimit ms'
74 recordAndAssertPerformance("Read datatrees using ${scenario}", durationLimit, durationInMillis)
75 where: 'the following xpaths are used'
76 scenario | anchorPrefix | xpath || durationLimit | expectedNumberOfDataNodes
77 'bookstore root' | 'bookstore' | '/' || 250 | 78
78 'bookstore top element' | 'bookstore' | '/bookstore' || 250 | 78
79 'openroadm root' | 'openroadm' | '/' || 1000 | 1 + 50 * 86
80 'openroadm top element' | 'openroadm' | '/openroadm-devices' || 1000 | 1 + 50 * 86