Skip to content

Commit

Permalink
[pfcwd] Fix the return code in invalid case (sonic-net#1691)
Browse files Browse the repository at this point in the history
Signed-off-by: Neetha John <[email protected]>

Fixes sonic-net#1690

What I did
Set the correct return code when pfcwd command is specified with invalid options

How to verify it
Modified the unit test to check for the correct return code and ran them and they passed
  • Loading branch information
neethajohn authored Jun 25, 2021
1 parent 57dc403 commit c5d00ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def start(self, action, restoration_time, ports, detection_time):
click.echo("Failed to run command, invalid options:")
for opt in invalid_ports:
click.echo(opt)
exit()
exit(1)
self.start_cmd(action, restoration_time, ports, detection_time)


Expand Down
6 changes: 3 additions & 3 deletions tests/pfcwd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_pfcwd_start_ports_invalid(self):
obj=db
)
print(result.output)
assert result.exit_code == 0
assert result.exit_code == 1
assert result.output == pfcwd_show_start_config_output_fail

@classmethod
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_pfcwd_start_ports_masic_invalid(self):
obj=db
)
print(result.output)
assert result.exit_code == 0
assert result.exit_code == 1
assert result.output == show_pfc_config_start_fail

# get config after the command, config shouldn't change
Expand Down Expand Up @@ -500,4 +500,4 @@ def teardown_class(cls):
import mock_tables.mock_single_asic
importlib.reload(mock_tables.mock_single_asic)
import pfcwd.main
importlib.reload(pfcwd.main)
importlib.reload(pfcwd.main)

0 comments on commit c5d00ae

Please sign in to comment.