Skip to content

Embedded Database 2.0 Release Notes

Tomáš Vaněk edited this page May 14, 2021 · 1 revision

Embedded Database 2.0 Release Notes

Upgrading from Embedded Database 1.x

Packages of some classes may changed, so please check your imports.

Docker is a default provider

Docker provides the highest degree of flexibility. It supports various platforms and architectures, allows the use of any extension, allows you to prepare a custom docker image containing test data, and much more.

Therefore, the default provider in Embedded Database 2.0 has been changed to docker provider. Nevertheless, all previous providers are still available, so if this provider is not suitable for you, just add a necessary dependency and switch to your preferred provider.

Flyway dependencies are optional

The org.flywaydb:flyway-core and org.flywaydb.flyway-test-extensions:flyway-spring-test dependencies are now optional. That means they are no longer part of the library as transitive dependencies. If you need them, you have to add them manually.

This change should avoid version conflicts between these two dependencies, and prevent FlywayAutoConfiguration from being enabled in projects that do not use Flyway at all.

PostgreSQL 11 upgrade

This release upgrades to PostgreSQL 11.10, so please check the compatibility.

New and Noteworthy

Refresh mode

This feature allows for reset the database to the initial state that existed before the test was being started. It's based on the use of template databases and does not rely on the rollback of the current transaction. So it's possible to save and commit data within the test without any consequences.

Due to the use of the template databases, the refresh operation can be relatively fast and efficient. If database prefetching is used and tuned properly, the refresh operation can take only a few milliseconds.

Note that the refresh mode can be combined with @FlywayTest annotation without any negative impact on performance.

Liquibase support

Liquibase and other similar tools are now supported. Since these tools do not offer an analogy to @FlywayTest annotation, you may consider using the new refresh mode.

Note that although all tools are supported, Flyway and Liquibase provide the best performance because the library includes extra optimizations for them.

Microsoft SQL Server support

This release includes support for Microsoft SQL Server.

The associated database provider supports all available features such as template databases and database prefetching. But because Microsoft SQL Server supports only a single template database per database instance, the template databases are emulated by using backup and restore operations. However, this should have a minimal impact on the resulting performance.

MySQL database support

This release includes support for MySQL database.

The associated database provider supports only basic features that are required to work the embedded database properly. So you may notice some performance degradation compared to other database providers. It's because in MySQL, database is only synonymous with schema, which makes it hard to implement database prefetching. Template databases are also not supported, and cannot be easily emulated because MySQL does not support fast binary backups.

MariaDB database support

This release includes support for MariaDB database.

The associated database provider supports only basic features that are required to work the embedded database properly. So you may notice some performance degradation compared to other database providers. It's because in MariaDB, database is only synonymous with schema, which makes it hard to implement database prefetching. Template databases are also not supported, and cannot be easily emulated because MariaDB does not support fast binary backups.

Configuration properties

New properties can be used to change the default behavior of the embedded database.

  • zonky.test.database.type - The type of embedded database to be created when replacing the data source.
  • zonky.test.database.refresh - Determines the refresh mode of the embedded database.
  • zonky.test.database.replace - Determines what type of existing DataSource beans can be replaced.
  • zonky.test.database.prefetching.max-prepared-templates - Maximum number of prepared database templates.

Miscellaneous

Apart from the changes listed above, there have also been lots of minor tweaks and improvements including:

  • Internal processing has been completely rewritten in order to use AOP concepts.
  • Temporary databases are being released during the build to reduce memory requirements and allow the use of the tmpfs option even on larger projects.
  • The processing of @ConditionalOnBean(DataSource.class) annotations in auto-configurations has been improved.
  • The support for JUnit 5 nested tests has been improved and it's possible to use @NestedTestConfiguration annotation.
  • The search algorithm on @FlywayTest annotation has changed slightly. Now it honors that the annotation is not declared as inherited.
  • The beanName attribute on @AutoConfigureTestDatabase is no longer required when creating a new database.
  • The zonky.test.database.postgres.zonky-provider.preparer-isolation property has been removed.
  • The PostgreSQL JDBC Driver is no longer part of the library as a transitive dependency.
  • All Apache Commons dependencies have been removed and the Guava library has been shaded into the project's jars.