testcontainers / testcontainers-rs

A library for integration-testing against docker containers from within Rust.
https://rust.testcontainers.org
Apache License 2.0
770 stars 141 forks source link

Postgres connection dropped unexpectedly #75

Closed ufoscout closed 5 years ago

ufoscout commented 5 years ago

I have a strange bug when using the postgres image, the connection is closed unexpectedly while I am using it. I created here a small reproducer (launch the tests to see it): https://github.com/ufoscout/rust-pg-issue

What happens? while using a connection to the postgres image, randomly rust-postgres returns this error:

Err(Error(Io(Custom { kind: UnexpectedEof, error: StringError("unexpected EOF") })))

I initially thought that it is a rust-postgres issue; however, this error does not happen if I use a Postgres docker image launched manually from the command line instead of the testcontainers one.

The error appears randomly. If you reproduce it through the above-linked reproducer, I'll notice that sometimes it happens after 2 loops, sometimes after 3 or 4 or whatever number of loops.

It seems to me that the image is stopped asynchronously while still in use.

Environment: Ubuntu LTS 18.04 64 bits Rustc: 1.32.0 (9fda7c223 2019-01-16)

ufoscout commented 5 years ago

Sorry, lifetime issue, I got it...

thomaseizinger commented 5 years ago

No worries. Note that there is a Drop implementation for the Container struct which deletes the docker image and thereby shuts down the running instance.