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.ncmp
23 import org.onap.cps.integration.ResourceMeter
24 import java.util.stream.Collectors
25 import org.onap.cps.api.CpsQueryService
26 import org.onap.cps.integration.performance.base.NcmpPerfTestBase
27 import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
28 import static org.onap.cps.spi.FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS
30 class CmHandleQueryPerfTest extends NcmpPerfTestBase {
32 CpsQueryService objectUnderTest
33 ResourceMeter resourceMeter = new ResourceMeter()
35 def setup() { objectUnderTest = cpsQueryService }
37 def 'Query CM Handle IDs by a property name and value.'() {
38 when: 'a cps-path query on name-value pair is performed (without getting descendants)'
40 def cpsPath = '//additional-properties[@name="neType" and @value="RadioNode"]/ancestor::cm-handles'
41 def dataNodes = objectUnderTest.queryDataNodes(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, cpsPath, OMIT_DESCENDANTS)
42 and: 'the ids of the result are extracted and converted to xpath'
43 def xpaths = dataNodes.stream().map(dataNode -> "/dmi-registry/cm-handles[@id='${dataNode.leaves.id}']".toString() ).collect(Collectors.toSet())
44 and: 'a single get is executed to get all the parent objects and their descendants'
45 def result = cpsDataService.getDataNodesForMultipleXpaths(NCMP_PERFORMANCE_TEST_DATASPACE, REGISTRY_ANCHOR, xpaths, INCLUDE_ALL_DESCENDANTS)
47 def durationInMillis = resourceMeter.getTotalTimeMillis()
48 then: 'the required operations are performed within 1200 ms'
49 recordAndAssertResourceUsage("CpsPath Registry attributes Query", 250, durationInMillis, 150, resourceMeter.getTotalMemoryUsageInMB())
50 and: 'all but 1 (other node) are returned'
52 and: 'the tree contains all the expected descendants too'
53 assert countDataNodesInTree(result) == 5 * 999