Skip to content

Commit 210fa2c

Browse files
bingwang-msCopilot
andcommitted
syslog: accept standard rsyslogd rate-limit message in test_syslog_rate_limit
The test expected only SONiC's patched rsyslogd message: 'begin to drop messages due to rate-limiting' Standard rsyslogd (used on some platforms) emits a different message: 'N messages lost due to rate-limiting (M allowed within K seconds)' Both messages indicate that rate limiting is working correctly. Use regex alternation to accept either form, making the test work across different rsyslogd builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Bing Wang <bingwang@microsoft.com>
1 parent ac0003e commit 210fa2c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/syslog/test_syslog_rate_limit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
LOCAL_LOG_GENERATOR_FILE = os.path.join(BASE_DIR, 'log_generator.py')
2222
REMOTE_LOG_GENERATOR_FILE = os.path.join('/tmp', 'log_generator.py')
2323
DOCKER_LOG_GENERATOR_FILE = '/log_generator.py'
24-
# rsyslogd prints this log when rate-limiting reached
25-
LOG_EXPECT_SYSLOG_RATE_LIMIT_REACHED = '.*rate-limit-test>: begin to drop messages due to rate-limiting.*'
24+
# rsyslogd emits one of two messages depending on version when rate-limiting kicks in:
25+
# - "begin to drop messages due to rate-limiting" (logged when drops start)
26+
# - "N messages lost due to rate-limiting (M allowed within K seconds)" (logged as summary)
27+
# Accept either form so the test works across different rsyslogd versions.
28+
LOG_EXPECT_SYSLOG_RATE_LIMIT_REACHED = r'.*(?:begin to drop messages|messages lost) due to rate-limiting.*'
2629
# Log pattern for tests/syslog/log_generator.py
2730
LOG_EXPECT_LAST_MESSAGE = '.*{}rate-limit-test: This is a test log:.*'
2831

0 commit comments

Comments
 (0)