Most MySQL-like hibernation-compatible databases in memory?

For the project that I am working on (Spring / struts 2 / hibernate), we decided to use h2 for unit testing with MySQL for the production store and manage the circuit in Liquibase, a fairly standard tariff, but the problem continues to work, so this is what h2 and MySQL differs in many ways, for example, how they handle timestamps and triggers. This goes so far as to make me regret the use of h2 as extra headaches that cause incorrect matches, begin to outweigh its benefits. My question is, is there any other internal file database that behaves like MySQL? Obviously, we will use MySQL for integration testing anyway, but to be able to perform unit testing without even making Liquibase files a giant hack or without ensuring the local MySQL db is running would be nice.

+4
source share
3 answers

I do not think that there is another Java database in the version that is more compatible with MySQL than H2. If you have a lot of code that works only with MySQL, then you should probably also use MySQL for testing.

Just remember that in the future it will be difficult to switch to another database. Leaning too much on the specifics of a single product will give you a “supplier lock” in In the case of MySQL, at least you have the option to switch to MariaDB , so it's not so bad.

0
source

You can use the ram drive, copy your test tables and data to this disk and run your mysql configured to boot from this disk, and all this in a script at boot time.

Then your unit tests will work insanely faster. We used it to develop workstations, and the level of friction went three steps down.

0
source

I think the correct approach at the moment is to use MySQL as a Docker image.

Once you create the image, you can easily unscrew it from your tests, and it takes a few seconds. Your sleep mode will dynamically initialize the DB schema and there you go!

The only problem is that CI servers need to install Docker.

0
source

Source: https://habr.com/ru/post/1491262/


All Articles