Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding log for number of flows #194

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@ def handle_flows_install_delete(self, event):
return

force = bool(event.content.get("force", False))
if not flow_dict["flows"]:
viniarck marked this conversation as resolved.
Show resolved Hide resolved
log.error(f"Error, empty list of flows recieved. {flow_dict}")
Alopalao marked this conversation as resolved.
Show resolved Hide resolved
return
else:
log.info(
f"Received event with {len(flow_dict['flows'])} flows"
viniarck marked this conversation as resolved.
Show resolved Hide resolved
f" with force={force}."
)

viniarck marked this conversation as resolved.
Show resolved Hide resolved
switch = self.controller.get_switch_by_dpid(dpid)
flows_to_log_info(
f"Send FlowMod from KytosEvent dpid: {dpid}, command: {command}, "
Expand Down Expand Up @@ -670,6 +679,10 @@ def _send_flow_mods_from_request(
raise HTTPException(400, detail=str(exc))

force = bool(flows_dict.get("force", False))
log.info(
f"Received request with {len(flows_dict['flows'])}"
f" flows_dict with force={force}."
)
flows_to_log_info(
f"Send FlowMod from request dpid: {dpid}, command: {command}, "
f"force: {force}, ",
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class Test(TestCommand):

def run(self):
"""Run tests."""
cmd = "python3 -m pytest tests/ %s" % self.get_args()
cmd = "python3 -m pytest tests/ --cov-report term-missing"
Alopalao marked this conversation as resolved.
Show resolved Hide resolved
cmd += f" {self.get_args()}"
try:
check_call(cmd, shell=True)
except CalledProcessError as exc:
Expand All @@ -115,7 +116,8 @@ class TestCoverage(Test):

def run(self):
"""Run tests quietly and display coverage report."""
cmd = "python3 -m pytest --cov=. tests/ %s" % self.get_args()
cmd = "python3 -m pytest --cov=. tests/ --cov-report term-missing"
cmd += f" {self.get_args()}"
try:
check_call(cmd, shell=True)
except CalledProcessError as exc:
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def test_handle_flows_install_delete_fail(self, *args):
# missing cookie_mask
event = get_kytos_event_mock(
name="kytos.flow_manager.flows.delete",
content={"dpid": dpid, "flow_dict": [{"cookie": 1}]},
content={"dpid": dpid, "flow_dict": {"cookie": 1, "flows": []}},
)
self.napp.handle_flows_install_delete(event)
assert mock_log.error.call_count == 3
Expand All @@ -663,6 +663,14 @@ def test_handle_flows_install_delete_fail(self, *args):
self.napp.handle_flows_install_delete(event)
assert mock_log.error.call_count == 4

# empty flow list
event = get_kytos_event_mock(
name="kytos.flow_manager.flows.delete",
content={"dpid": dpid, "flow_dict": {"flows": []}},
)
self.napp.handle_flows_install_delete(event)
assert mock_log.error.call_count == 5

# install_flow exceptions
event = get_kytos_event_mock(
name="kytos.flow_manager.flows.install",
Expand Down