Add Groovy Perf. Tests CM Handle Query REST API 71/141471/2
authorToineSiebelink <toine.siebelink@est.tech>
Mon, 7 Jul 2025 07:49:32 +0000 (08:49 +0100)
committerToine Siebelink <toine.siebelink@est.tech>
Mon, 7 Jul 2025 11:06:16 +0000 (11:06 +0000)
Issue-ID:CPS-2840
Change-Id: I941fe2e45840b2d49ef9cd33343c954ebb218f3e
Signed-off-by: ToineSiebelink <toine.siebelink@est.tech>
integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy
integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy
integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleSearchApiPerfTest.groovy [new file with mode: 0644]

index 589443f..99c7cb9 100644 (file)
@@ -22,8 +22,6 @@
 package org.onap.cps.integration.base
 
 import com.hazelcast.map.IMap
-import java.time.OffsetDateTime
-import java.util.concurrent.BlockingQueue
 import okhttp3.mockwebserver.MockWebServer
 import org.onap.cps.api.CpsAnchorService
 import org.onap.cps.api.CpsDataService
@@ -46,6 +44,7 @@ import org.onap.cps.ncmp.impl.inventory.ParameterizedCmHandleQueryService
 import org.onap.cps.ncmp.impl.inventory.sync.ModuleSyncService
 import org.onap.cps.ncmp.impl.inventory.sync.ModuleSyncWatchdog
 import org.onap.cps.ncmp.impl.utils.AlternateIdMatcher
+import org.onap.cps.ncmp.rest.controller.NetworkCmProxyInventoryController
 import org.onap.cps.ri.repository.DataspaceRepository
 import org.onap.cps.ri.repository.SchemaSetRepository
 import org.onap.cps.ri.utils.SessionManager
@@ -65,6 +64,9 @@ import org.testcontainers.spock.Testcontainers
 import spock.lang.Shared
 import spock.lang.Specification
 
+import java.time.OffsetDateTime
+import java.util.concurrent.BlockingQueue
+
 @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = [CpsDataspaceService])
 @Testcontainers
 @EnableAutoConfiguration
@@ -84,6 +86,9 @@ abstract class CpsIntegrationSpecBase extends Specification {
     @Autowired
     MockMvc mvc
 
+    @Autowired
+    NetworkCmProxyInventoryController networkCmProxyInventoryController
+
     @Autowired
     CpsDataspaceService cpsDataspaceService
 
index e9e1962..972e166 100644 (file)
@@ -24,8 +24,8 @@ import org.onap.cps.integration.base.CpsIntegrationSpecBase
 
 import static org.hamcrest.Matchers.containsInAnyOrder
 import static org.hamcrest.Matchers.emptyString
-import static org.hamcrest.Matchers.everyItem
 import static org.hamcrest.Matchers.equalTo
+import static org.hamcrest.Matchers.everyItem
 import static org.hamcrest.Matchers.hasSize
 import static org.hamcrest.Matchers.is
 import static org.hamcrest.Matchers.not
diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleSearchApiPerfTest.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleSearchApiPerfTest.groovy
new file mode 100644 (file)
index 0000000..4666251
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ *  ============LICENSE_START=======================================================
+ *  Copyright (C) 2025 OpenInfra Foundation Europe. All rights reserved.
+ *  ================================================================================
+ *  Licensed under the Apache License, Version 2.0 (the 'License');
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an 'AS IS' BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *  SPDX-License-Identifier: Apache-2.0
+ *  ============LICENSE_END=========================================================
+ */
+
+package org.onap.cps.integration.performance.ncmp
+
+import org.onap.cps.integration.performance.base.NcmpPerfTestBase
+import org.onap.cps.ncmp.rest.model.CmHandleQueryParameters
+
+class CmHandleSearchApiPerfTest extends NcmpPerfTestBase {
+
+    def 'CM Handle Query without any parameters (conditions).'() {
+        given: 'no cm handle query parameters'
+            def noCmHandleQueryParameters = new CmHandleQueryParameters()
+        when: 'executing a cm handle (object) query'
+            resourceMeter.start()
+            def result = networkCmProxyInventoryController.searchCmHandles(noCmHandleQueryParameters, false)
+            resourceMeter.stop()
+        then: 'the response status is OK'
+            assert result.statusCode.value() == 200
+        and: 'the response contains all the cm handles in the network'
+            assert result.body.size() == TOTAL_CM_HANDLES
+        and: 'record the resource usage'
+            recordAndAssertResourceUsage('CM Handle API Query Performance A', 6.0 , resourceMeter.totalTimeInSeconds, 0.0)
+    }
+
+}