diff options
8 files changed, 56 insertions, 41 deletions
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 45922454fd..34eeaccf8f 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 @@ -66,19 +66,20 @@ public class ParameterizedCmHandleQueryServiceImpl implements ParameterizedCmHan public Collection<String> queryCmHandleIds( final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) { return executeQueries(cmHandleQueryServiceParameters, - this::executeCpsPathQuery, - this::queryCmHandlesByPublicProperties, - this::executeModuleNameQuery, + this::executeCpsPathQuery, + this::queryCmHandlesByPublicProperties, + this::executeModuleNameQuery, this::queryCmHandlesByTrustLevel); } @Override public Collection<String> queryCmHandleIdsForInventory( - final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) { + final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) { return executeQueries(cmHandleQueryServiceParameters, - this::queryCmHandlesByPublicProperties, - this::queryCmHandlesByPrivateProperties, - this::queryCmHandlesByDmiPlugin); + this::executeCpsPathQuery, + this::queryCmHandlesByPublicProperties, + this::queryCmHandlesByPrivateProperties, + this::queryCmHandlesByDmiPlugin); } @Override diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java index fce285b415..e0b54d2197 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditions.java @@ -32,7 +32,8 @@ public enum InventoryQueryConditions { HAS_ALL_PROPERTIES("hasAllProperties"), HAS_ALL_ADDITIONAL_PROPERTIES("hasAllAdditionalProperties"), - CM_HANDLE_WITH_DMI_PLUGIN("cmHandleWithDmiPlugin"); + CM_HANDLE_WITH_DMI_PLUGIN("cmHandleWithDmiPlugin"), + WITH_CPS_PATH("cmHandleWithCpsPath"); public static final List<String> ALL_CONDITION_NAMES = Arrays.stream(InventoryQueryConditions.values()) .map(InventoryQueryConditions::getName).collect(Collectors.toList()); diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy index dfd549e63e..013bace04d 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/ParameterizedCmHandleQueryServiceSpec.groovy @@ -57,6 +57,19 @@ class ParameterizedCmHandleQueryServiceSpec extends Specification { assert result == ['some-cmhandle-id'] as Set } + def 'Query cm handle where cps path itself is ancestor axis.'() { + given: 'a cmHandleWithCpsPath condition property' + def cmHandleQueryParameters = new CmHandleQueryServiceParameters() + def conditionProperties = createConditionProperties('cmHandleWithCpsPath', [['cpsPath' : '/some/cps/path']]) + cmHandleQueryParameters.setCmHandleQueryParameters([conditionProperties]) + and: 'the query get the cm handle data nodes excluding all descendants returns a datanode' + cmHandleQueries.queryCmHandleAncestorsByCpsPath('/some/cps/path', FetchDescendantsOption.OMIT_DESCENDANTS) >> [new DataNode(leaves: ['id':'some-cmhandle-id'])] + when: 'the query is executed for cm handle ids' + def result = objectUnderTest.queryCmHandleIdsForInventory(cmHandleQueryParameters) + then: 'the correct expected cm handles ids are returned' + assert result == ['some-cmhandle-id'] as Set + } + def 'Cm handle ids query with error: #scenario.'() { given: 'a cmHandleWithCpsPath condition property' def cmHandleQueryParameters = new CmHandleQueryServiceParameters() diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy index 51c1f4bb13..2e7122268f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/models/InventoryQueryConditionsSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================== - * Copyright (c) 2022 Nordix Foundation. + * Copyright (c) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,18 +20,16 @@ package org.onap.cps.ncmp.impl.inventory.models - import spock.lang.Specification class InventoryQueryConditionsSpec extends Specification { def 'Inventory query condition names.'() { - expect: '3 conditions with the correct names' - assert InventoryQueryConditions.ALL_CONDITION_NAMES.size() == 3 + expect: '4 conditions with the correct names' + assert InventoryQueryConditions.ALL_CONDITION_NAMES.size() == 4 assert InventoryQueryConditions.ALL_CONDITION_NAMES.containsAll('hasAllProperties', 'hasAllAdditionalProperties', - 'cmHandleWithDmiPlugin') + 'cmHandleWithDmiPlugin', + 'cmHandleWithCpsPath') } - - } diff --git a/csit/run-csit.sh b/csit/run-csit.sh index 7f8f6b5270..93941e2163 100755 --- a/csit/run-csit.sh +++ b/csit/run-csit.sh @@ -187,10 +187,6 @@ export TESTOPTIONS="${2}" rm -rf "$WORKSPACE/archives/$TESTPLAN" mkdir -p "$WORKSPACE/archives/$TESTPLAN" -rm -rf "$WORKSPACE/nginx-log" -mkdir -p "$WORKSPACE/nginx-log" -chmod -R 755 "$WORKSPACE/nginx-log" - TESTPLANDIR="${WORKSPACE}/${TESTPLAN}" # Run installation of prerequired libraries diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 908673a700..2ecd456fc5 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -77,7 +77,6 @@ services: volumes: - ./nginx.conf:/etc/nginx/nginx.conf - ./proxy_params:/etc/nginx/proxy_params - - ../csit/nginx-log:/var/log/nginx ### if kafka is not required comment out zookeeper and kafka ### zookeeper: diff --git a/docs/ncmp-inventory-querying.rst b/docs/ncmp-inventory-querying.rst index 349b984963..084eaaf696 100644 --- a/docs/ncmp-inventory-querying.rst +++ b/docs/ncmp-inventory-querying.rst @@ -156,3 +156,23 @@ With the *cmHandleWithDmiPlugin* condition, we can provide a dmiPluginName. The } ] } + +CM Handle search with CPS Path +------------------------------ + +The *cmHandleWithCpsPath* condition allows any data of the CM Handle to be queried as long as it is accessible by CPS path. CPS path is described in detail in :doc:`cps-path`. For this endpoint, the ancestor axis for CM Handles is appended automatically so that a CM Handle is always returned. For example ``/dmi-registry/cm-handles[@module-set-tag='']`` will become ``/dmi-registry/cm-handles[@module-set-tag='']/ancestor::cm-handles``. + +.. code-block:: json + + { + "cmHandleQueryParameters": [ + { + "conditionName": "cmHandleWithCpsPath", + "conditionParameters": [ + { + "cpsPath": "/dmi-registry/cm-handles[@module-set-tag='some-value or empty']" + } + ] + } + ] + }
\ No newline at end of file diff --git a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy index 914f562a2f..c9a64e0ab8 100644 --- a/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy +++ b/integration-test/src/test/groovy/org/onap/cps/integration/functional/ncmp/CmHandleCreateSpec.groovy @@ -138,41 +138,28 @@ class CmHandleCreateSpec extends CpsIntegrationSpecBase { dmiDispatcher.isAvailable = false when: 'CM-handles are registered for creation' - def cmHandlesToCreate = [new NcmpServiceCmHandle(cmHandleId: 'ch-1'), new NcmpServiceCmHandle(cmHandleId: 'ch-2')] + def cmHandlesToCreate = [new NcmpServiceCmHandle(cmHandleId: 'ch-1')] def dmiPluginRegistration = new DmiPluginRegistration(dmiPlugin: DMI_URL, createdCmHandles: cmHandlesToCreate) objectUnderTest.updateDmiRegistrationAndSyncModule(dmiPluginRegistration) then: 'CM-handles go to LOCKED state' new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> { assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.LOCKED - assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.LOCKED }) - when: 'we wait for LOCKED CM handle retry time (actually just subtract 3 minutes from handles lastUpdateTime)' + when: 'DMI is available for retry' + dmiDispatcher.moduleNamesPerCmHandleId = ['ch-1': ['M1', 'M2']] + dmiDispatcher.isAvailable = true + and: 'the LOCKED CM handle retry time elapses (actually just subtract 3 minutes from handles lastUpdateTime)' overrideCmHandleLastUpdateTime('ch-1', OffsetDateTime.now().minusMinutes(3)) - overrideCmHandleLastUpdateTime('ch-2', OffsetDateTime.now().minusMinutes(3)) - then: 'CM-handles go to ADVISED state' - new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> { - assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.ADVISED - assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.ADVISED - }) - when: 'DMI will return expected modules' - dmiDispatcher.moduleNamesPerCmHandleId = ['ch-1': ['M1', 'M2'], 'ch-2': ['M1', 'M3']] - and: 'DMI is available for retry' - dmiDispatcher.isAvailable = true - then: 'CM-handles go to READY state' + then: 'CM-handle goes to READY state' new PollingConditions().within(MODULE_SYNC_WAIT_TIME_IN_SECONDS, () -> { assert objectUnderTest.getCmHandleCompositeState('ch-1').cmHandleState == CmHandleState.READY - assert objectUnderTest.getCmHandleCompositeState('ch-2').cmHandleState == CmHandleState.READY }) - and: 'CM-handles have expected modules' + and: 'CM-handle has expected modules' assert ['M1', 'M2'] == objectUnderTest.getYangResourcesModuleReferences('ch-1').moduleName.sort() - assert ['M1', 'M3'] == objectUnderTest.getYangResourcesModuleReferences('ch-2').moduleName.sort() - and: 'CM-handles have expected module set tags (blank)' - assert objectUnderTest.getNcmpServiceCmHandle('ch-1').moduleSetTag == '' - assert objectUnderTest.getNcmpServiceCmHandle('ch-2').moduleSetTag == '' cleanup: 'deregister CM handle' - deregisterCmHandles(DMI_URL, ['ch-1', 'ch-2']) + deregisterCmHandle(DMI_URL, 'ch-1') } } |