zio-sql icon indicating copy to clipboard operation
zio-sql copied to clipboard

Testcontainers not closing correctly after tests

Open jczuchnowski opened this issue 3 years ago • 1 comments

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.

jczuchnowski avatar May 26 '22 10:05 jczuchnowski

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:

  • https://support.snyk.io/hc/en-us/articles/360003143417-Out-of-Memory-Error-when-testing-Scala-sbt-project
export SBT_OPTS="-Xms1024M -Xmx4G -Xss2M -XX:MaxMetaspaceSize=2G"

kyledinh avatar Oct 28 '22 10:10 kyledinh