Have you ever wondered what’s happening behind the scenes when you run tests using spring boot? Usually, you don’t care until it’s working in a predictable way. Once you encounter performance issues, your PC starts to lag, a single test executes in a couple of seconds instead of milliseconds, then you start digging. Most of the time, you end up with a single culprit — the spring context caching mechanism. It’s a great “tool” to speed up your tests, but you must be aware of all the consequences it entails.

Investigation

Let’s take a step back and start with a problem we had in the project. We have a spring boot application with mongo as storage. We have more than five hundred tests which start up a spring context and use embedded mongo beneath. A couple of weeks ago, we decided to bump up the version of embedded mongo to have it aligned with the one we have in real. A small change in gradle.properties and application.properties, rerun all test suites and … my computer stopped responding. Upsss… I needed a hard reset to bring it back to life ;-)

We reverted the change but a few days later, we decided to investigate the problem.

#mongodb #spring-boot #java #spring

One embedded mongo to rule them all
1.50 GEEK