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 QueryPerfTest extends CpsPerfTestBase {
33 def setup() { objectUnderTest = cpsQueryService }
35 def 'Query complete data trees with #scenario.'() {
36 when: 'query data nodes (using a fresh anchor with identical data for each test)'
38 def result = objectUnderTest.queryDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchor, cpsPath, INCLUDE_ALL_DESCENDANTS)
40 def durationInMillis = stopWatch.getTotalTimeMillis()
41 then: 'the expected number of nodes is returned'
42 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
43 and: 'all data is read within #durationLimit ms'
44 recordAndAssertPerformance("Query 1 anchor ${scenario}", durationLimit, durationInMillis)
45 where: 'the following parameters are used'
46 scenario | anchor | cpsPath || durationLimit | expectedNumberOfDataNodes
47 'top element' | 'openroadm1' | '/openroadm-devices' || 250 | 50 * 86 + 1
48 'leaf condition' | 'openroadm2' | '//openroadm-device[@ne-state="inservice"]' || 650 | 50 * 86
49 'ancestors' | 'openroadm3' | '//openroadm-device/ancestor::openroadm-devices' || 250 | 50 * 86 + 1
50 'leaf condition + ancestors' | 'openroadm4' | '//openroadm-device[@status="success"]/ancestor::openroadm-devices' || 500 | 50 * 86 + 1
53 def 'Query complete data trees across all anchors with #scenario.'() {
54 when: 'query data nodes across all anchors'
56 def result = objectUnderTest.queryDataNodesAcrossAnchors('cpsPerformanceDataspace', cpspath, INCLUDE_ALL_DESCENDANTS)
58 def durationInMillis = stopWatch.getTotalTimeMillis()
59 then: 'the expected number of nodes is returned'
60 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
61 and: 'all data is read within #durationLimit ms'
62 recordAndAssertPerformance("Query across anchors ${scenario}", durationLimit, durationInMillis)
63 where: 'the following parameters are used'
64 scenario | cpspath || durationLimit | expectedNumberOfDataNodes
65 // FIXME Current implementation of queryDataNodesAcrossAnchors throws NullPointerException for next case. Uncomment after CPS-1582 is done.
66 // 'top element' | '/openroadm-devices' || 1 | 5 * (50 * 86 + 1)
67 'leaf condition' | '//openroadm-device[@ne-state="inservice"]' || 2500 | 5 * (50 * 86)
68 'ancestors' | '//openroadm-device/ancestor::openroadm-devices' || 12000 | 5 * (50 * 86 + 1)
69 'leaf condition + ancestors' | '//openroadm-device[@status="success"]/ancestor::openroadm-devices' || 1000 | 5 * (50 * 86 + 1)
72 def 'Query with leaf condition and #scenario.'() {
73 when: 'query data nodes (using a fresh anchor with identical data for each test)'
75 def result = objectUnderTest.queryDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchor, '//openroadm-device[@status="success"]', fetchDescendantsOption)
77 def durationInMillis = stopWatch.getTotalTimeMillis()
78 then: 'the expected number of nodes is returned'
79 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
80 and: 'all data is read within #durationLimit ms'
81 recordAndAssertPerformance("Query with ${scenario}", durationLimit, durationInMillis)
82 where: 'the following parameters are used'
83 scenario | fetchDescendantsOption | anchor || durationLimit | expectedNumberOfDataNodes
84 'no descendants' | OMIT_DESCENDANTS | 'openroadm1' || 100 | 50
85 'direct descendants' | DIRECT_CHILDREN_ONLY | 'openroadm2' || 400 | 50 * 2
86 'all descendants' | INCLUDE_ALL_DESCENDANTS | 'openroadm3' || 500 | 50 * 86
89 def 'Query ancestors with #scenario.'() {
90 when: 'query data nodes (using a fresh anchor with identical data for each test)'
92 def result = objectUnderTest.queryDataNodes(CPS_PERFORMANCE_TEST_DATASPACE, anchor, '//openroadm-device[@ne-state="inservice"]/ancestor::openroadm-devices', fetchDescendantsOption)
94 def durationInMillis = stopWatch.getTotalTimeMillis()
95 then: 'the expected number of nodes is returned'
96 assert countDataNodesInTree(result) == expectedNumberOfDataNodes
97 and: 'all data is read within #durationLimit ms'
98 recordAndAssertPerformance("Query ancestors with ${scenario}", durationLimit, durationInMillis)
99 where: 'the following parameters are used'
100 scenario | fetchDescendantsOption | anchor || durationLimit | expectedNumberOfDataNodes
101 'no descendants' | OMIT_DESCENDANTS | 'openroadm1' || 100 | 1
102 'direct descendants' | DIRECT_CHILDREN_ONLY | 'openroadm2' || 250 | 1 + 50
103 'all descendants' | INCLUDE_ALL_DESCENDANTS | 'openroadm3' || 400 | 1 + 50 * 86