From: Toine Siebelink Date: Thu, 8 Feb 2024 14:08:47 +0000 (+0000) Subject: Merge "Introduce Hazelcast for alternateId-cmHandle relation pt. 2 - error collection" X-Git-Tag: 3.4.4~34 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=814b882c6bf85a88c9135edb592e90d46af31f9a;hp=67681820f2a7fea88cbc6cbe5b3d483dae506d55;p=cps.git Merge "Introduce Hazelcast for alternateId-cmHandle relation pt. 2 - error collection" --- diff --git a/checkstyle/pom.xml b/checkstyle/pom.xml index ff4ecb5f1..95794b165 100644 --- a/checkstyle/pom.xml +++ b/checkstyle/pom.xml @@ -26,7 +26,7 @@ 4.0.0 org.onap.cps checkstyle - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT diff --git a/cps-application/pom.xml b/cps-application/pom.xml index be7664aa5..6466bcfe4 100644 --- a/cps-application/pom.xml +++ b/cps-application/pom.xml @@ -28,7 +28,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-bom/pom.xml b/cps-bom/pom.xml index 54d7602cb..ecd442cf4 100644 --- a/cps-bom/pom.xml +++ b/cps-bom/pom.xml @@ -25,7 +25,7 @@ 4.0.0 org.onap.cps cps-bom - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT pom This artifact contains dependencyManagement declarations of all published CPS components. diff --git a/cps-dependencies/pom.xml b/cps-dependencies/pom.xml index e7eb576ce..2f1a4d2d8 100644 --- a/cps-dependencies/pom.xml +++ b/cps-dependencies/pom.xml @@ -27,7 +27,7 @@ 4.0.0 org.onap.cps cps-dependencies - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT pom ${project.groupId}:${project.artifactId} diff --git a/cps-events/pom.xml b/cps-events/pom.xml index b1fd6f993..662d150a5 100644 --- a/cps-events/pom.xml +++ b/cps-events/pom.xml @@ -24,7 +24,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ncmp-events/pom.xml b/cps-ncmp-events/pom.xml index 36c69c69a..6e638438c 100644 --- a/cps-ncmp-events/pom.xml +++ b/cps-ncmp-events/pom.xml @@ -23,7 +23,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ncmp-events/src/main/resources/schemas/lcm/lcm-event-schema-v1.json b/cps-ncmp-events/src/main/resources/schemas/lcm/lcm-event-schema-v1.json index 7006b7836..e687303f8 100644 --- a/cps-ncmp-events/src/main/resources/schemas/lcm/lcm-event-schema-v1.json +++ b/cps-ncmp-events/src/main/resources/schemas/lcm/lcm-event-schema-v1.json @@ -39,6 +39,10 @@ "description": "cmHandle id", "type": "string" }, + "alternateId": { + "description": "alternative id for cmHandle (e.g. 3GPP FDN)", + "type": "string" + }, "oldValues": { "$ref": "#/definitions/Values" }, diff --git a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml index cdd9eefe0..25d4939eb 100644 --- a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml +++ b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-app/pom.xml @@ -22,7 +22,7 @@ org.onap.cps cps-ncmp-rest-stub - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT cps-ncmp-rest-stub-app diff --git a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml index 695065a48..1a8e89b68 100644 --- a/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml +++ b/cps-ncmp-rest-stub/cps-ncmp-rest-stub-service/pom.xml @@ -21,7 +21,7 @@ org.onap.cps cps-ncmp-rest-stub - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT cps-ncmp-rest-stub-service diff --git a/cps-ncmp-rest-stub/pom.xml b/cps-ncmp-rest-stub/pom.xml index a1c5ee04f..a35a88662 100644 --- a/cps-ncmp-rest-stub/pom.xml +++ b/cps-ncmp-rest-stub/pom.xml @@ -22,7 +22,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ncmp-rest/pom.xml b/cps-ncmp-rest/pom.xml index 27c640a63..f363c01f6 100644 --- a/cps-ncmp-rest/pom.xml +++ b/cps-ncmp-rest/pom.xml @@ -27,7 +27,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy index f06af6c10..4edbf3569 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/controller/handlers/NcmpDatastoreRequestHandlerSpec.groovy @@ -44,7 +44,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { def 'Attempt to execute async get request with #scenario.'() { given: 'notification feature is turned on/off' objectUnderTest.notificationFeatureEnabled = notificationFeatureEnabled - and: ' a flag to track the network service call' + and: 'a flag to track the network service call' def networkServiceMethodCalled = false and: 'the (mocked) service will use the flag to indicate if it is called' mockNetworkCmProxyDataService.getResourceDataForCmHandle('ds', 'ch1', 'resource1', 'options', _, _) >> { @@ -54,7 +54,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { objectUnderTest.executeRequest('ds', 'ch1', 'resource1', 'options', topic, false) then: 'the task is executed in an async fashion or not' expectedCalls * spiedCpsNcmpTaskExecutor.executeTask(*_) - and: 'the service request is always invoked within 1 seconds' + and: 'the service request is invoked' new PollingConditions().within(1) { assert networkServiceMethodCalled == true } @@ -97,7 +97,7 @@ class NcmpDatastoreRequestHandlerSpec extends Specification { objectUnderTest.executeRequest('myTopic', dataOperationRequest) then: 'the task is executed in an async fashion' 1 * spiedCpsNcmpTaskExecutor.executeTask(*_) - and: 'the network service is invoked within 1 seconds' + and: 'the network service is invoked' new PollingConditions().within(1) { assert networkServiceMethodCalled == true } diff --git a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy index 55590168d..5f62aca68 100644 --- a/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy +++ b/cps-ncmp-rest/src/test/groovy/org/onap/cps/ncmp/rest/executor/CpsNcmpTaskExecutorSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation + * Copyright (C) 2023-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. @@ -28,6 +28,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach import org.slf4j.LoggerFactory import spock.lang.Specification +import spock.util.concurrent.PollingConditions class CpsNcmpTaskExecutorSpec extends Specification { @@ -37,23 +38,23 @@ class CpsNcmpTaskExecutorSpec extends Specification { @BeforeEach void setup() { - ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).addAppender(logger); - logger.start(); + ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).addAppender(logger) + logger.start() } @AfterEach void teardown() { - ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).detachAndStopAllAppenders(); + ((Logger) LoggerFactory.getLogger(CpsNcmpTaskExecutor.class)).detachAndStopAllAppenders() } def 'Execute successful task.'() { when: 'task is executed' objectUnderTest.executeTask(taskSupplier(), enoughTime) - and: 'wait a little for async execution completion' - Thread.sleep(10) then: 'an event is logged with level INFO' - def loggingEvent = getLoggingEvent() - assert loggingEvent.level == Level.INFO + new PollingConditions().within(1) { + def loggingEvent = getLoggingEvent() + assert loggingEvent.level == Level.INFO + } and: 'the log indicates the task completed successfully' assert loggingEvent.formattedMessage == 'Async task completed successfully.' } @@ -61,11 +62,11 @@ class CpsNcmpTaskExecutorSpec extends Specification { def 'Execute failing task.'() { when: 'task is executed' objectUnderTest.executeTask(taskSupplierForFailingTask(), enoughTime) - and: 'wait a little for async execution completion' - Thread.sleep(10) then: 'an event is logged with level ERROR' - def loggingEvent = getLoggingEvent() - assert loggingEvent.level == Level.ERROR + new PollingConditions().within(1) { + def loggingEvent = getLoggingEvent() + assert loggingEvent.level == Level.ERROR + } and: 'the original error message is logged' assert loggingEvent.formattedMessage.contains('original exception message') } diff --git a/cps-ncmp-service/pom.xml b/cps-ncmp-service/pom.xml index 93c60fa53..9beb6b7b0 100644 --- a/cps-ncmp-service/pom.xml +++ b/cps-ncmp-service/pom.xml @@ -27,7 +27,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java index 450bc8cce..23d508b07 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreator.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 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. @@ -95,6 +95,7 @@ public class LcmEventsCreator { final NcmpServiceCmHandle existingNcmpServiceCmHandle, final LcmEventType lcmEventType) { final Event event = new Event(); event.setCmHandleId(eventCorrelationId); + event.setAlternateId(targetNcmpServiceCmHandle.getAlternateId()); final CmHandleValuesHolder cmHandleValuesHolder = LcmEventsCreatorHelper.determineEventValues(targetNcmpServiceCmHandle, existingNcmpServiceCmHandle, lcmEventType); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java index b54c154b2..3be97e8ee 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/utils/YangDataConverter.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 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. @@ -54,6 +54,7 @@ public class YangDataConverter { final List publicProperties = yangModelCmHandle.getPublicProperties(); ncmpServiceCmHandle.setCmHandleId(yangModelCmHandle.getId()); ncmpServiceCmHandle.setCompositeState(yangModelCmHandle.getCompositeState()); + ncmpServiceCmHandle.setAlternateId(yangModelCmHandle.getAlternateId()); setDmiProperties(dmiProperties, ncmpServiceCmHandle); setPublicProperties(publicProperties, ncmpServiceCmHandle); return ncmpServiceCmHandle; diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java index ba36b1a54..03e53fc42 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/yangmodels/YangModelCmHandle.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation + * Copyright (C) 2021-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. @@ -119,7 +119,7 @@ public class YangModelCmHandle { yangModelCmHandle.setDmiDataServiceName(dmiDataServiceName); yangModelCmHandle.setDmiModelServiceName(dmiModelServiceName); yangModelCmHandle.setModuleSetTag(moduleSetTag == null ? StringUtils.EMPTY : moduleSetTag); - yangModelCmHandle.setAlternateId(alternateId); + yangModelCmHandle.setAlternateId(alternateId == null ? StringUtils.EMPTY : alternateId); yangModelCmHandle.setDmiProperties(asYangModelCmHandleProperties(ncmpServiceCmHandle.getDmiProperties())); yangModelCmHandle.setPublicProperties(asYangModelCmHandleProperties( ncmpServiceCmHandle.getPublicProperties())); diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/FilterStrategiesIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/FilterStrategiesIntegrationSpec.groovy index bb082fd7f..fba1f953f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/FilterStrategiesIntegrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/FilterStrategiesIntegrationSpec.groovy @@ -23,7 +23,6 @@ package org.onap.cps.ncmp.api.impl.async import io.cloudevents.core.builder.CloudEventBuilder import org.onap.cps.events.EventsPublisher import org.onap.cps.ncmp.api.impl.config.kafka.KafkaConfig - import org.onap.cps.ncmp.api.kafka.ConsumerBaseSpec import org.onap.cps.ncmp.event.model.DmiAsyncRequestResponseEvent import org.spockframework.spring.SpringBean @@ -32,6 +31,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.DirtiesContext import org.testcontainers.spock.Testcontainers +import spock.util.concurrent.PollingConditions import java.util.concurrent.TimeUnit @SpringBootTest(classes =[DataOperationEventConsumer, AsyncRestRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) @@ -50,28 +50,34 @@ class FilterStrategiesIntegrationSpec extends ConsumerBaseSpec { def topic def 'Legacy event consumer with cloud event.'() { - given: 'a cloud event of type: #eventType' + given: 'a data operation cloud event type' def cloudEvent = CloudEventBuilder.v1().withId('some id') .withType('DataOperationEvent') .withSource(URI.create('some-source')) .build() when: 'send the cloud event' cloudEventKafkaTemplate.send(topic, cloudEvent) - and: 'wait a little for async processing of message' + then: 'wait a little for async processing of message (must wait to try to avoid false positives)' TimeUnit.MILLISECONDS.sleep(300) - then: 'event is not consumed' + and: 'event is not consumed' 0 * mockEventsPublisher.publishEvent(*_) } def 'Legacy event consumer with valid legacy event.'() { - given: 'a cloud event of type: #eventType' + given: 'a legacy event' DmiAsyncRequestResponseEvent legacyEvent = new DmiAsyncRequestResponseEvent(eventId:'legacyEventId', eventTarget:'legacyEventTarget') + and: 'a flag to track the publish event call' + def publishEventMethodCalled = false + and: 'the (mocked) events publisher will use the flag to indicate if it is called' + mockEventsPublisher.publishEvent(*_) >> { + publishEventMethodCalled = true + } when: 'send the cloud event' legacyEventKafkaTemplate.send(topic, legacyEvent) - and: 'wait a little for async processing of message' - TimeUnit.MILLISECONDS.sleep(300) then: 'the event is consumed by the (legacy) AsynRestRequest consumer' - 1 * mockEventsPublisher.publishEvent(*_) + new PollingConditions().within(1) { + assert publishEventMethodCalled == true + } } def 'Filtering Cloud Events on Type.'() { @@ -80,17 +86,23 @@ class FilterStrategiesIntegrationSpec extends ConsumerBaseSpec { .withType(eventType) .withSource(URI.create('some-source')) .build() + and: 'a flag to track the publish event call' + def publishEventMethodCalled = false + and: 'the (mocked) events publisher will use the flag to indicate if it is called' + mockEventsPublisher.publishCloudEvent(*_) >> { + publishEventMethodCalled = true + } when: 'send the cloud event' cloudEventKafkaTemplate.send(topic, cloudEvent) - and: 'wait a little for async processing of message' - TimeUnit.MILLISECONDS.sleep(300) then: 'the event has only been forwarded for the correct type' - expectedNUmberOfCallsToPublishForwardedEvent * mockEventsPublisher.publishCloudEvent(*_) + new PollingConditions(initialDelay: 0.3).within(1) { + assert publishEventMethodCalled == expectCallToPublishEventMethod + } where: 'the following event types are used' - eventType || expectedNUmberOfCallsToPublishForwardedEvent - 'DataOperationEvent' || 1 - 'other type' || 0 - 'any type contain the word "DataOperationEvent"' || 1 + eventType || expectCallToPublishEventMethod + 'DataOperationEvent' || true + 'other type' || false + 'any type contain the word "DataOperationEvent"' || true } //TODO Toine, add positive test with data to prove event is converted correctly (using correct factory) @@ -98,9 +110,9 @@ class FilterStrategiesIntegrationSpec extends ConsumerBaseSpec { def 'Non cloud events on same Topic.'() { when: 'sending a non-cloud event on the same topic' legacyEventKafkaTemplate.send(topic, 'simple string event') - and: 'wait a little for async processing of message' + then: 'wait a little for async processing of message (must wait to try to avoid false positives)' TimeUnit.MILLISECONDS.sleep(300) - then: 'the event is not processed by this consumer' + and: 'the event is not processed by this consumer' 0 * mockEventsPublisher.publishCloudEvent(*_) } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/SerializationIntegrationSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/SerializationIntegrationSpec.groovy index 212c6734e..ee8933300 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/SerializationIntegrationSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/async/SerializationIntegrationSpec.groovy @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import io.cloudevents.core.builder.CloudEventBuilder import org.onap.cps.events.EventsPublisher import org.onap.cps.ncmp.api.impl.config.kafka.KafkaConfig - import org.onap.cps.ncmp.api.kafka.ConsumerBaseSpec import org.onap.cps.ncmp.event.model.DmiAsyncRequestResponseEvent import org.onap.cps.ncmp.event.model.NcmpAsyncRequestResponseEvent @@ -38,8 +37,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.annotation.DirtiesContext import org.testcontainers.spock.Testcontainers - -import java.util.concurrent.TimeUnit +import spock.util.concurrent.PollingConditions @SpringBootTest(classes =[DataOperationEventConsumer, AsyncRestRequestResponseEventConsumer, RecordFilterStrategies, KafkaConfig]) @DirtiesContext @@ -59,33 +57,38 @@ class SerializationIntegrationSpec extends ConsumerBaseSpec { @Value('${app.ncmp.async-m2m.topic}') def topic - def capturedForwardedEvent - def 'Forwarding DataOperation Event Data.'() { given: 'a data operation cloud event' def cloudEvent = createCloudEvent() + and: 'a flag to track the publish cloud event call' + def publishCloudEventMethodCalled = false + and: 'the (mocked) events publisher will use the flag to indicate if it is called and will capture the cloud event' + mockEventsPublisher.publishCloudEvent('some client topic', 'some-correlation-id', cloudEvent) >> { + publishCloudEventMethodCalled = true + } when: 'send the event' cloudEventKafkaTemplate.send(topic, cloudEvent) - and: 'wait a little for async processing of message' - TimeUnit.MILLISECONDS.sleep(300) then: 'the event has been forwarded' - 1 * mockEventsPublisher.publishCloudEvent('some client topic', 'some-correlation-id', _) >> { args -> { capturedForwardedEvent = args[2] } } - and: 'the forwarded event is identical to the event that was sent' - assert capturedForwardedEvent == cloudEvent + new PollingConditions().within(1) { + assert publishCloudEventMethodCalled == true + } } def 'Forwarding AsyncRestRequestResponse Event Data.'() { given: 'async request response legacy event' def dmiAsyncRequestResponseEvent = new DmiAsyncRequestResponseEvent(eventId: 'my-event-id',eventTarget: 'some client topic') + and: 'a flag to track the publish event call' + def publishEventMethodCalled = false + and: 'the (mocked) events publisher will use the flag to indicate if it is called and will capture the event' + mockEventsPublisher.publishEvent(*_) >> { + publishEventMethodCalled = true + } when: 'send the event' legacyEventKafkaTemplate.send(topic, dmiAsyncRequestResponseEvent) - and: 'wait a little for async processing of message' - TimeUnit.MILLISECONDS.sleep(300) then: 'the event has been forwarded' - 1 * mockEventsPublisher.publishEvent('some client topic', 'my-event-id', _) >> { args -> { capturedForwardedEvent = args[2] } } - and: 'the captured id and target of the forwarded event is same as the one that was sent' - assert capturedForwardedEvent.eventId == dmiAsyncRequestResponseEvent.eventId - assert capturedForwardedEvent.eventTarget == dmiAsyncRequestResponseEvent.eventTarget + new PollingConditions().within(1) { + assert publishEventMethodCalled == true + } } def createCloudEvent() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy index 501714a2b..3b1709d80 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/config/embeddedcache/SynchronizationCacheConfigSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================== - * Copyright (C) 2022-2023 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. @@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ContextConfiguration import spock.lang.Specification +import spock.util.concurrent.PollingConditions import java.util.concurrent.BlockingQueue import java.util.concurrent.TimeUnit @@ -121,8 +122,10 @@ class SynchronizationCacheConfigSpec extends Specification { moduleSyncStartedOnCmHandles.put('testKeyModuleSync', 'toBeExpired' as Object, 1, TimeUnit.SECONDS) then: 'the entry is present in the map' assert moduleSyncStartedOnCmHandles.get('testKeyModuleSync') != null - and: 'the entry expires in less then 2 seconds' - waitMax2SecondsForKeyExpiration(moduleSyncStartedOnCmHandles, 'testKeyModuleSync') + and: 'the entry expires' + new PollingConditions().within(10) { + assert moduleSyncStartedOnCmHandles.get('testKeyModuleSync') == null + } } def 'Time to Live Verify for Data Sync Semaphore'() { @@ -130,16 +133,10 @@ class SynchronizationCacheConfigSpec extends Specification { dataSyncSemaphores.put('testKeyDataSync', Boolean.TRUE, 1, TimeUnit.SECONDS) then: 'the entry is present in the map' assert dataSyncSemaphores.get('testKeyDataSync') != null - and: 'the entry expires in less then 2 seconds' - waitMax2SecondsForKeyExpiration(dataSyncSemaphores, 'testKeyDataSync') - } - - def waitMax2SecondsForKeyExpiration(map, key) { - def count = 0 - while ( map.get(key)!=null && ++count <= 20 ) { - sleep(100) - } - return count < 20 // Should have expired in less the 20 x 100ms = 2 seconds! + and: 'the entry expires' + new PollingConditions().within(10) { + assert dataSyncSemaphores.get('testKeyDataSync') == null + } } } diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy index 09179539a..b7c3b873f 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/lcm/LcmEventsCreatorSpec.groovy @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 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. @@ -173,4 +173,19 @@ class LcmEventsCreatorSpec extends Specification { assert result.eventCorrelationId == cmHandleId assert result.eventId != null } + + def 'Map the LcmEvent for alternate IDs when #scenario'() { + given: 'NCMP cm handle details with current and old alternate IDs' + def existingNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: existingAlternateId, compositeState: new CompositeState(dataSyncEnabled: false)) + def targetNcmpServiceCmHandle = new NcmpServiceCmHandle(cmHandleId: cmHandleId, alternateId: targetAlternateId, compositeState: new CompositeState(dataSyncEnabled: false)) + when: 'the event is populated' + def result = objectUnderTest.populateLcmEvent(cmHandleId, targetNcmpServiceCmHandle, existingNcmpServiceCmHandle) + then: 'the alternate ID is present or is an empty string in the payload' + assert result.event.alternateId == expectedEventAlternateId + where: 'the following alternate IDs are provided' + scenario | existingAlternateId | targetAlternateId || expectedEventAlternateId + 'same new and old alternate ID' | 'someAlternateId' | 'someAlternateId' || 'someAlternateId' + 'blank new and old alternate ID' | '' | '' || '' + 'new alternate id and blank old alternate ID' | '' | 'someAlternateId' || 'someAlternateId' + } } \ No newline at end of file diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy index 3f2148f80..2229b32b0 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy @@ -21,8 +21,6 @@ package org.onap.cps.ncmp.api.impl.operations -import org.onap.cps.events.EventsPublisher - import static org.onap.cps.ncmp.api.impl.events.mapper.CloudEventMapper.toTargetEvent import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_OPERATIONAL import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING @@ -33,8 +31,8 @@ import static org.onap.cps.ncmp.api.NcmpResponseStatus.UNABLE_TO_READ_RESOURCE_D import static org.onap.cps.ncmp.api.NcmpResponseStatus.DMI_SERVICE_NOT_RESPONDING import com.fasterxml.jackson.databind.ObjectMapper +import org.onap.cps.events.EventsPublisher import org.onap.cps.ncmp.api.impl.config.NcmpConfiguration - import org.onap.cps.ncmp.api.impl.exception.HttpClientRequestException import org.onap.cps.ncmp.api.impl.utils.DmiServiceUrlBuilder import org.onap.cps.ncmp.api.impl.utils.context.CpsApplicationContext @@ -49,6 +47,7 @@ import org.springframework.http.ResponseEntity import org.springframework.test.context.ContextConfiguration import org.springframework.http.HttpStatus import spock.lang.Shared +import spock.util.concurrent.PollingConditions import java.util.concurrent.TimeoutException @SpringBootTest @@ -101,20 +100,24 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec { def dataOperationBatchRequestJsonData = TestUtils.getResourceFileContent('dataOperationRequest.json') def dataOperationRequest = spiedJsonObjectMapper.convertJsonString(dataOperationBatchRequestJsonData, DataOperationRequest.class) dataOperationRequest.dataOperationDefinitions[0].cmHandleIds = [cmHandleId] - def requestBodyAsJsonStringArg = null and: 'a positive response from DMI service when it is called with valid request parameters' def responseFromDmi = new ResponseEntity(HttpStatus.ACCEPTED) def expectedDmiBatchResourceDataUrl = "ncmp/v1/data/topic=my-topic-name" def expectedBatchRequestAsJson = '{"operations":[{"operation":"read","operationId":"operational-14","datastore":"ncmp-datastore:passthrough-operational","options":"some option","resourceIdentifier":"some resource identifier","cmHandles":[{"id":"some-cm-handle","cmHandleProperties":{"prop1":"val1"}}]}]}' mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, _, READ.operationName) >> responseFromDmi dmiServiceUrlBuilder.getDataOperationRequestUrl(_, _) >> expectedDmiBatchResourceDataUrl + and: ' a flag to track the post operation call' + def postOperationWithJsonDataMethodCalled = false + and: 'the (mocked) dmi rest client will use the flag to indicate it is called and capture the request body' + mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, expectedBatchRequestAsJson, READ) >> { + postOperationWithJsonDataMethodCalled = true + } when: 'get resource data for group of cm handles are invoked' objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId') - then: 'wait a little to allow execution of service method by task executor (on separate thread)' - Thread.sleep(100) - then: 'validate ncmp generated dmi request body json args' - 1 * mockDmiRestClient.postOperationWithJsonData(expectedDmiBatchResourceDataUrl, _, READ) >> { args -> requestBodyAsJsonStringArg = args[1] } - assert requestBodyAsJsonStringArg == expectedBatchRequestAsJson + then: 'validate the post operation was called and ncmp generated dmi request body json args' + new PollingConditions().within(1) { + assert postOperationWithJsonDataMethodCalled == true + } } def 'Execute (async) data operation from DMI service for #scenario.'() { diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmHandleIdMapperSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmHandleIdMapperSpec.groovy index a625e3e46..1b323a216 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmHandleIdMapperSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/utils/CmHandleIdMapperSpec.groovy @@ -78,6 +78,15 @@ class CmHandleIdMapperSpec extends Specification { assert objectUnderTest.cmHandleIdToAlternateId('cached cmhandle id') == null } + def 'Attempt to remove a non-existing entry from the cache.'() { + when: 'removing an entry that is not cached' + objectUnderTest.removeMapping('non-cached cmhandle id') + then: 'deleting from the cmhandle cache returns null' + assert alternateIdPerCmHandle.remove('non-cached cmhandle id') == null + and: 'removal from the alternate id cache is skipped' + 0 * cmHandlePerAlternateId.remove(_) + } + def 'Cannot update existing alternate id.'() { given: 'attempt to update an existing alternate id' objectUnderTest.addMapping('cached cmhandle id', 'other id') diff --git a/cps-parent/pom.xml b/cps-parent/pom.xml index 2856b9874..2e81b004e 100644 --- a/cps-parent/pom.xml +++ b/cps-parent/pom.xml @@ -32,7 +32,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT pom diff --git a/cps-path-parser/pom.xml b/cps-path-parser/pom.xml index 4b743a725..e6e00dcf3 100644 --- a/cps-path-parser/pom.xml +++ b/cps-path-parser/pom.xml @@ -23,7 +23,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-rest/pom.xml b/cps-rest/pom.xml index 0b31577ae..022c3b8eb 100644 --- a/cps-rest/pom.xml +++ b/cps-rest/pom.xml @@ -28,7 +28,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-ri/pom.xml b/cps-ri/pom.xml index 600676838..2fd369b2a 100644 --- a/cps-ri/pom.xml +++ b/cps-ri/pom.xml @@ -26,7 +26,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-service/pom.xml b/cps-service/pom.xml index e661f3421..de716dfa5 100644 --- a/cps-service/pom.xml +++ b/cps-service/pom.xml @@ -29,7 +29,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java index 0f9eb3c64..14b949e5a 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsModuleServiceImpl.java @@ -117,8 +117,8 @@ public class CpsModuleServiceImpl implements CpsModuleService { final Collection anchorNames = cpsAnchorService.getAnchors(dataspaceName, schemaSetNames) .stream().map(Anchor::getName).collect(Collectors.toSet()); cpsAnchorService.deleteAnchors(dataspaceName, anchorNames); - cpsModulePersistenceService.deleteUnusedYangResourceModules(); cpsModulePersistenceService.deleteSchemaSets(dataspaceName, schemaSetNames); + cpsModulePersistenceService.deleteUnusedYangResourceModules(); for (final String schemaSetName : schemaSetNames) { yangTextSchemaSourceSetCache.removeFromCache(dataspaceName, schemaSetName); } diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml index cbb5155a3..eca8871c6 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-app/pom.xml @@ -22,7 +22,7 @@ org.onap.cps dmi-plugin-demo-and-csit-stub - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT dmi-plugin-demo-and-csit-stub-app diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml index 9b6e40254..d3142f821 100644 --- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/pom.xml @@ -21,7 +21,7 @@ org.onap.cps dmi-plugin-demo-and-csit-stub - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT dmi-plugin-demo-and-csit-stub-service diff --git a/dmi-plugin-demo-and-csit-stub/pom.xml b/dmi-plugin-demo-and-csit-stub/pom.xml index d708f7c6e..9fb40e3cd 100644 --- a/dmi-plugin-demo-and-csit-stub/pom.xml +++ b/dmi-plugin-demo-and-csit-stub/pom.xml @@ -22,7 +22,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/docs/api/swagger/ncmp/openapi.yaml b/docs/api/swagger/ncmp/openapi.yaml index 8098faefc..a1cc5d9ba 100644 --- a/docs/api/swagger/ncmp/openapi.yaml +++ b/docs/api/swagger/ncmp/openapi.yaml @@ -918,9 +918,9 @@ paths: - network-cm-proxy /v1/ch/{cm-handle}/modules/definitions: get: - description: "Fetch all module definitions (name, revision, yang resource) for\ - \ a given cm handle" - operationId: getModuleDefinitionsByCmHandleId + description: "Get module definitions (module name, revision, yang resource)\ + \ with options to filter on module name and revision" + operationId: getModuleDefinitions parameters: - description: "The identifier for a network function, network element, subnetwork\ \ or any other cm object by managed Network CM Proxy" @@ -930,6 +930,21 @@ paths: schema: example: my-cm-handle type: string + - description: Filter for a module name.This is an optional parameter + in: query + name: module-name + required: false + schema: + example: my-module + type: string + - description: Filter for a module revision.This is an optional parameter and + ignored when no module name is supplied + in: query + name: revision + required: false + schema: + example: 2024-01-22 + type: string responses: "200": content: @@ -969,8 +984,7 @@ paths: schema: $ref: '#/components/schemas/ErrorMessage' description: Internal Server Error - summary: "Fetch all module definitions (name, revision, yang resource) for a\ - \ given cm handle" + summary: Get module definitions tags: - network-cm-proxy /v1/ch/searches: @@ -1666,6 +1680,23 @@ components: schema: default: / type: string + moduleNameInQuery: + description: Filter for a module name.This is an optional parameter + in: query + name: module-name + required: false + schema: + example: my-module + type: string + revisionInQuery: + description: Filter for a module revision.This is an optional parameter and + ignored when no module name is supplied + in: query + name: revision + required: false + schema: + example: 2024-01-22 + type: string dataSyncEnabled: description: Is used to enable or disable the data synchronization flag in: query diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 4c93dd1f4..191a04d1a 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -16,6 +16,34 @@ CPS Release Notes .. * * * NEW DELHI * * * .. ========================= +Version: 3.4.4 +============== + +Release Data +------------ + ++--------------------------------------+--------------------------------------------------------+ +| **CPS Project** | | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Docker images** | onap/cps-and-ncmp:3.4.4 | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release designation** | 3.4.4 New Delhi | +| | | ++--------------------------------------+--------------------------------------------------------+ +| **Release date** | Not yet released | +| | | ++--------------------------------------+--------------------------------------------------------+ + +Bug Fixes +--------- +3.4.4 + +Features +-------- + + Version: 3.4.3 ============== @@ -32,14 +60,16 @@ Release Data | **Release designation** | 3.4.3 New Delhi | | | | +--------------------------------------+--------------------------------------------------------+ -| **Release date** | Not yet released | +| **Release date** | 2024 February 07 | | | | +--------------------------------------+--------------------------------------------------------+ Bug Fixes --------- 3.4.3 - + - `CPS-2000 `_ Fix for Schema object cache not being distributed. + - `CPS-2027 `_ Fixes for upgrade yang modules using module set tag. + - `CPS-2070 `_ Add retry interval for Kafka consumer. Features -------- diff --git a/integration-test/pom.xml b/integration-test/pom.xml index 3ac096418..73998cd13 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -23,7 +23,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml diff --git a/jacoco-report/pom.xml b/jacoco-report/pom.xml index 47486e85e..60aa6b465 100644 --- a/jacoco-report/pom.xml +++ b/jacoco-report/pom.xml @@ -5,7 +5,7 @@ org.onap.cps cps-parent - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT ../cps-parent/pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 42d2bfa3a..3f67efb53 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.onap.cps cps-aggregator - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT pom cps diff --git a/releases/3.4.3-container.yaml b/releases/3.4.3-container.yaml new file mode 100644 index 000000000..685e23008 --- /dev/null +++ b/releases/3.4.3-container.yaml @@ -0,0 +1,8 @@ +distribution_type: container +container_release_tag: 3.4.3 +project: cps +log_dir: cps-maven-docker-stage-master/934/ +ref: 7ce495b1e5871d42392b0b45fd3babd9fd5bd634 +containers: + - name: 'cps-and-ncmp' + version: '3.4.3-20240207T150310Z' \ No newline at end of file diff --git a/releases/3.4.3.yaml b/releases/3.4.3.yaml new file mode 100644 index 000000000..43423e1cd --- /dev/null +++ b/releases/3.4.3.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: cps-maven-stage-master/942/ +project: cps +version: 3.4.3 \ No newline at end of file diff --git a/spotbugs/pom.xml b/spotbugs/pom.xml index 8fcf04031..4a15e4e3d 100644 --- a/spotbugs/pom.xml +++ b/spotbugs/pom.xml @@ -25,7 +25,7 @@ 4.0.0 org.onap.cps spotbugs - 3.4.3-SNAPSHOT + 3.4.4-SNAPSHOT https://nexus.onap.org diff --git a/version.properties b/version.properties index 6c691bf22..369d36341 100644 --- a/version.properties +++ b/version.properties @@ -22,7 +22,7 @@ major=3 minor=4 -patch=3 +patch=4 base_version=${major}.${minor}.${patch}