In-memory database unit testing

I have a PostgreSQL database. It is used for unit testing.

  • I want to speed up the tests, so I want to use some kind of in-memory database (e.g. H2).
  • I want to dump a database (from PostgreSQL) and import such a dump into the database in memory.

Do you have any suggestion regarding choosing a database in memory? I want this database to be compatible with PostgreSQL.

+5
source share
3 answers

( PostgreSQL) tmpfs ( , RAM- - /dev/shm Linux) postgres , :

initdb -D /dev/shm/pgtest
postmaster -D /dev/shm/pgtest -p 11111
+4

HSQL spring. , , , . hsql PostgreSQL. , .

+3

Pg ?

, , .

: PostgreSQL .

... , .

update: , ramdisk , , , . , , . unlogged ( , ) fsync=off .

, ramdisk tmpfs, initdb - . unlogged, .

Please note that while tmpfsramdisk is, it allows less used pages to go into swapspace. If for some reason you must have all the data stored in RAM, you need to use the driver ramdiskand create a file system on ramdisk . My advice: do not do this. Just configure Pg for quick testing.

0
source

All Articles