From b00f8180e8d80a28e3f66c5693b21d9a06ae31b1 Mon Sep 17 00:00:00 2001 From: Gilles Thouenon Date: Thu, 21 Mar 2024 11:23:56 +0100 Subject: [PATCH] Fix bugs in nbinotifications module - 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 Change-Id: I914f3c2313e17ec25b36633ef8af26ff8f8394bf --- .../nbinotifications/impl/NbiNotificationsProvider.java | 9 +++++---- .../listener/NbiNotificationsHandler.java | 8 ++++---- .../servicehandler/listeners/PceNotificationHandler.java | 2 +- .../with_docker/test02_nbinotifications.py | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java index 7eda70e1e..6c61bfa25 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/impl/NbiNotificationsProvider.java @@ -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> publishersServiceMap = new HashMap<>(); - private static Map> publishersAlarmMap = new HashMap<>(); + private Map> publishersServiceMap; + private Map> publishersAlarmMap; private Registration listenerRegistration; private Registration rpcRegistration; private NetworkTransactionService networkTransactionService; @@ -99,7 +98,7 @@ public class NbiNotificationsProvider { } JsonStringConverter 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"); } diff --git a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsHandler.java b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsHandler.java index ad38b819c..917f40c7d 100644 --- a/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsHandler.java +++ b/nbinotifications/src/main/java/org/opendaylight/transportpce/nbinotifications/listener/NbiNotificationsHandler.java @@ -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()); } } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java index 6cb4540aa..9ce49beeb 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceNotificationHandler.java @@ -286,7 +286,7 @@ public class PceNotificationHandler implements PceListener { sendNbiNotification( nbiNotificationBuilder .setResponseFailed("") - .setMessage("{} Service deleted !") + .setMessage("Service deleted !") .setOperationalState(State.Degraded) .build()); } else { diff --git a/tests/transportpce_tests/with_docker/test02_nbinotifications.py b/tests/transportpce_tests/with_docker/test02_nbinotifications.py index 92aed86cc..053b16b5c 100644 --- a/tests/transportpce_tests/with_docker/test02_nbinotifications.py +++ b/tests/transportpce_tests/with_docker/test02_nbinotifications.py @@ -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() -- 2.36.6