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

[rsyslog] Disable rsyslog rate limit in pre_test and do a recover in post_test #2378

Merged
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
20 changes: 20 additions & 0 deletions tests/test_posttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os.path
import os
import json
import time

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -54,3 +55,22 @@ def test_restore_container_autorestart(duthost):
cmds_enable.append("config save -y")
duthost.shell_cmds(cmds=cmds_enable)
os.remove(state_file_name)
# Wait 30 seconds for snmp reloading
time.sleep(30)
daall marked this conversation as resolved.
Show resolved Hide resolved

def test_recover_rsyslog_rate_limit(duthost):
features_dict, succeed = duthost.get_feature_status()
if not succeed:
# Something unexpected happened.
# We don't want to fail here because it's an util
return
daall marked this conversation as resolved.
Show resolved Hide resolved
cmd_disable_rate_limit = r"docker exec -i {} sed -i 's/^#\$SystemLogRateLimit/\$SystemLogRateLimit/g' /etc/rsyslog.conf"
daall marked this conversation as resolved.
Show resolved Hide resolved
cmd_reload = r"docker exec -i {} supervisorctl restart rsyslogd"
for feature_name, state in features_dict.items():
if state == "disabled":
continue
cmds = []
cmds.append(cmd_disable_rate_limit.format(feature_name))
cmds.append(cmd_reload.format(feature_name))
duthost.shell_cmds(cmds=cmds)

21 changes: 20 additions & 1 deletion tests/test_pretest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import pytest
import logging
import json
import time

logger = logging.getLogger(__name__)

pytestmark = [
pytest.mark.pretest,
pytest.mark.topology('util')
pytest.mark.topology('util'),
pytest.mark.disable_loganalyzer
]

def test_cleanup_testbed(duthost, request, ptfhost):
Expand Down Expand Up @@ -45,5 +47,22 @@ def test_disable_container_autorestart(duthost):
# Write into config_db
cmds_disable.append("config save -y")
duthost.shell_cmds(cmds=cmds_disable)
# Wait 30 seconds for snmp reloading
time.sleep(30)
daall marked this conversation as resolved.
Show resolved Hide resolved

def test_disable_rsyslog_rate_limit(duthost):
features_dict, succeed = duthost.get_feature_status()
if not succeed:
# Something unexpected happened.
# We don't want to fail here because it's an util
daall marked this conversation as resolved.
Show resolved Hide resolved
return
cmd_disable_rate_limit = r"docker exec -i {} sed -i 's/^\$SystemLogRateLimit/#\$SystemLogRateLimit/g' /etc/rsyslog.conf"
cmd_reload = r"docker exec -i {} supervisorctl restart rsyslogd"
for feature_name, state in features_dict.items():
if state == "disabled":
continue
cmds = []
cmds.append(cmd_disable_rate_limit.format(feature_name))
cmds.append(cmd_reload.format(feature_name))
duthost.shell_cmds(cmds=cmds)