-
Notifications
You must be signed in to change notification settings - Fork 88
feat(integration-tests): system-wide overhaul of logging and error reporting. #1802
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
base: main
Are you sure you want to change the base?
feat(integration-tests): system-wide overhaul of logging and error reporting. #1802
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
junhaoliao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the understanding that this is a draft, i just took a quick look
| .task/ | ||
| build/ | ||
| dist/ | ||
| __* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are we trying to exclude here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __pytest_logs directory that stores the log file for each test run.
That being said, right now the __pytest_logs directory gets created/stored under the clp/integration-tests directory. Do you think it might be better to have it under the build/integration-tests directory instead (used for other integration test stuff as well)? Then we wouldn't have to modify this file.
| --show-capture=no | ||
| --tb=short | ||
| --strict-config | ||
| --strict-markers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
| --show-capture=no | |
| --tb=short | |
| --strict-config | |
| --strict-markers | |
| --show-capture=no | |
| --strict-config | |
| --strict-markers | |
| --tb=short |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
| log_cli_date_format = %Y-%m-%d %H:%M:%S,%f | ||
| log_cli_format = %(name)s %(asctime)s [%(levelname)s] %(message)s | ||
| log_cli_level = INFO | ||
| log_cli_format = %(levelname)-8s %(asctime)-25s %(message)s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to change this? i thought we were trying to match references like
| logging_formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(message)s") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only reason was aesthetics, cause this is the format of the logs that will be reported to the user via the command line. If there is some reason we want to match references like you describe above, I can change it; I just wasn't aware we were doing that
|
|
||
| log_file_mode = a | ||
| log_file_level = DEBUG | ||
| log_file_format = %(levelname)-8s %(asctime)-30s [%(name)s:%(filename)s:%(lineno)d]: %(message)s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to use a different format string between the cli and the log file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to provide more information to the dev; I don't want to crowd the cli output, especially for a successful (no failure) test run. I think it's safe to assume that the main reason a dev would be looking at the test log would be if something fails, and in the event of failure, they'll need more information.
| log_cli_format = %(levelname)-8s %(asctime)-25s %(message)s | ||
| log_cli_date_format = %Y-%m-%d %H:%M:%S | ||
|
|
||
| log_file_mode = a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of appending to the same file, can isolate the logs from different test runs instead? e.g., use set_log_path with the default log_file_mode = w. see the test code at pytest-dev/pytest#4752 for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this isn't here, the test output file will contain all of the pytest logging messages followed by all of the output from the various subprocesses called during the test run, like this:
INFO 2025-01-06 event1
INFO 2025-01-06 event2
INFO 2025-01-06 event3
<output following event 1>
<output following event 2>
<output following event 3>
It seems better to me to have everything written to the log file in order, so that it looks like this:
INFO 2025-01-06 event1
<output following event 1>
INFO 2025-01-06 event2
<output following event 2>
INFO 2025-01-06 event3
<output following event 3>
The logs from different test runs are already isolated by the code in conftest.py.
|
|
||
| def run_and_assert(cmd: list[str], **kwargs: Any) -> subprocess.CompletedProcess[Any]: | ||
| def run_and_assert( | ||
| request: pytest.FixtureRequest, cmd: list[str], **kwargs: Any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update below docstring for the param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean the request? if so, right on, thank you
|
|
||
|
|
||
| def stop_clp_package(package_config: PackageConfig) -> None: | ||
| def stop_clp_package(request: pytest.FixtureRequest, package_config: PackageConfig) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param docstring for request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right on, thanks
|
|
||
| try: | ||
| run_and_assert(request, stop_cmd, timeout=DEFAULT_CMD_TIMEOUT_SECONDS) | ||
| except SubprocessError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in what case would this be thrown here? i thought we would have caught this in run_and_assert? like also if there are other SubprocessError than CalledProcessError that might be thrown but uncaught in run_and_assert, why don't we modify run_and_assert to handle such in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a good point. See my message that I sent you offline.
|
|
||
| try: | ||
| run_and_assert(request, start_cmd, timeout=DEFAULT_CMD_TIMEOUT_SECONDS) | ||
| except SubprocessError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto -
in what case would this be thrown here? i thought we would have caught this in
run_and_assert? like also if there are otherSubprocessErrorthanCalledProcessErrorthat might be thrown but uncaught inrun_and_assert, why don't we modifyrun_and_assertto handle such in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto my other comment -
|
|
||
|
|
||
| def start_clp_package(package_config: PackageConfig) -> None: | ||
| def start_clp_package(request: pytest.FixtureRequest, package_config: PackageConfig) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param docstring for request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right on, thanks
Description
Checklist
breaking change.
Validation performed