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