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

Make sure we don't hide exceptions from waitUntilContainerStarted #6167

Conversation

deejgregor
Copy link
Contributor

This adds the original exception as the cause. It also adds the text "Wait strategy threw an exception." to each exception message.

This addresses two issues:

  1. The original exception from waitUntilContainerStarted was not being included as the cause in newly thrown exceptions in tryStart. The exceptions were not completely hidden because they were being logged, however, but the initial cause was less visible.

  2. The exception messages focused on state that was found at the time the exception was received but did not mention that the waitUntilContainerStarted method threw an exception.

Because of these two issues, unless you look at the source or see the logs, it isn't clear that this was caused by an exception from waitUntilContainerStarted. In test failure reports, CI systems, etc. that might highlight the failure message and not logs, this makes it harder to debug these issues.

Here is an example why including these details is useful:

@deejgregor deejgregor requested a review from a team as a code owner November 12, 2022 03:12
@deejgregor deejgregor force-pushed the fix-exception-hiding-wait-until-container-started branch from e9adc4f to fd82b30 Compare November 12, 2022 03:45
deejgregor added a commit to OpenNMS/opennms that referenced this pull request Nov 13, 2022
See testcontainers/testcontainers-java#6167

This change should be temporary until the above fix is released and we
update. Created waitUntilReadyWrapped to make it less messy to make
this change now and revert it later.
deejgregor added a commit to OpenNMS/opennms that referenced this pull request Nov 13, 2022
See testcontainers/testcontainers-java#6167

This change should be temporary until the above fix is released and we
update. Created waitUntilReadyWrapped to make it less messy to make
this change now and revert it later.
deejgregor added a commit to OpenNMS/opennms that referenced this pull request Nov 13, 2022
See testcontainers/testcontainers-java#6167

This change should be temporary until the above fix is released and we
update. Created waitUntilReadyWrapped to make it less messy to make
this change now and revert it later.
deejgregor added a commit to OpenNMS/opennms that referenced this pull request Nov 13, 2022
See testcontainers/testcontainers-java#6167

This change should be temporary until the above fix is released and we
update. Created waitUntilReadyWrapped to make it less messy to make
this change now and revert it later.
@deejgregor deejgregor force-pushed the fix-exception-hiding-wait-until-container-started branch 4 times, most recently from d23eaef to 10056f1 Compare November 17, 2022 23:54
Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @deejgregor ! I have left a suggestion which can be applied to the rest of messages.

@deejgregor deejgregor force-pushed the fix-exception-hiding-wait-until-container-started branch from 10056f1 to 5c8af15 Compare December 3, 2022 06:24
This adds the original exception as the cause. It also adds the
text "Wait strategy threw an exception." to each exception message.

This addresses two issues:

1. The original exception from waitUntilContainerStarted was not
   being included as the cause in newly thrown exceptions in
   tryStart. The exceptions were not completely hidden because
   they were being logged, however, but the initial cause was
   less visible.

2. The exception messages focused on state that was found at the
   time the exception was received but did not mention that the
   waitUntilContainerStarted method threw an exception.

Because of these issues, unless you look at the source or see the
logs, it isn't clear that this was caused by an exception from
waitUntilContainerStarted. In systems that might highlight the
failure message and stack trace and not logs/console output (test
failure reports, CI systems, etc.), it makes it harder to debug
these issues.

Updated tests to check for the updated messages as well as the
exception from waitUntilContainerStarted.
@deejgregor deejgregor force-pushed the fix-exception-hiding-wait-until-container-started branch from 5c8af15 to 78d961c Compare December 3, 2022 07:16
@eddumelendez eddumelendez added this to the next milestone Dec 14, 2022
@eddumelendez eddumelendez merged commit 52b6949 into testcontainers:main Dec 14, 2022
@eddumelendez
Copy link
Member

thanks for your contribution @deejgregor ! This is now in main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants