27ff15547170d53e7c0427e15daae74c5b11d34a
[cps.git] /
1 /*
2  *  ============LICENSE_START=======================================================
3  *  Copyright (C) 2025 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
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 import org.onap.cps.ncmp.api.datajobs.DataJobService
26 import org.onap.cps.ncmp.api.datajobs.models.DataJobMetadata
27 import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest
28 import org.onap.cps.ncmp.api.datajobs.models.WriteOperation
29 import org.springframework.beans.factory.annotation.Autowired
30
31 /**
32  * This test does not depend on common performance test data. Hence it just extends the integration spec base.
33  */
34 class WriteDataJobPerfTest extends CpsIntegrationSpecBase {
35
36     @Autowired
37     DataJobService dataJobService
38
39     def resourceMeter = new ResourceMeter()
40
41     def populateDataJobWriteRequests(int numberOfWriteOperations) {
42         def writeOperations = []
43         for (int i = 1; i <= numberOfWriteOperations; i++) {
44             def basePath = "/SubNetwork=Europe/SubNetwork=Ireland/MeContext=MyRadioNode${i}/ManagedElement=MyManagedElement${i}"
45             writeOperations.add(new WriteOperation("${basePath}/SomeChild=child-1", 'operation1', '1', null))
46             writeOperations.add(new WriteOperation("${basePath}/SomeChild=child-2", 'operation2', '2', null))
47             writeOperations.add(new WriteOperation(basePath, 'operation3', '3', null))
48         }
49         return new DataJobWriteRequest(writeOperations)
50     }
51
52     def 'Performance test for writeDataJob method'() {
53         given: 'register 1,000 cm handles (with alternative ids)'
54         registerSequenceOfCmHandlesWithManyModuleReferencesButDoNotWaitForReady(DMI1_URL, 'tagA', 1000, 1, ModuleNameStrategy.UNIQUE, { it -> "/SubNetwork=Europe/SubNetwork=Ireland/MeContext=MyRadioNode${it}/ManagedElement=MyManagedElement${it}" })
55             def authorization = 'my authorization header'
56             def numberOfWriteOperations = 1000
57             def dataJobWriteRequest = populateDataJobWriteRequests(numberOfWriteOperations)
58             def myDataJobMetadata = new DataJobMetadata('d1', '', '')
59             def dataJobId = 'my-data-job-id'
60         when: 'sending a write job to NCMP with dynamically generated write operations'
61             resourceMeter.start()
62             dataJobService.writeDataJob(authorization, dataJobId, myDataJobMetadata, dataJobWriteRequest)
63             resourceMeter.stop()
64         then: 'record the result. Not asserted, just recorded in See https://lf-onap.atlassian.net/browse/CPS-2691'
65             println "*** CPS-2691 Execution time: ${resourceMeter.totalTimeInSeconds} seconds"
66         cleanup: 'deregister test cm handles'
67             deregisterSequenceOfCmHandles(DMI1_URL, 1000, 1)
68     }
69 }