Chat Logs

  1. dreamrealhttps://bytecode.news/posts/2026/10/testcontainers-and-reuse
  2. javabotdreamreal's title: "Testcontainers and Reuse | ByteCode.News"
  3. dreamrealhttps://news.ycombinator.com/item?id=49977000 upvotes appreciated, I'm trying to get this to the front page of HN so I can see how the front end endures
  4. nevetTestcontainers and Reuse | Hacker News
  5. javabotdreamreal's title: "Testcontainers and Reuse | Hacker News"
  6. dreamreal(I did not post this to HN)
  7. Paradreamreal: neat, i'm gonna steal that
  8. dreamrealPara: :)
  9. dreamrealIt's definitely nicer - my builds for nevet lost five literal minutes on deployments
  10. deeboi've been kinda battling the opposite of that in spring boot, if you use jdbc:tc:postgresql as the spring boot jdbc url, context caching still reuses the same underlying container for new contexts
  11. deeboso all tests have to make sure they can run with possibly garbage data left by other tests not running transactionally (intentional or not)
  12. dreamrealHmm, I wonder how that's propagating: on my machine, every module was getting its own container and choking docker out
  13. dreamrealmoving to unique scoped *databases* cleared everything up
  14. deeboat this point i've forgotten what the issue was, each new context in the cache had its own hikaripool to the same db, but somehow new containers were not started
  15. dreamrealThat's the problem *I* had! New containers were taking too long to initialize
  16. dreamrealso now: one container, so it initializes ONCE, and new dbs can be created and destroyed instantly because connecting to postgres doesn't have to wait on docker
  17. deebomaybe the container is created on Class.forName() or something so it's only done once per jvm, never looked into how jdbc testcontainers work
  18. ParaI have this in my personal project https://gist.github.com/esuomi/1a7a5b847f0b5943a63b35b91a226c1f
  19. nevetPostgreSQLExtension.java
  20. ParaFeel free to steal if there's anything worth stealing.
  21. dreamrealdeebo: if you don't explicitly turn on reuse, it starts a container for every JVM
  22. dreamrealbut turning on reuse isn't enough, you also need to differentiate schemas if they differ
  23. deeboyeah we don't fork tests from gradle and any multimodules are trivial, mostly for sharing domain classes etc so basically single jvm for tests
  24. dreamreal*nod*
  25. deeboyeah the driver has one container per url, i remember testing adding like ?cachebust=${time} or something and it made it work, but broke something else