aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java25
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java67
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java8
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java37
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java10
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy32
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy14
-rw-r--r--docs/release-notes.rst1
-rw-r--r--k6-tests/ncmp/common/search-base.js4
-rw-r--r--k6-tests/ncmp/ncmp-test-runner.js12
10 files changed, 119 insertions, 91 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java
index 04c3ad2fc6..56352c1c81 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImpl.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-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.
@@ -31,6 +31,7 @@ import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest;
import org.onap.cps.ncmp.api.datajobs.models.DmiWriteOperation;
import org.onap.cps.ncmp.api.datajobs.models.ProducerKey;
import org.onap.cps.ncmp.api.datajobs.models.SubJobWriteResponse;
+import org.onap.cps.utils.JsonObjectMapper;
import org.springframework.stereotype.Service;
@Slf4j
@@ -40,6 +41,7 @@ public class DataJobServiceImpl implements DataJobService {
private final DmiSubJobRequestHandler dmiSubJobClient;
private final WriteRequestExaminer writeRequestExaminer;
+ private final JsonObjectMapper jsonObjectMapper;
@Override
public void readDataJob(final String authorization,
@@ -54,14 +56,25 @@ public class DataJobServiceImpl implements DataJobService {
final String dataJobId,
final DataJobMetadata dataJobMetadata,
final DataJobWriteRequest dataJobWriteRequest) {
- log.info("data job id for write operation is: {}", dataJobId);
+
+ log.info("Data Job ID: {} - Total operations received: {}", dataJobId, dataJobWriteRequest.data().size());
+ logJsonRepresentation("Initiating WRITE operation for Data Job ID: " + dataJobId, dataJobWriteRequest);
final Map<ProducerKey, List<DmiWriteOperation>> dmiWriteOperationsPerProducerKey =
writeRequestExaminer.splitDmiWriteOperationsFromRequest(dataJobId, dataJobWriteRequest);
- return dmiSubJobClient.sendRequestsToDmi(authorization,
- dataJobId,
- dataJobMetadata,
- dmiWriteOperationsPerProducerKey);
+ final List<SubJobWriteResponse> subJobWriteResponses = dmiSubJobClient.sendRequestsToDmi(authorization,
+ dataJobId, dataJobMetadata, dmiWriteOperationsPerProducerKey);
+
+ log.info("Data Job ID: {} - Received {} sub-job(s) from DMI.", dataJobId, subJobWriteResponses.size());
+ logJsonRepresentation("Finalized subJobWriteResponses for Data Job ID: " + dataJobId, subJobWriteResponses);
+ return subJobWriteResponses;
+ }
+
+ private void logJsonRepresentation(final String description, final Object object) {
+ if (log.isDebugEnabled()) {
+ final String objectAsJsonString = jsonObjectMapper.asJsonString(object);
+ log.debug("{} (JSON): {}", description, objectAsJsonString);
+ }
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java
index bdf3785a7a..8d1d50ec15 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java
@@ -29,10 +29,10 @@ import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DMI_REGISTRY
import com.hazelcast.map.IMap;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsQueryService;
@@ -54,6 +54,7 @@ import org.springframework.stereotype.Component;
@Component
public class CmHandleQueryServiceImpl implements CmHandleQueryService {
private static final String ANCESTOR_CM_HANDLES = "/ancestor::cm-handles";
+ public static final String CM_HANDLE_ID = "id";
private static final String ALTERNATE_ID = "alternate-id";
private static final Integer NO_LIMIT = 0;
private final CpsDataService cpsDataService;
@@ -147,7 +148,7 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
@Override
public Collection<String> getAllCmHandleReferences(final boolean outputAlternateId) {
- final String attributeName = outputAlternateId ? ALTERNATE_ID : "id";
+ final String attributeName = outputAlternateId ? ALTERNATE_ID : CM_HANDLE_ID;
final String cpsPath = String.format("%s/cm-handles/@%s", NCMP_DMI_REGISTRY_PARENT, attributeName);
return cpsQueryService.queryDataLeaf(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, String.class);
}
@@ -177,20 +178,23 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
for (final Map.Entry<String, TrustLevel> mapEntry : trustLevelPerDmiPlugin.entrySet()) {
final String dmiPluginIdentifier = mapEntry.getKey();
final TrustLevel dmiTrustLevel = mapEntry.getValue();
- final Collection<String> candidateCmHandleIds = getCmHandleReferencesByDmiPluginIdentifier(
- dmiPluginIdentifier, false);
- final Set<String> candidateCmHandleIdsSet = new HashSet<>(candidateCmHandleIds);
+ final Map<String, String> candidateCmHandleReferences =
+ getCmHandleReferencesMapByDmiPluginIdentifier(dmiPluginIdentifier);
final Map<String, TrustLevel> trustLevelPerCmHandleIdInBatch =
- trustLevelPerCmHandleId.getAll(candidateCmHandleIdsSet);
- trustLevelPerCmHandleIdInBatch.forEach((cmHandleId, trustLevel) -> {
- final TrustLevel effectiveTrustLevel = trustLevel.getEffectiveTrustLevel(dmiTrustLevel);
- if (targetTrustLevel.equals(effectiveTrustLevel)) {
- selectedCmHandleReferences.add(cmHandleId);
+ trustLevelPerCmHandleId.getAll(candidateCmHandleReferences.keySet());
+ for (final Map.Entry<String, String> candidateCmHandleReference : candidateCmHandleReferences.entrySet()) {
+ final TrustLevel candidateCmHandleTrustLevel =
+ trustLevelPerCmHandleIdInBatch.get(candidateCmHandleReference.getKey());
+ final TrustLevel effectiveTrustlevel =
+ candidateCmHandleTrustLevel.getEffectiveTrustLevel(dmiTrustLevel);
+ if (targetTrustLevel.equals(effectiveTrustlevel)) {
+ if (outputAlternateId) {
+ selectedCmHandleReferences.add(candidateCmHandleReference.getValue());
+ } else {
+ selectedCmHandleReferences.add(candidateCmHandleReference.getKey());
+ }
}
- });
- }
- if (outputAlternateId) {
- return getAlternateIdsByCmHandleIds(selectedCmHandleReferences);
+ }
}
return selectedCmHandleReferences;
}
@@ -220,40 +224,47 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
private Set<String> getIdsByDmiPluginIdentifierAndDmiProperty(final String dmiPluginIdentifier,
final String dmiProperty,
final boolean outputAlternateId) {
- final String attributeName = outputAlternateId ? ALTERNATE_ID : "id";
+ final String attributeName = outputAlternateId ? ALTERNATE_ID : CM_HANDLE_ID;
final String cpsPath = String.format("%s/cm-handles[@%s='%s']/@%s",
NCMP_DMI_REGISTRY_PARENT, dmiProperty, dmiPluginIdentifier, attributeName);
return cpsQueryService.queryDataLeaf(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, String.class);
}
- private Collection<String> getAlternateIdsByCmHandleIds(final Collection<String> cmHandleIds) {
-
- final String cpsPath = NCMP_DMI_REGISTRY_PARENT + "/cm-handles["
- + createFormattedQueryString(cmHandleIds) + "]/@alternate-id";
+ private Collection<DataNode> getDataNodesByDmiPluginIdentifierAndDmiProperty(final String dmiPluginIdentifier,
+ final String dmiProperty) {
+ return cpsQueryService.queryDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
+ NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@" + dmiProperty + "='" + dmiPluginIdentifier + "']",
+ OMIT_DESCENDANTS);
+ }
- return cpsQueryService.queryDataLeaf(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, String.class);
+ private Map<String, String> getCmHandleReferencesMapByDmiPluginIdentifier(final String dmiPluginIdentifier) {
+ final Map<String, String> cmHandleReferencesMap = new HashMap<>();
+ for (final ModelledDmiServiceLeaves modelledDmiServiceLeaf : ModelledDmiServiceLeaves.values()) {
+ final Collection<DataNode> cmHandlesAsDataNodes = getDataNodesByDmiPluginIdentifierAndDmiProperty(
+ dmiPluginIdentifier, modelledDmiServiceLeaf.getLeafName());
+ for (final DataNode cmHandleAsDataNode : cmHandlesAsDataNodes) {
+ final String cmHandleId = cmHandleAsDataNode.getLeaves().get(CM_HANDLE_ID).toString();
+ final String alternateId = cmHandleAsDataNode.getLeaves().get(ALTERNATE_ID).toString();
+ cmHandleReferencesMap.put(cmHandleId, alternateId);
+ }
+ }
+ return cmHandleReferencesMap;
}
private Collection<String> getCmHandleReferencesByProperties(final PropertyType propertyType,
final String propertyName,
final String propertyValue,
final boolean outputAlternateId) {
- final String attributeName = outputAlternateId ? ALTERNATE_ID : "id";
+ final String attributeName = outputAlternateId ? ALTERNATE_ID : CM_HANDLE_ID;
final String cpsPath = String.format("//%s[@name='%s' and @value='%s']%s/@%s",
propertyType.getYangContainerName(), propertyName, propertyValue, ANCESTOR_CM_HANDLES, attributeName);
return cpsQueryService.queryDataLeaf(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, cpsPath, String.class);
}
- private String createFormattedQueryString(final Collection<String> cmHandleIds) {
- return cmHandleIds.stream()
- .map(cmHandleId -> "@id='" + cmHandleId + "'")
- .collect(Collectors.joining(" or "));
- }
-
private DataNode getCmHandleState(final String cmHandleId) {
cpsValidator.validateNameCharacters(cmHandleId);
final String xpath = NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@id='" + cmHandleId + "']/state";
return cpsDataService.getDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
xpath, OMIT_DESCENDANTS).iterator().next();
}
-} \ No newline at end of file
+}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java
index 6bb1bfc86c..aeeb86592c 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistence.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2023 TechMahindra Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -118,7 +118,7 @@ public interface InventoryPersistence extends NcmpPersistence {
* Get data node with the given cm handle id.
*
* @param cmHandleId cmHandle ID
- * @param fetchDescendantsOption fetchDescendantsOption
+ * @param fetchDescendantsOption fetch descendants option
* @return data node
*/
Collection<DataNode> getCmHandleDataNodeByCmHandleId(String cmHandleId,
@@ -144,9 +144,11 @@ public interface InventoryPersistence extends NcmpPersistence {
* Get collection of data nodes of given cm handles.
*
* @param cmHandleIds collection of cmHandle IDs
+ * @param fetchDescendantsOption fetch descendants option
* @return collection of data nodes
*/
- Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds);
+ Collection<DataNode> getCmHandleDataNodes(Collection<String> cmHandleIds,
+ FetchDescendantsOption fetchDescendantsOption);
/**
* get CM handles that has given module names.
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java
index 02e711287e..88322903a3 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImpl.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada
* Modifications Copyright (C) 2024 TechMahindra Ltd.
* ================================================================================
@@ -34,8 +34,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.onap.cps.api.CpsAnchorService;
import org.onap.cps.api.CpsDataService;
import org.onap.cps.api.CpsModuleService;
@@ -134,7 +134,7 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
dataValidationException.getMessage());
}
});
- return YangDataConverter.toYangModelCmHandles(getCmHandleDataNodes(validCmHandleIds));
+ return YangDataConverter.toYangModelCmHandles(getCmHandleDataNodes(validCmHandleIds, INCLUDE_ALL_DESCENDANTS));
}
@Override
@@ -201,22 +201,22 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
}
@Override
- public Collection<DataNode> getCmHandleDataNodes(final Collection<String> cmHandleIds) {
+ public Collection<DataNode> getCmHandleDataNodes(final Collection<String> cmHandleIds,
+ final FetchDescendantsOption fetchDescendantsOption) {
final Collection<String> xpaths = new ArrayList<>(cmHandleIds.size());
cmHandleIds.forEach(cmHandleId -> xpaths.add(getXPathForCmHandleById(cmHandleId)));
- return this.getDataNodes(xpaths);
+ return this.getDataNodes(xpaths, fetchDescendantsOption);
}
@Override
public Collection<String> getCmHandleReferencesWithGivenModules(final Collection<String> moduleNamesForQuery,
final boolean outputAlternateId) {
- if (outputAlternateId) {
- final Collection<String> cmHandleIds =
+ final Collection<String> cmHandleIds =
cpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
- return getAlternateIdsFromDataNodes(getCmHandleDataNodes(cmHandleIds));
- } else {
- return cpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, moduleNamesForQuery);
+ if (outputAlternateId) {
+ return getAlternateIdsForCmHandleIds(cmHandleIds);
}
+ return cmHandleIds;
}
@Override
@@ -241,12 +241,6 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@alternate-id='", "']"));
}
- private String getCpsPathForCmHandlesByReferences(final Collection<String> cmHandleReferences) {
- return cmHandleReferences.stream()
- .flatMap(id -> Stream.of("@id='" + id + "'", "@alternate-id='" + id + "'"))
- .collect(Collectors.joining(" or ", NCMP_DMI_REGISTRY_PARENT + "/cm-handles[", "]"));
- }
-
private static String createStateJsonData(final String state) {
return "{\"state\":" + state + "}";
}
@@ -255,8 +249,13 @@ public class InventoryPersistenceImpl extends NcmpPersistenceImpl implements Inv
return "{\"cm-handles\":" + jsonObjectMapper.asJsonString(yangModelCmHandles) + "}";
}
- private Collection<String> getAlternateIdsFromDataNodes(final Collection<DataNode> dataNodes) {
- return dataNodes.stream().map(dataNode ->
- (String) dataNode.getLeaves().get("alternate-id")).collect(Collectors.toSet());
+
+ private Collection<String> getAlternateIdsForCmHandleIds(final Collection<String> cmHandleIds) {
+ final Collection<DataNode> dataNodes = getCmHandleDataNodes(cmHandleIds, OMIT_DESCENDANTS);
+ return dataNodes.stream()
+ .map(DataNode::getLeaves)
+ .map(leaves -> (String) leaves.get("alternate-id"))
+ .filter(StringUtils::isNotBlank)
+ .collect(Collectors.toSet());
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java
index 6076895f0f..bafb06578e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceImpl.java
@@ -288,14 +288,4 @@ public class ParameterizedCmHandleQueryServiceImpl implements ParameterizedCmHan
}
}
- private Collection<String> collectCmHandleReferencesFromDataNodes(final Collection<DataNode> dataNodes,
- final boolean outputAlternateId) {
- if (outputAlternateId) {
- return dataNodes.stream().map(dataNode ->
- (String) dataNode.getLeaves().get("alternate-id")).collect(Collectors.toSet());
- } else {
- return dataNodes.stream().map(dataNode ->
- (String) dataNode.getLeaves().get("id")).collect(Collectors.toSet());
- }
- }
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy
index 4b536b9710..9f0e134466 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/datajobs/DataJobServiceImplSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-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.
@@ -29,6 +29,7 @@ import org.onap.cps.ncmp.api.datajobs.models.DataJobReadRequest
import org.onap.cps.ncmp.api.datajobs.models.DataJobWriteRequest
import org.onap.cps.ncmp.api.datajobs.models.ReadOperation
import org.onap.cps.ncmp.api.datajobs.models.WriteOperation
+import org.onap.cps.utils.JsonObjectMapper
import org.slf4j.LoggerFactory
import spock.lang.Specification
@@ -36,8 +37,9 @@ class DataJobServiceImplSpec extends Specification {
def mockWriteRequestExaminer = Mock(WriteRequestExaminer)
def mockDmiSubJobRequestHandler = Mock(DmiSubJobRequestHandler)
+ def mockJsonObjectMapper = Mock(JsonObjectMapper)
- def objectUnderTest = new DataJobServiceImpl(mockDmiSubJobRequestHandler, mockWriteRequestExaminer)
+ def objectUnderTest = new DataJobServiceImpl(mockDmiSubJobRequestHandler, mockWriteRequestExaminer, mockJsonObjectMapper)
def myDataJobMetadata = new DataJobMetadata('', '', '')
def authorization = 'my authorization header'
@@ -45,7 +47,7 @@ class DataJobServiceImplSpec extends Specification {
def logger = Spy(ListAppender<ILoggingEvent>)
def setup() {
- setupLogger()
+ setupLogger(Level.DEBUG)
}
def cleanup() {
@@ -62,22 +64,32 @@ class DataJobServiceImplSpec extends Specification {
assert loggingEvent.formattedMessage.contains('data job id for read operation is: my-job-id')
}
- def 'Write data-job request.'() {
+ def 'Write data-job request and verify logging when info enabled.'() {
given: 'data job metadata and write request'
def dataJobWriteRequest = new DataJobWriteRequest([new WriteOperation('', '', '', null)])
- and: 'a map of producer key and dmi 3gpp write operation'
+ and: 'a map of producer key and DMI 3GPP write operations'
def dmiWriteOperationsPerProducerKey = [:]
- when: 'write data job request is processed'
+ and: 'mocking the splitDmiWriteOperationsFromRequest method to return the expected data'
+ mockWriteRequestExaminer.splitDmiWriteOperationsFromRequest(_, _) >> dmiWriteOperationsPerProducerKey
+ and: 'mocking the sendRequestsToDmi method to simulate empty sub-job responses from the DMI request handler'
+ mockDmiSubJobRequestHandler.sendRequestsToDmi(authorization, 'my-job-id', myDataJobMetadata, dmiWriteOperationsPerProducerKey) >> []
+ when: 'the write data job request is processed'
objectUnderTest.writeDataJob(authorization, 'my-job-id', myDataJobMetadata, dataJobWriteRequest)
then: 'the examiner service is called and a map is returned'
1 * mockWriteRequestExaminer.splitDmiWriteOperationsFromRequest('my-job-id', dataJobWriteRequest) >> dmiWriteOperationsPerProducerKey
- and: 'the dmi request handler is called with the result from the examiner'
- 1 * mockDmiSubJobRequestHandler.sendRequestsToDmi(authorization, 'my-job-id', myDataJobMetadata, dmiWriteOperationsPerProducerKey)
+ and: 'write operation details are logged at debug level'
+ with(logger.list.find { it.level == Level.DEBUG }) {
+ assert it.formattedMessage.contains("Initiating WRITE operation for Data Job ID: my-job-id")
+ }
+ and: 'number of operations are logged at info level'
+ with(logger.list.find { it.level == Level.INFO }) {
+ assert it.formattedMessage.contains("Data Job ID: my-job-id - Total operations received: 1")
+ }
}
- def setupLogger() {
+ def setupLogger(Level level) {
def setupLogger = ((Logger) LoggerFactory.getLogger(DataJobServiceImpl.class))
- setupLogger.setLevel(Level.DEBUG)
+ setupLogger.setLevel(level)
setupLogger.addAppender(logger)
logger.start()
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy
index 2b0997b523..bc21360c47 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/InventoryPersistenceImplSpec.groovy
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2022-2025 Nordix Foundation
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. All rights reserved.
* Modifications Copyright (C) 2022 Bell Canada
* Modifications Copyright (C) 2024 TechMahindra Ltd.
* ================================================================================
@@ -336,15 +336,15 @@ class InventoryPersistenceImplSpec extends Specification {
}
def 'Get Alternate Ids for CM Handles that has given module names'() {
- given: 'A Collection of data nodes'
- def dataNodes = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-1']", leaves: ['id': 'ch-1', 'alternate-id': 'alt-1'])]
- when: 'the methods to get dataNodes is called and returns correct values'
+ given: 'cps anchor service returns a CM-handle ID for the given module name'
mockCpsAnchorService.queryAnchorNames(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, ['sample-module-name']) >> ['ch-1']
- mockCpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, ["/dmi-registry/cm-handles[@id='ch-1']"], INCLUDE_ALL_DESCENDANTS) >> dataNodes
- and: 'the method returns a result'
+ and: 'cps data service returns some data nodes for the given CM-handle ID'
+ def dataNodes = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-1']", leaves: ['id': 'ch-1', 'alternate-id': 'alt-1'])]
+ mockCpsDataService.getDataNodesForMultipleXpaths(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR, ["/dmi-registry/cm-handles[@id='ch-1']"], OMIT_DESCENDANTS) >> dataNodes
+ when: 'the method to get cm-handle references by modules is called (outputting alternate IDs)'
def result = objectUnderTest.getCmHandleReferencesWithGivenModules(['sample-module-name'], true)
then: 'the result contains the correct alternate Id'
- assert result == ['alt-1'] as HashSet
+ assert result == ['alt-1'] as Set
}
def 'Replace list content'() {
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 376009d06a..29b8844e64 100644
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -38,6 +38,7 @@ Release Data
Features
--------
- `CPS-2416 <https://lf-onap.atlassian.net/browse/CPS-2416>`_ Implement XPath Attribute Axis in CPS
+ - `CPS-2712 <https://lf-onap.atlassian.net/browse/CPS-2712>`_ Use Flux streaming/buffering for CM-handle searches
Version: 3.6.1
==============
diff --git a/k6-tests/ncmp/common/search-base.js b/k6-tests/ncmp/common/search-base.js
index af7d153416..91369e818f 100644
--- a/k6-tests/ncmp/common/search-base.js
+++ b/k6-tests/ncmp/common/search-base.js
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation
+ * Copyright (C) 2024-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.
@@ -31,7 +31,7 @@ export function executeCmHandleIdSearch(scenario) {
function executeSearchRequest(searchType, scenario) {
const searchParameters = SEARCH_PARAMETERS_PER_SCENARIO[scenario];
const payload = JSON.stringify(searchParameters);
- const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${searchType}`;
+ const url = `${NCMP_BASE_URL}/ncmp/v1/ch/${searchType}?outputAlternateId=true`;
return performPostRequest(url, payload, searchType);
}
diff --git a/k6-tests/ncmp/ncmp-test-runner.js b/k6-tests/ncmp/ncmp-test-runner.js
index b8fccdd69c..1104b14e4a 100644
--- a/k6-tests/ncmp/ncmp-test-runner.js
+++ b/k6-tests/ncmp/ncmp-test-runner.js
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2024-2025 Nordix Foundation
+ * Copyright (C) 2024-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.
@@ -119,7 +119,7 @@ export function passthroughWriteAltIdScenario() {
export function cmHandleIdSearchNoFilterScenario() {
const response = executeCmHandleIdSearch('no-filter');
if (check(response, { 'CM handle ID no-filter search status equals 200': (r) => r.status === 200 })
- && check(response, { 'CM handle ID no-filter search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
+ && check(response, { 'CM handle ID no-filter search returned the correct number of ids': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
idSearchNoFilterDurationTrend.add(response.timings.duration);
}
}
@@ -135,7 +135,7 @@ export function cmHandleSearchNoFilterScenario() {
export function cmHandleIdSearchModuleScenario() {
const response = executeCmHandleIdSearch('module');
if (check(response, { 'CM handle ID module search status equals 200': (r) => r.status === 200 })
- && check(response, { 'CM handle ID module search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
+ && check(response, { 'CM handle ID module search returned the correct number of ids': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
idSearchModuleDurationTrend.add(response.timings.duration);
}
}
@@ -151,7 +151,7 @@ export function cmHandleSearchModuleScenario() {
export function cmHandleIdSearchPropertyScenario() {
const response = executeCmHandleIdSearch('property');
if (check(response, { 'CM handle ID property search status equals 200': (r) => r.status === 200 })
- && check(response, { 'CM handle ID property search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
+ && check(response, { 'CM handle ID property search returned the correct number of ids': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
idSearchPropertyDurationTrend.add(response.timings.duration);
}
}
@@ -167,7 +167,7 @@ export function cmHandleSearchPropertyScenario() {
export function cmHandleIdSearchCpsPathScenario() {
const response = executeCmHandleIdSearch('cps-path-for-ready-cm-handles');
if (check(response, { 'CM handle ID cps path search status equals 200': (r) => r.status === 200 })
- && check(response, { 'CM handle ID cps path search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
+ && check(response, { 'CM handle ID cps path search returned the correct number of ids': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
idSearchCpsPathDurationTrend.add(response.timings.duration);
}
}
@@ -183,7 +183,7 @@ export function cmHandleSearchCpsPathScenario() {
export function cmHandleIdSearchTrustLevelScenario() {
const response = executeCmHandleIdSearch('trust-level');
if (check(response, { 'CM handle ID trust level search status equals 200': (r) => r.status === 200 })
- && check(response, { 'CM handle ID trust level search returned expected CM-handles': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
+ && check(response, { 'CM handle ID trust level search returned the correct number of ids': (r) => r.json('#') === TOTAL_CM_HANDLES })) {
idSearchTrustLevelDurationTrend.add(response.timings.duration);
}
}