From 42684453fa92100a503c76e670d1fd3926ed6fb5 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Mon, 9 Sep 2024 11:28:10 -0400 Subject: [PATCH 1/3] Handled ConnectError --- models/path.py | 2 ++ tests/unit/models/test_path.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/models/path.py b/models/path.py index 940108dd..1dad2dba 100644 --- a/models/path.py +++ b/models/path.py @@ -147,6 +147,8 @@ def get_paths(circuit, max_paths=2, **kwargs) -> list[dict]: api_reply = httpx.post(endpoint, json=request_data, timeout=10) except httpx.TimeoutException as err: raise PathFinderException(str(err)) from err + except httpx.ConnectError as err: + raise PathFinderException(str(err)) from err if api_reply.status_code >= 400: raise PathFinderException(api_reply.text) diff --git a/tests/unit/models/test_path.py b/tests/unit/models/test_path.py index 32d35b76..04a0fb5f 100644 --- a/tests/unit/models/test_path.py +++ b/tests/unit/models/test_path.py @@ -3,7 +3,7 @@ from unittest.mock import call, patch, Mock, MagicMock import pytest from napps.kytos.mef_eline import settings -from httpx import TimeoutException +from httpx import TimeoutException, ConnectError from kytos.core.common import EntityStatus from kytos.core.link import Link from kytos.core.switch import Switch @@ -877,6 +877,11 @@ def test_get_disjoint_paths_error(self, _, mock_log, mock_post): assert len(list(path)) == 0 assert mock_log.error.call_count == 1 + mock_post.side_effect = ConnectError('mock') + path = DynamicPathManager.get_disjoint_paths(evc, unwanted_path) + assert len(list(path)) == 0 + assert mock_log.error.call_count == 2 + def test_get_shared_components(self): """Test get_shared_components""" mock_path = {"hops": [ From f5d3ffb9e477075e1d5b32c97f4420b97c2e5d72 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Mon, 9 Sep 2024 13:28:55 -0400 Subject: [PATCH 2/3] United httpx errors into RequestError --- models/path.py | 4 +--- tests/unit/models/test_path.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/models/path.py b/models/path.py index 1dad2dba..d3e308c2 100644 --- a/models/path.py +++ b/models/path.py @@ -145,9 +145,7 @@ def get_paths(circuit, max_paths=2, **kwargs) -> list[dict]: request_data.update(kwargs) try: api_reply = httpx.post(endpoint, json=request_data, timeout=10) - except httpx.TimeoutException as err: - raise PathFinderException(str(err)) from err - except httpx.ConnectError as err: + except httpx.RequestError as err: raise PathFinderException(str(err)) from err if api_reply.status_code >= 400: diff --git a/tests/unit/models/test_path.py b/tests/unit/models/test_path.py index 04a0fb5f..aa8c315f 100644 --- a/tests/unit/models/test_path.py +++ b/tests/unit/models/test_path.py @@ -853,7 +853,8 @@ def test_get_disjoint_paths_simple_evc(self, mock_httpx_post): @patch("napps.kytos.mef_eline.models.path.log") @patch("time.sleep") def test_get_disjoint_paths_error(self, _, mock_log, mock_post): - """Test get_disjoint_paths""" + """Test get_disjoint_paths with reported errors. These are caught under + httpx.RequestError.""" mock_post.side_effect = TimeoutException('mock') unwanted_path = [ Link( From e3bf7262b64972ada2f73a8d4d5c4669a61356b5 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Mon, 9 Sep 2024 13:30:44 -0400 Subject: [PATCH 3/3] Updated version --- CHANGELOG.rst | 7 +++++++ kytos.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ec2ecdd9..c67da439 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,13 @@ All notable changes to the MEF_ELine NApp will be documented in this file. [UNRELEASED] - Under development ******************************** +[2024.1.4] - 2024-09-09 +*********************** + +Fixed +===== +- Catching error when searching for ``failover_path`` at kytos start. + [2024.1.3] - 2024-09-03 *********************** diff --git a/kytos.json b/kytos.json index 4e8d01c9..aff4a515 100644 --- a/kytos.json +++ b/kytos.json @@ -3,7 +3,7 @@ "username": "kytos", "name": "mef_eline", "description": "NApp to provision circuits from user request", - "version": "2024.1.3", + "version": "2024.1.4", "napp_dependencies": ["kytos/flow_manager", "kytos/pathfinder", "amlight/sndtrace_cp"], "license": "MIT", "tags": [],