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

Regression tests: display stdout/stderr even if there was an exception before the report could be created. #38008

Merged
merged 3 commits into from
May 7, 2024

Conversation

clnoll
Copy link
Contributor

@clnoll clnoll commented May 7, 2024

Currently if there's an exception running regression tests before the report is written, we get a generic exception that the report couldn't be exported from the container because it does not exist.

However, this causes us to not be able to see the stderr/stdout.

This code change makes a small modification so to handle the exception exporting the report so we can still see the stderr/stdout of the container.

@clnoll clnoll requested a review from a team May 7, 2024 00:35
Copy link

vercel bot commented May 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Visit Preview May 7, 2024 3:55pm

@clnoll clnoll force-pushed the regression-tests-handle-dagger-exception branch from 5ce0d7a to 8d11352 Compare May 7, 2024 00:44
@clnoll clnoll force-pushed the regression-tests-handle-dagger-exception branch from 8d11352 to a8ce766 Compare May 7, 2024 01:07
Copy link
Contributor

@alafanechere alafanechere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to not be blocking but please check out my suggestion, it could provide a more explicit error handling which would be simpler to debug.

And please bump the package version and add a changelog entry 🙏

Comment on lines 421 to 429
exit_code, stdout, stderr = await get_exec_result(container)

with open(path_to_report, "r") as fp:
regression_test_report = fp.read()
try:
await container.file(path_to_report).export(path_to_report)
with open(path_to_report, "r") as fp:
regression_test_report = fp.read()
except Exception as exc:
main_logger.exception(f"Could not export or read report due to exception. traceback={traceback.format_exc()}", exc_info=exc)
regression_test_report = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just summarizing my understanding of the flow.

  • get_exec_result actually executes the command in the container
  • If there's an ExecError during the execution of this command we get stdout and stderr from the exception object
  • If an ExecError was thrown (and handled) executing container.file() will likely fail as we're trying to get a file that does not exist.

Instead of excepting a broad exception I'd be in favor of being more specific:

if "report.html" not in await container.directory(f"{regression_tests_artifacts_dir}/session_{self.run_id}").entries():
   main_logger.exception("The report file was not generated, an unhandled error likely happened during regression test execution, please check the step stderr and stdout for more details")
else:
  await container.file(path_to_report).export(path_to_report)
  with open(path_to_report, "r") as fp:
    regression_test_report = fp.read()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the suggestion, updated.

@clnoll clnoll merged commit 5f85707 into master May 7, 2024
32 checks passed
@clnoll clnoll deleted the regression-tests-handle-dagger-exception branch May 7, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants