objectcomputing / check-ins

Other
7 stars 7 forks source link

[2339] Reducing test run times by preventing migration after each test #2397

Closed mjperry91 closed 1 month ago

mjperry91 commented 1 month ago

This commit will ensure we only run flyway migration once, and after each test we clear all entities from the db instead of cleaning it completely. As of now this takes our server test runtime from about 12 mins to a little under 2 mins.

mjperry91 commented 1 month ago

We should not need to truncate every table after each test. The long-term solution would be to identify which tests leak side effects and fix those.

However, I think we can merge this PR since it reduces test execution time by half:

Without this PR: 14m https://gradle.com/s/c2hz3kekpipro With this PR: 4m https://gradle.com/s/piiulfb27odqw

Moreover, I would delete the variable shouldResetDBAfterEachTest and both constructors.

Agreed. That is what I had done for a quick POC of this, but it will be fairly time consuming to go through each test for what it gets us. I figured this was the simplest way to go for now to automate cleanup, and hopefully prevent anyone adding new tests using these repositories from running into issues in case they forget to setup their own cleanup. Though of course that can still happen if any new repositories are added, and we will have to be aware of it.