From d5780437d46a632d9bc0c2c3359e3f2082bf5801 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Mon, 25 Dec 2023 17:55:36 +0800 Subject: [PATCH] [syslog] enable/disable syslog rate limit feature in fixture (#10986) Feature syslog rate limit has been disabled by default to avoid consume CPU cycles during warm / fast reboot. There are new CLIs to enable/disable it. The PR is to automatically enable it before syslog rate limit test and disable it after. Summary: In fixture "restore_rate_limit", enable the feature at beginning, disable the feature at the end. Change-Id: I61545db602d579fa0f337686427235c6d04998c7 --- tests/syslog/test_syslog_rate_limit.py | 9 +++++++++ tests/test_pretest.py | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/tests/syslog/test_syslog_rate_limit.py b/tests/syslog/test_syslog_rate_limit.py index 1675700f2d..f12683ec57 100644 --- a/tests/syslog/test_syslog_rate_limit.py +++ b/tests/syslog/test_syslog_rate_limit.py @@ -51,6 +51,13 @@ def restore_rate_limit(rand_selected_dut): Args: rand_selected_dut (object): DUT host object """ + output = rand_selected_dut.command('config syslog --help')['stdout'] + manually_enable_feature = False + if 'rate-limit-feature' in output: + # in 202305, the feature is disabled by default for warmboot/fastboot + # performance, need manually enable it via command + rand_selected_dut.command('config syslog rate-limit-feature enable') + manually_enable_feature = True container_data = rand_selected_dut.show_and_parse('show syslog rate-limit-container') host_data = rand_selected_dut.show_and_parse('show syslog rate-limit-host') @@ -63,6 +70,8 @@ def restore_rate_limit(rand_selected_dut): rand_selected_dut.command('config syslog rate-limit-host -b {} -i {}'.format( host_data[0]['burst'], host_data[0]['interval'])) rand_selected_dut.command('config save -y') + if manually_enable_feature: + rand_selected_dut.command('config syslog rate-limit-feature disable') @pytest.mark.disable_loganalyzer diff --git a/tests/test_pretest.py b/tests/test_pretest.py index d86e7d0174..d59ecfc18c 100644 --- a/tests/test_pretest.py +++ b/tests/test_pretest.py @@ -163,6 +163,14 @@ def test_disable_rsyslog_rate_limit(duthosts, enum_dut_hostname): is_dhcp_server_enable = config_facts["ansible_facts"]["DEVICE_METADATA"]["localhost"]["dhcp_server"] except KeyError: is_dhcp_server_enable = None + + output = duthost.command('config syslog --help')['stdout'] + manually_enable_feature = False + if 'rate-limit-feature' in output: + # in 202305, the feature is disabled by default for warmboot/fastboot + # performance, need manually enable it via command + duthost.command('config syslog rate-limit-feature enable') + manually_enable_feature = True for feature_name, state in list(features_dict.items()): if 'enabled' not in state: continue @@ -175,6 +183,8 @@ def test_disable_rsyslog_rate_limit(duthosts, enum_dut_hostname): if "sonic-telemetry" not in output: continue duthost.modify_syslog_rate_limit(feature_name, rl_option='disable') + if manually_enable_feature: + duthost.command('config syslog rate-limit-feature disable') def collect_dut_lossless_prio(dut):