From: Atul Agarwal Date: Mon, 25 Oct 2021 15:44:45 +0000 (+0000) Subject: Resolved bug 1719 - POL hangs waiting for webhook response X-Git-Tag: v9.1.5^0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F11290%2F2;p=osm%2FPOL.git Resolved bug 1719 - POL hangs waiting for webhook response Change-Id: Id12dc098053557c2904754b29371c693c1b1054b Signed-off-by: Atul Agarwal --- diff --git a/osm_policy_module/alarming/service.py b/osm_policy_module/alarming/service.py index 1cc1a8d..ec1b354 100644 --- a/osm_policy_module/alarming/service.py +++ b/osm_policy_module/alarming/service.py @@ -192,7 +192,7 @@ class AlarmingService: log.info("Executing request to url %s for vnf alarm %s with status %s", action.url, alarm.alarm_id, status) try: - requests.post(url=action.url, json=json.dumps(payload)) + requests.post(url=action.url, json=json.dumps(payload), timeout=10) except RequestException as e: log.info("Error connecting to url %s", action.url) log.debug("RequestException %s", e) diff --git a/osm_policy_module/tests/unit/alarming/test_alarming_service.py b/osm_policy_module/tests/unit/alarming/test_alarming_service.py index 4edfa86..51edef2 100644 --- a/osm_policy_module/tests/unit/alarming/test_alarming_service.py +++ b/osm_policy_module/tests/unit/alarming/test_alarming_service.py @@ -50,15 +50,15 @@ class TestAlarmingService(TestCase): service = AlarmingService(self.config) self.loop.run_until_complete(service.handle_alarm('test_id', 'alarm', {})) - requests_post.assert_called_once_with(json='{}', url='http://alarm-url/') + requests_post.assert_called_once_with(json='{}', url='http://alarm-url/', timeout=10) requests_post.reset_mock() self.loop.run_until_complete(service.handle_alarm('test_id', 'ok', {})) - requests_post.assert_called_once_with(json='{}', url='http://ok-url/') + requests_post.assert_called_once_with(json='{}', url='http://ok-url/', timeout=10) requests_post.reset_mock() self.loop.run_until_complete(service.handle_alarm('test_id', 'insufficient-data', {})) - requests_post.assert_called_once_with(json='{}', url='http://insufficient-data-url/') + requests_post.assert_called_once_with(json='{}', url='http://insufficient-data-url/', timeout=10) @mock.patch.object(VnfAlarmRepository, 'get') @mock.patch('requests.post')