Skip to content

Commit

Permalink
uncomment log-errors tests
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrc committed Jul 6, 2023
1 parent 3184176 commit 4e3a546
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 85 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ dependencies = [
"tenacity",
"termcolor",
"tqdm",
"xmltodict"
"xmltodict",
"typing-extensions"
]

[project.urls]
Expand Down
3 changes: 2 additions & 1 deletion src/chtools/monrun_checks/ch_log_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def log_errors_command(crit, warn, watch_seconds, exclude, logfile):
match = regex.match(line)
if match is None:
continue
if datetime.strptime(match.group(0), "%Y.%m.%d %H:%M:%S") < datetime_start:
date = match.group(1)
if datetime.strptime(date, "%Y.%m.%d %H:%M:%S") < datetime_start:
break
errors += 1

Expand Down
165 changes: 82 additions & 83 deletions tests/features/monrun.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,89 +150,88 @@ Feature: ch-monitoring tool
0;OK
"""

# TODO ORION-1000
# Scenario: Check Log errors
# When we sleep for 30 seconds
# And we execute command on clickhouse01
# """
# ch-monitoring log-errors -n 20
# """
# Then we get response
# """
# 0;OK, 0 errors for last 20 seconds
# """
# When we execute query on clickhouse01
# """
# SELECT 1;
# """
# And we sleep for 5 seconds
# And we execute command on clickhouse01
# """
# ch-monitoring log-errors -n 20
# """
# Then we get response
# """
# 0;OK, 0 errors for last 20 seconds
# """
# When we execute query on clickhouse01
# """
# FOOBAR INCORRECT REQUEST;
# """
# And we sleep for 5 seconds
# And we execute command on clickhouse01
# """
# ch-monitoring log-errors -n 20
# """
# Then we get response
# """
# 0;OK, 2 errors for last 20 seconds
# """
# When we execute query on clickhouse01
# """
# FOOBAR INCORRECT REQUEST;
# """
# And we execute query on clickhouse01
# """
# FOOBAR INCORRECT REQUEST;
# """
# And we execute query on clickhouse01
# """
# FOOBAR INCORRECT REQUEST;
# """
# And we execute query on clickhouse01
# """
# FOOBAR INCORRECT REQUEST;
# """
# And we sleep for 5 seconds
# And we execute command on clickhouse01
# """
# ch-monitoring log-errors -n 20
# """
# Then we get response
# """
# 1;10 errors for last 20 seconds
# """
# When we sleep for 30 seconds
# And we execute command on clickhouse01
# """
# ch-monitoring log-errors -n 20
# """
# Then we get response
# """
# 0;OK, 0 errors for last 20 seconds
# """
#
# Scenario: Check Log errors with timetail stderr output
# When we execute command on clickhouse01
# """
# echo 2000.01.01 00:00:00 test line > /tmp/test.log
# for j in {1..2000}; do echo junk line >> /tmp/test.log; done
# ch-monitoring log-errors -n 20 -f /tmp/test.log
# """
# Then we get response
# """
# 0;OK, 0 errors for last 20 seconds
# """
Scenario: Check Log errors
When we sleep for 20 seconds
And we execute command on clickhouse01
"""
ch-monitoring log-errors -n 10
"""
Then we get response
"""
0;OK, 0 errors for last 10 seconds
"""
When we execute query on clickhouse01
"""
SELECT 1;
"""
And we sleep for 5 seconds
And we execute command on clickhouse01
"""
ch-monitoring log-errors -n 20
"""
Then we get response
"""
0;OK, 0 errors for last 20 seconds
"""
When we execute query on clickhouse01
"""
FOOBAR INCORRECT REQUEST;
"""
And we sleep for 5 seconds
And we execute command on clickhouse01
"""
ch-monitoring log-errors -n 20
"""
Then we get response
"""
0;OK, 2 errors for last 20 seconds
"""
When we execute query on clickhouse01
"""
FOOBAR INCORRECT REQUEST;
"""
And we execute query on clickhouse01
"""
FOOBAR INCORRECT REQUEST;
"""
And we execute query on clickhouse01
"""
FOOBAR INCORRECT REQUEST;
"""
And we execute query on clickhouse01
"""
FOOBAR INCORRECT REQUEST;
"""
And we sleep for 5 seconds
And we execute command on clickhouse01
"""
ch-monitoring log-errors -n 20
"""
Then we get response
"""
1;10 errors for last 20 seconds
"""
When we sleep for 21 seconds
And we execute command on clickhouse01
"""
ch-monitoring log-errors -n 20
"""
Then we get response
"""
0;OK, 0 errors for last 20 seconds
"""

Scenario: Check Log errors with some random test log
When we execute command on clickhouse01
"""
echo 2000.01.01 00:00:00 test line > /tmp/test.log
for j in {1..2000}; do echo junk line >> /tmp/test.log; done
ch-monitoring log-errors -n 20 -f /tmp/test.log
"""
Then we get response
"""
0;OK, 0 errors for last 20 seconds
"""

Scenario: Check Ping
When we execute command on clickhouse01
Expand Down

0 comments on commit 4e3a546

Please sign in to comment.