From a7455e1546523273724360245a18d3594d7ab5a5 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox Date: Mon, 22 May 2023 14:43:29 +0800 Subject: [PATCH] Fix issue: out of range sflow polling interval is accepted and stored in config_db --- config/main.py | 2 +- tests/sflow_test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/main.py b/config/main.py index abef5397af..2c5a75b52b 100644 --- a/config/main.py +++ b/config/main.py @@ -6506,7 +6506,7 @@ def polling_int(ctx, interval): """Set polling-interval for counter-sampling (0 to disable)""" if ADHOC_VALIDATION: 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 = ValidatedConfigDBConnector(ctx.obj['db']) sflow_tbl = config_db.get_table('SFLOW') diff --git a/tests/sflow_test.py b/tests/sflow_test.py index da03ff396e..ecd622655e 100644 --- a/tests/sflow_test.py +++ b/tests/sflow_test.py @@ -237,6 +237,7 @@ def test_config_sflow_polling_interval(self): 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