a733d42931bbca882170f65f6c0c76334192843c
[cps.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
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
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  *  SPDX-License-Identifier: Apache-2.0
18  *  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.cps.integration.performance.ncmp
22
23 import org.onap.cps.integration.ResourceMeter
24 import org.onap.cps.integration.base.CpsIntegrationSpecBase
25
26 /**
27  * This test does not depend on common performance test data. Hence it just extends the integration spec base.
28  */
29 class AlternateIdPerfTest extends CpsIntegrationSpecBase {
30
31     def resourceMeter = new ResourceMeter()
32
33     def NETWORK_SIZE = 10_000
34     def altIdPrefix = '/a=1/b=2/c=3/'
35
36     def setup() {
37         registerSequenceOfCmHandlesWithManyModuleReferencesButDoNotWaitForReady(DMI1_URL, 'tagA', NETWORK_SIZE, 1, altIdPrefix)
38     }
39
40     def cleanup() {
41         deregisterSequenceOfCmHandles(DMI1_URL, NETWORK_SIZE, 1)
42     }
43
44     def 'Alternate Id Lookup Performance.'() {
45         when: 'perform a 1,000 lookups by alternate id'
46             resourceMeter.start()
47             (1..1000).each {
48                 networkCmProxyInventoryFacade.getNcmpServiceCmHandle("${altIdPrefix}alt=${it}")
49             }
50             resourceMeter.stop()
51         then: 'record the result. Not asserted, just recorded in See https://lf-onap.atlassian.net/browse/CPS-2605'
52             println "*** CPS-2605 Execution time: ${resourceMeter.totalTimeInSeconds} ms"
53     }
54
55     def 'Alternate Id Longest Match Performance.'() {
56         given: 'an offset at 90% of the network size, so matches are not at the start...'
57             def offset = (int) (0.9 * NETWORK_SIZE)
58         when: 'perform a 100 longest matches'
59             resourceMeter.start()
60             (1..100).each {
61                 def target = "${altIdPrefix}alt=${it + offset}/d=4/e=5/f=6/g=7"
62                 alternateIdMatcher.getCmHandleIdByLongestMatchingAlternateId(target, "/")
63             }
64             resourceMeter.stop()
65         then: 'record the result. Not asserted, just recorded in See https://lf-onap.atlassian.net/browse/CPS-2743?focusedCommentId=83220'
66             println "*** CPS-2743 Execution time: ${resourceMeter.totalTimeInSeconds} ms"
67     }
68 }