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

scan_log_for_errors: check that regex is correct #9815

Merged
merged 1 commit into from
Nov 20, 2024
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
10 changes: 8 additions & 2 deletions test_runner/fixtures/pageserver/allowed_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ def scan_pageserver_log_for_errors(

# It's an ERROR or WARN. Is it in the allow-list?
for a in allowed_errors:
if re.match(a, line):
break
try:
if re.match(a, line):
break
# We can switch `re.error` with `re.PatternError` after 3.13
# https://docs.python.org/3/library/re.html#re.PatternError
except re.error:
print(f"Invalid regex: '{a}'", file=sys.stderr)
raise
else:
errors.append((lineno, line))
return errors
Expand Down
10 changes: 8 additions & 2 deletions test_runner/fixtures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,14 @@ def scan_log_for_errors(input: Iterable[str], allowed_errors: list[str]) -> list

# It's an ERROR or WARN. Is it in the allow-list?
for a in allowed_errors:
if re.match(a, line):
break
try:
if re.match(a, line):
break
# We can switch `re.error` with `re.PatternError` after 3.13
# https://docs.python.org/3/library/re.html#re.PatternError
except re.error:
log.error(f"Invalid regex: '{a}'")
raise
else:
errors.append((lineno, line))
return errors
Expand Down
Loading