Remove subscriptionModelLoader flag 54/137354/2
authormpriyank <priyank.maheshwari@est.tech>
Fri, 23 Feb 2024 10:35:37 +0000 (10:35 +0000)
committerPriyank Maheshwari <priyank.maheshwari@est.tech>
Fri, 23 Feb 2024 15:50:08 +0000 (15:50 +0000)
- removed the flag as the functionality around model loader is stable
  now
- removed the config parameter from the application yaml file as well

Issue-ID: CPS-2112
Change-Id: Ie4e3317c0689615b900dcd9bbf1896bc3a5f37b3
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
cps-application/src/main/resources/application.yml
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumer.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoader.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmNotificationSubscriptionNcmpInEventConsumerSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/init/CmDataSubscriptionModelLoaderSpec.groovy
cps-ncmp-service/src/test/resources/application.yml
integration-test/src/test/resources/application.yml

index e56e0e1..9f03fc2 100644 (file)
@@ -200,7 +200,6 @@ ncmp:
             parallelism-level: 10
 
     model-loader:
-        subscription: true
         maximum-attempt-count: 20
 
 # Custom Hazelcast Config.
index bc798af..d3bde01 100644 (file)
@@ -37,9 +37,6 @@ public class CmNotificationSubscriptionNcmpInEventConsumer {
     @Value("${notification.enabled:true}")
     private boolean notificationFeatureEnabled;
 
-    @Value("${ncmp.model-loader.subscription:false}")
-    private boolean subscriptionModelLoaderEnabled;
-
     /**
      * Consume the specified event.
      *
@@ -51,10 +48,8 @@ public class CmNotificationSubscriptionNcmpInEventConsumer {
         final CloudEvent cloudEvent = subscriptionEventConsumerRecord.value();
         final CmNotificationSubscriptionNcmpInEvent cmNotificationSubscriptionNcmpInEvent =
                 toTargetEvent(cloudEvent, CmNotificationSubscriptionNcmpInEvent.class);
-        if (subscriptionModelLoaderEnabled) {
-            log.info("Subscription with name {} to be mapped to hazelcast object...",
-                    cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
-        }
+        log.info("Subscription with name {} to be mapped to hazelcast object...",
+                cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
         if ("subscriptionCreated".equals(cloudEvent.getType()) && cmNotificationSubscriptionNcmpInEvent != null) {
             log.info("Subscription for ClientID {} with name {} ...", cloudEvent.getSource(),
                     cmNotificationSubscriptionNcmpInEvent.getData().getSubscriptionId());
index 7cee87a..4c31719 100644 (file)
@@ -32,7 +32,6 @@ import org.onap.cps.api.CpsModuleService;
 import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException;
 import org.onap.cps.ncmp.api.impl.operations.DatastoreType;
 import org.onap.cps.spi.exceptions.AlreadyDefinedException;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 @Slf4j
@@ -45,24 +44,16 @@ public class CmDataSubscriptionModelLoader extends AbstractModelLoader {
     private static final String REGISTRY_DATANODE_NAME = "datastores";
 
     public CmDataSubscriptionModelLoader(final CpsDataspaceService cpsDataspaceService,
-                                         final CpsModuleService cpsModuleService,
-                                         final CpsAnchorService cpsAnchorService,
-                                         final CpsDataService cpsDataService) {
+            final CpsModuleService cpsModuleService, final CpsAnchorService cpsAnchorService,
+            final CpsDataService cpsDataService) {
         super(cpsDataspaceService, cpsModuleService, cpsAnchorService, cpsDataService);
     }
 
-    @Value("${ncmp.model-loader.subscription:true}")
-    private boolean subscriptionModelLoaderEnabled;
-
     @Override
     public void onboardOrUpgradeModel() {
-        if (subscriptionModelLoaderEnabled) {
-            waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME);
-            onboardSubscriptionModels();
-            log.info("Subscription Models onboarded successfully");
-        } else {
-            log.info("Subscription Model Loader is disabled");
-        }
+        waitUntilDataspaceIsAvailable(NCMP_DATASPACE_NAME);
+        onboardSubscriptionModels();
+        log.info("Subscription Models onboarded successfully");
     }
 
     private void onboardSubscriptionModels() {
index 6a3d4be..1074229 100644 (file)
@@ -71,8 +71,6 @@ class CmNotificationSubscriptionNcmpInEventConsumerSpec extends MessagingBaseSpe
             def consumerRecord = new ConsumerRecord<String, CloudEvent>('topic-name', 0, 0, 'event-key', testCloudEventSent)
         and: 'notifications are enabled'
             objectUnderTest.notificationFeatureEnabled = true
-        and: 'subscription model loader is enabled'
-            objectUnderTest.subscriptionModelLoaderEnabled = true
         when: 'the valid event is consumed'
             objectUnderTest.consumeSubscriptionEvent(consumerRecord)
         then: 'an event is logged with level INFO'
index bde9961..f3b405b 100644 (file)
 
 package org.onap.cps.ncmp.init
 
-import org.onap.cps.api.CpsAnchorService
-import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
-import org.onap.cps.spi.exceptions.AlreadyDefinedException
-
-import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
-
 import ch.qos.logback.classic.Level
 import ch.qos.logback.classic.Logger
 import ch.qos.logback.core.read.ListAppender
-import org.onap.cps.api.CpsDataspaceService
+import org.onap.cps.api.CpsAnchorService
 import org.onap.cps.api.CpsDataService
+import org.onap.cps.api.CpsDataspaceService
 import org.onap.cps.api.CpsModuleService
+import org.onap.cps.ncmp.api.impl.exception.NcmpStartUpException
+import org.onap.cps.spi.exceptions.AlreadyDefinedException
 import org.onap.cps.spi.model.Dataspace
 import org.slf4j.LoggerFactory
 import org.springframework.boot.context.event.ApplicationReadyEvent
 import org.springframework.context.annotation.AnnotationConfigApplicationContext
 import spock.lang.Specification
 
+import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DATASPACE_NAME
+
 class CmDataSubscriptionModelLoaderSpec extends Specification {
 
     def mockCpsDataspaceService = Mock(CpsDataspaceService)
@@ -67,9 +66,7 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
     }
 
     def 'Onboard subscription model via application ready event.'() {
-        given:'model loader is enabled'
-            objectUnderTest.subscriptionModelLoaderEnabled = true
-        and: 'dataspace is ready for use'
+        given: 'dataspace is ready for use'
             mockCpsDataspaceService.getDataspace(NCMP_DATASPACE_NAME) >> new Dataspace('')
         when: 'the application is ready'
             objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
@@ -81,14 +78,14 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
             1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '{"datastores":{}}', _)
         and: 'the data service is called once to create datastore for Passthrough-operational'
             1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores',
-                    '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _)
+                '{"datastore":[{"name":"ncmp-datastore:passthrough-operational","cm-handles":{}}]}', _, _)
         and: 'the data service is called once to create datastore for Passthrough-running'
             1 * mockCpsDataService.saveData(NCMP_DATASPACE_NAME, 'cm-data-subscriptions', '/datastores',
-                    '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _)
+                '{"datastore":[{"name":"ncmp-datastore:passthrough-running","cm-handles":{}}]}', _, _)
     }
 
     def 'Create node for datastore with already defined exception.'() {
-        given:'the data service throws an Already Defined exception'
+        given: 'the data service throws an Already Defined exception'
             mockCpsDataService.saveData(*_) >> { throw AlreadyDefinedException.forDataNodes([], 'some context') }
         when: 'attempt to create datastore'
             objectUnderTest.createDatastore('some datastore')
@@ -110,16 +107,4 @@ class CmDataSubscriptionModelLoaderSpec extends Specification {
             assert thrown.details.contains('test message')
     }
 
-    def 'Subscription model loader disabled.' () {
-        given: 'model loader is disabled'
-            objectUnderTest.subscriptionModelLoaderEnabled = false
-        when: 'application is ready'
-            objectUnderTest.onApplicationEvent(Mock(ApplicationReadyEvent))
-        then: 'no interaction with admin service'
-            0 * mockCpsDataspaceService.getDataspace(_)
-        then: 'a message is logged that the function is disabled'
-            def logs = loggingListAppender.list.toString()
-            assert logs.contains('Subscription Model Loader is disabled')
-    }
-
 }
index a4bb4e8..a3283ff 100644 (file)
@@ -50,8 +50,6 @@ ncmp:
         async-executor:
             parallelism-level: 3
 
-    model-loader:
-        subscription: true
 
 # Custom Hazelcast Config.
 hazelcast:
index d1307cd..f77cb02 100644 (file)
@@ -195,7 +195,6 @@ ncmp:
       parallelism-level: 1
 
   model-loader:
-    subscription: true
     maximum-attempt-count: 20
 
   servlet: