2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2024 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 static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS
25 import org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence
26 import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence
27 import org.onap.cps.integration.ResourceMeter
28 import org.onap.cps.integration.performance.base.NcmpPerfTestBase
29 import java.util.stream.Collectors
31 class CmHandleQueryByAlternateIdPerfTest extends NcmpPerfTestBase {
33 InventoryPersistence objectUnderTest
34 ResourceMeter resourceMeter = new ResourceMeter()
36 def setup() { objectUnderTest = inventoryPersistence }
38 def 'Query cm handle by longest match alternate id'() {
39 when: 'an alternate id as cps path query'
41 def cpsPath = "/a/b/c/d-5/e/f/g/h/i"
42 def dataNodes = objectUnderTest.getCmHandleDataNodeByLongestMatchAlternateId(cpsPath, '/')
43 and: 'the ids of the result are extracted and converted to xpath'
44 def cpsXpaths = dataNodes.stream().map(dataNode -> "/dmi-registry/cm-handles[@id='${dataNode.leaves.id}']".toString() ).collect(Collectors.toSet())
45 and: 'a single get is executed to get all the parent objects and their descendants'
46 cpsDataService.getDataNodesForMultipleXpaths(NcmpPersistence.NCMP_DATASPACE_NAME, NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR, cpsXpaths, OMIT_DESCENDANTS)
48 def durationInSeconds = resourceMeter.getTotalTimeInSeconds()
49 print 'Total time in seconds to query ch handle by alternate id: ' + durationInSeconds
50 then: 'the required operations are performed within required time and memory limit'
51 recordAndAssertResourceUsage('CpsPath Registry attributes Query', 1, durationInSeconds, 300, resourceMeter.getTotalMemoryUsageInMB())