zio / zio-sql

Type-safe, composable SQL for ZIO applications
https://zio.dev/zio-sql/
Apache License 2.0
236 stars 116 forks source link

Testcontainers not closing correctly after tests #666

Open jczuchnowski opened 2 years ago

jczuchnowski commented 2 years ago

When running the tests from sbt with:

sbt test

some of the containers don't close after running the tests finish. Resulting in: testcontainers

Perhaps there's a problem with how zio.sql.TestContainer and zio.sql.JdbcRunnableSpec are interacting with ZIO Test.

Also it seems like closing sbt also closes these containers after couple of seconds.

kyledinh commented 2 years ago

I pulled the latest and ran the test and the containers are cleaning themselves afterwards:

    + lower
    + trim
37 tests passed. 0 tests failed. 1 tests ignored.

Executed in 7 m 16 s

[info] Completed tests
[error] (postgres / Test / test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 296 s (04:56), completed Oct 28, 2022, 3:08:38 AM
sbt test  295.43s user 20.04s system 103% cpu 5:03.57 total

*[master][~/src/github.com/zio/zio-sql]$ docker ps                                                        
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
*[master][~/src/github.com/zio/zio-sql]$ 

I was getting this error with the default sbt settings:

[error] ## Exception when compiling 4 sources to /Users/kyle/src/github.com/zio/zio-sql/sqlserver/target/scala-2.13/test-classes
[error] java.lang.OutOfMemoryError: Java heap space
[error] 
[error]            
+ Hikaricp module
java.lang.OutOfMemoryError: Java heap space
[error] [launcher] error during sbt launcher: java.lang.OutOfMemoryError: Java heap space

Solved it with: