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

fix: wait_for_logs can now fail early when the container stops #682

Merged
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: 3 additions & 0 deletions core/testcontainers/core/waiting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
timeout: float = config.timeout,
interval: float = 1,
predicate_streams_and: bool = False,
raise_on_exit: bool = False,
#
) -> float:
"""
Expand Down Expand Up @@ -117,4 +118,6 @@
return duration
if duration > timeout:
raise TimeoutError(f"Container did not emit logs satisfying predicate in {timeout:.3f} " "seconds")
if raise_on_exit and container.get_wrapped_container().status != "running":
raise RuntimeError("Container exited before emitting logs satisfying predicate")

Check warning on line 122 in core/testcontainers/core/waiting_utils.py

View check run for this annotation

Codecov / codecov/patch

core/testcontainers/core/waiting_utils.py#L122

Added line #L122 was not covered by tests
time.sleep(interval)