Fix bugs in nbinotifications module 47/110947/2
authorGilles Thouenon <gilles.thouenon@orange.com>
Thu, 21 Mar 2024 10:23:56 +0000 (11:23 +0100)
committerGilles Thouenon <gilles.thouenon@orange.com>
Thu, 21 Mar 2024 13:21:29 +0000 (14:21 +0100)
- fix NPE issue in NbiNotificationsHandler
- fix message issue in PceNotificationHandler of service handler
- add small delay in functional test execution to let the notification
being sent in kafka broker
- fix issue when uninstalling the feature (publisher sessions with
kafka server remained open)

JIRA: TRNSPRTPCE-790
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I914f3c2313e17ec25b36633ef8af26ff8f8394bf

nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java
nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsHandler.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java
tests/transportpce_tests/with_docker/test02_nbinotifications.py

index 7eda70e1e864e439de77a8fc414495aad2444021..6c61bfa25ecf1c4c166d34c426e805ff9443b1fa 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.transportpce.nbinotifications.impl;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -58,8 +57,8 @@ public class NbiNotificationsProvider {
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsProvider.class);
-    private static Map<String, Publisher<NotificationProcessService>> publishersServiceMap =  new HashMap<>();
-    private static Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap =  new HashMap<>();
+    private Map<String, Publisher<NotificationProcessService>> publishersServiceMap;
+    private Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap;
     private Registration listenerRegistration;
     private Registration rpcRegistration;
     private NetworkTransactionService networkTransactionService;
@@ -99,7 +98,7 @@ public class NbiNotificationsProvider {
         }
         JsonStringConverter<NotificationTapiService> converterTapiService =
                 new JsonStringConverter<>(bindingDOMCodecServices);
-        LOG.info("baozhi tapi converter: {}", converterTapiService);
+        LOG.info("tapi converter: {}", converterTapiService);
         topicManager.setTapiConverter(converterTapiService);
 
         rpcRegistration = rpcProviderService.registerRpcImplementations(
@@ -118,6 +117,8 @@ public class NbiNotificationsProvider {
         listenerRegistration = notificationService.registerCompositeListener(
             notificationsListener.getCompositeListener());
         topicManager.setNbiNotificationsListener(notificationsListener);
+        publishersServiceMap = topicManager.getProcessTopicMap();
+        publishersAlarmMap = topicManager.getAlarmTopicMap();
         LOG.info("NbiNotificationsProvider Session Initiated");
     }
 
index ad38b819c947f8f9e89538dcfc1015d6d8a5d054..917f40c7dd681221e59d806f0bb01c4b2dba6b9e 100644 (file)
@@ -67,15 +67,15 @@ public class NbiNotificationsHandler {
                 .setServiceName(notification.getServiceName())
                 .setServiceZEnd(notification.getServiceZEnd());
 
-        if (notification.getIsTempService()) {
+        if (notification.getIsTempService() == null || !notification.getIsTempService()) {
+            publisher.sendEvent(notificationProcessServiceBuilder
+                .build(), notification.getConnectionType().getName());
+        } else {
             // A-to-Z and Z-to-A containers are only needed for temp-service-create notification
             publisher.sendEvent(notificationProcessServiceBuilder
                     .setAToZ(notification.getAToZ())
                     .setZToA(notification.getZToA())
                     .build(), notification.getConnectionType().getName());
-        } else {
-            publisher.sendEvent(notificationProcessServiceBuilder
-                    .build(), notification.getConnectionType().getName());
         }
     }
 
index 6cb4540aad398a19123de5109979cb032aed520f..9ce49beebabc11b418824bbe80f3d0d5cae033d5 100644 (file)
@@ -286,7 +286,7 @@ public class PceNotificationHandler implements PceListener {
             sendNbiNotification(
                 nbiNotificationBuilder
                     .setResponseFailed("")
-                    .setMessage("{} Service deleted !")
+                    .setMessage("Service deleted !")
                     .setOperationalState(State.Degraded)
                     .build());
         } else {
index 92aed86cc19be9a2227a33f9f1a22d5d630e2ccd..053b16b5ca7b985b5342e57690c7eb486df4f143 100644 (file)
@@ -270,6 +270,7 @@ class TransportNbiNotificationstesting(unittest.TestCase):
             "administrative-state": "outOfService",
             "port-qual": "roadm-external"
         }))
+        time.sleep(5)
 
     def test_19_get_notifications_alarm_service1(self):
         response = test_utils.transportpce_api_rpc_request(
@@ -291,6 +292,7 @@ class TransportNbiNotificationstesting(unittest.TestCase):
             "administrative-state": "inService",
             "port-qual": "roadm-external"
         }))
+        time.sleep(5)
 
     def test_21_get_notifications_alarm_service1(self):
         self.test_17_get_notifications_alarm_service1()