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

[202205] Fix issue: out of range sflow polling interval is accepted and stored in config_db (#2847) #3123

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6308,7 +6308,7 @@ def disable(ctx):
def polling_int(ctx, interval):
"""Set polling-interval for counter-sampling (0 to disable)"""
if interval not in range(5, 301) and interval != 0:
click.echo("Polling interval must be between 5-300 (0 to disable)")
ctx.fail("Polling interval must be between 5-300 (0 to disable)")

config_db = ctx.obj['db']
sflow_tbl = config_db.get_table('SFLOW')
Expand Down
7 changes: 7 additions & 0 deletions tests/sflow_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ def test_config_sflow_polling_interval(self):
runner = CliRunner()
obj = {'db':db.cfgdb}

# set to 500 out of range
result = runner.invoke(config.config.commands["sflow"].
commands["polling-interval"], ["500"], obj=obj)
print(result.exit_code, result.output)
assert result.exit_code != 0
assert "Polling interval must be between 5-300" in result.output

# set to 20
result = runner.invoke(config.config.commands["sflow"].
commands["polling-interval"], ["20"], obj=obj)
Expand Down
Loading