From b9f1a61a9b1a509f4f19739c1b91666236f43d6b Mon Sep 17 00:00:00 2001 From: ToineSiebelink Date: Mon, 7 Jul 2025 08:49:32 +0100 Subject: [PATCH] Add Groovy Perf. Tests CM Handle Query REST API Issue-ID:CPS-2840 Change-Id: I941fe2e45840b2d49ef9cd33343c954ebb218f3e Signed-off-by: ToineSiebelink --- .../integration/base/CpsIntegrationSpecBase.groovy | 9 ++++- .../ncmp/inventory/ModulesRestApiSpec.groovy | 2 +- .../ncmp/CmHandleSearchApiPerfTest.groovy | 43 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleSearchApiPerfTest.groovy diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy index 589443f93e..99c7cb9be2 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/base/CpsIntegrationSpecBase.groovy @@ -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 diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy index e9e1962e8a..972e16655b 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/inventory/ModulesRestApiSpec.groovy @@ -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 index 0000000000..4666251aaf --- /dev/null +++ b/integration-test/src/test/groovy/org/onap/cps/integration/performance/ncmp/CmHandleSearchApiPerfTest.groovy @@ -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) + } + +} -- 2.16.6