Reduce the number of service notifications sent 56/97056/1
authorThierry Jiao <thierry.jiao@orange.com>
Tue, 1 Jun 2021 13:47:36 +0000 (15:47 +0200)
committerBalagangadhar Bathula <bb4341@att.com>
Mon, 2 Aug 2021 19:10:08 +0000 (15:10 -0400)
- Delete 'PCE calculation done OK' notification sent by
pceListenerImpl during serviceCreate
- Delete 'ServiceCreate request received' notification sent by
serviceHandlerImpl during serviceCreate
- Delete 'ServiceDelete request received' notification sent by
serviceHandlerImpl during serviceDelete
- Update the functional test test_nbinotifications

JIRA: TRNSPRTPCE-447
Signed-off-by: Thierry Jiao <thierry.jiao@orange.com>
Change-Id: Id52eb6bcfb63753158294a227bcaeb5c40a3c972

servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/PceListenerImpl.java
tests/transportpce_tests/2.2.1/test_nbinotifications.py

index f37583482c36c31afa90b34a998ea5c2bab4dd5a..bd8897c65e6d9593de83f8a67cf43707b48da998 100644 (file)
@@ -178,17 +178,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                     input, ResponseCodes.FINAL_ACK_YES,
                     validationResult.getResultMessage(), ResponseCodes.RESPONSE_FAILED);
         }
-        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
-                .setServiceName(input.getServiceName())
-                .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
-                .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
-                .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
-                .setResponseFailed("")
-                .setMessage("ServiceCreate request received ...")
-                .setOperationalState(State.OutOfService)
-                .setTopic(topic)
-                .build();
-        sendNbiNotification(nbiNotification);
         this.pceListenerImpl.setInput(new ServiceInput(input));
         this.pceListenerImpl.setServiceReconfigure(false);
         this.pceListenerImpl.setserviceDataStoreOperations(this.serviceDataStoreOperations);
@@ -199,12 +188,15 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
         PathComputationRequestOutput output = this.pceServiceWrapper.performPCE(input, true);
         if (output == null) {
             LOG.warn(SERVICE_CREATE_MSG, LogMessages.ABORT_PCE_FAILED);
-            nbiNotification = new PublishNotificationServiceBuilder(nbiNotification)
+            sendNbiNotification(new PublishNotificationServiceBuilder()
+                    .setServiceName(input.getServiceName())
+                    .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
+                    .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
+                    .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
                     .setResponseFailed(LogMessages.ABORT_PCE_FAILED)
                     .setMessage("ServiceCreate request failed ...")
                     .setOperationalState(State.Degraded)
-                    .build();
-            sendNbiNotification(nbiNotification);
+                    .build());
             return ModelMappingUtils.createCreateServiceReply(input, ResponseCodes.FINAL_ACK_YES,
                     LogMessages.PCE_FAILED, ResponseCodes.RESPONSE_FAILED);
         }
@@ -245,17 +237,6 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
                     LogMessages.serviceNotInDS(serviceName), ResponseCodes.RESPONSE_FAILED);
         }
         service = serviceOpt.get();
-        PublishNotificationService nbiNotification = new PublishNotificationServiceBuilder()
-                .setServiceName(service.getServiceName())
-                .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
-                .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
-                .setCommonId(service.getCommonId()).setConnectionType(service.getConnectionType())
-                .setMessage("ServiceDelete request received ...")
-                .setOperationalState(service.getOperationalState())
-                .setResponseFailed("")
-                .setTopic(topic)
-                .build();
-        sendNbiNotification(nbiNotification);
         LOG.debug("serviceDelete: Service '{}' found in datastore", serviceName);
         this.pceListenerImpl.setInput(new ServiceInput(input));
         this.pceListenerImpl.setServiceReconfigure(false);
@@ -272,12 +253,15 @@ public class ServicehandlerImpl implements OrgOpenroadmServiceService {
 
         if (output == null) {
             LOG.error(SERVICE_DELETE_MSG, LogMessages.RENDERER_DELETE_FAILED);
-            nbiNotification = new PublishNotificationServiceBuilder(nbiNotification)
+            sendNbiNotification(new PublishNotificationServiceBuilder()
+                    .setServiceName(service.getServiceName())
+                    .setServiceAEnd(new ServiceAEndBuilder(service.getServiceAEnd()).build())
+                    .setServiceZEnd(new ServiceZEndBuilder(service.getServiceZEnd()).build())
+                    .setCommonId(service.getCommonId()).setConnectionType(service.getConnectionType())
                     .setMessage("ServiceDelete request failed ...")
                     .setOperationalState(State.InService)
                     .setResponseFailed(LogMessages.RENDERER_DELETE_FAILED)
-                    .build();
-            sendNbiNotification(nbiNotification);
+                    .build());
             return ModelMappingUtils.createDeleteServiceReply(
                     input, ResponseCodes.FINAL_ACK_YES,
                     LogMessages.RENDERER_DELETE_FAILED, ResponseCodes.RESPONSE_FAILED);
index eed0c383318e2a8f3e5d67a36b4df708c66aa30d..d154d9bc6772f7af8781493bad1b290a021d7aa9 100644 (file)
@@ -163,9 +163,6 @@ public class PceListenerImpl implements TransportpcePceListener {
                 return false;
             case Successful:
                 LOG.info("PCE calculation done OK !");
-                nbiNotification = publishNotificationServiceBuilder.setMessage("PCE calculation done OK !")
-                        .setResponseFailed("").setOperationalState(State.OutOfService).build();
-                sendNbiNotification(nbiNotification);
                 return true;
             default:
                 LOG.error("PCE path computation returned an unknown RpcStatusEx code {}",
index 628fa8f1085def90355db4a41994dbd4bb6ad457..00bcae7eb135930ae57542970aa3ae431a5b31e4 100644 (file)
@@ -117,6 +117,7 @@ class TransportNbiNotificationstesting(unittest.TestCase):
     @classmethod
     def setUpClass(cls):
         # TODO: for lighty manage the activation of NBI notification feature
+        cls.init_failed = False
         cls.processes = test_utils.start_tpce()
         # NBI notification feature is not installed by default in Karaf
         if "USE_LIGHTY" not in os.environ or os.environ['USE_LIGHTY'] != 'True':
@@ -229,10 +230,8 @@ class TransportNbiNotificationstesting(unittest.TestCase):
         response = test_utils.get_notifications_service_request(data)
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
-        self.assertEqual(res['output']['notification-service'][-2]['connection-type'], 'service')
-        self.assertEqual(res['output']['notification-service'][-2]['message'], 'ServiceCreate request received ...')
         self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service')
         self.assertEqual(res['output']['notification-service'][-1]['message'], 'ServiceCreate request failed ...')
         self.assertEqual(res['output']['notification-service'][-1]['response-failed'],
                          'PCE path computation failed !')
@@ -303,12 +302,8 @@ class TransportNbiNotificationstesting(unittest.TestCase):
         response = test_utils.get_notifications_service_request(data)
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertEqual(res['output']['notification-service'][-3]['service-name'], 'service1')
-        self.assertEqual(res['output']['notification-service'][-3]['connection-type'], 'service')
-        self.assertEqual(res['output']['notification-service'][-3]['message'], 'ServiceCreate request received ...')
-        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
-        self.assertEqual(res['output']['notification-service'][-2]['message'], 'PCE calculation done OK !')
         self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service')
         self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service implemented !')
         time.sleep(2)
 
@@ -331,10 +326,8 @@ class TransportNbiNotificationstesting(unittest.TestCase):
         response = test_utils.get_notifications_service_request(data)
         self.assertEqual(response.status_code, requests.codes.ok)
         res = response.json()
-        self.assertEqual(res['output']['notification-service'][-2]['service-name'], 'service1')
-        self.assertEqual(res['output']['notification-service'][-2]['connection-type'], 'service')
-        self.assertEqual(res['output']['notification-service'][-2]['message'], 'ServiceDelete request received ...')
         self.assertEqual(res['output']['notification-service'][-1]['service-name'], 'service1')
+        self.assertEqual(res['output']['notification-service'][-1]['connection-type'], 'service')
         self.assertEqual(res['output']['notification-service'][-1]['message'], 'Service deleted !')
         time.sleep(2)