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

uncomment log-errors tests #15

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
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