-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add dump command to allow container logs dumping #444
Conversation
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.
Thanks! A few comments.
testcontainers/src/core/container.rs
Outdated
|
||
fn get_log_dump_dir_path() -> PathBuf { | ||
env::current_dir() | ||
.unwrap_or(PathBuf::from("/tmp")) |
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.
This is gonna fail on Windows. I'd say if we can't get the current directory, print a warning and lets not dump them.
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.
On second thought, it might be better to allow passing the required path from outside - maybe an additional env var, or some syntax on the command env var i.e TESTCONTAINERS=dump=/tmp/target
? what do you think?
@thomaseizinger glad you like the feature :) In addition I changed to logs directory structure so that all logs from same test run will be saved in its own directory: |
@thomaseizinger what do you say? Any other comments to advance this PR? |
The ability to access logs is definitely helpful However I'd consider more aligned interface with implementations in other languages, like java and golang Also keep in mind, that we gonna deprecate CLI client soon (#563). So we actually can introduce this for http client only Subjectively, I'd avoid configuration though env variable and dumping logs to filesystem. In addition there is an alternative: it could be achieved by not-removing container and accessing logs with docker cli. |
Let us know if you're still interested in implementing / actualizing this PR. |
A common use case in integration tests development and debugging is inspecting created container logs.
Currently the way to do so is to run the tests using the "keep" command and inspect the logs afterwards. This isn't a good fit for CI testing environment, and might not be ideal for local development as well.
This PR adds a new "dump" command that removes the containers just like "remove" but will dump container logs into a "./testcontainers" directory.
The logs filename is
{container_name/image_name}_{stdout/stderr}_{current date in ISO format}.log
usage example:
TESTCONTAINERS=dump cargo test