Skip to content

Commit

Permalink
Merge pull request #508 from kytos-ng/error/failover
Browse files Browse the repository at this point in the history
Handled ConnectError
  • Loading branch information
Alopalao authored Sep 12, 2024
2 parents de821c8 + e3bf726 commit 40d08cd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
***********************

Expand Down
2 changes: 1 addition & 1 deletion kytos.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
2 changes: 1 addition & 1 deletion models/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +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:
except httpx.RequestError as err:
raise PathFinderException(str(err)) from err

if api_reply.status_code >= 400:
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/models/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -877,6 +878,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": [
Expand Down

0 comments on commit 40d08cd

Please sign in to comment.