# hibernate-matrix-testing **Repository Path**: mirrors_hibernate/hibernate-matrix-testing ## Basic Information - **Project Name**: hibernate-matrix-testing - **Description**: Support for running tests against a number of database profiles - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2025-08-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hibernate Matrix Testing **This plugin is considered deprecated. Use `database-profile-plugin` plugin instead** ### Goal The idea of matrix testing is to allow testing in a varied set of configurations. Specifically for Hibernate, this correlates to running the same set of tests against multiple databases. This goal is achieved through 2 Gradle plugins. Note that the second plugin (org.hibernate.build.gradle.testing.matrix.MatrixTestingPlugin) applies the first one (org.hibernate.build.gradle.testing.database.DatabaseProfilePlugin) automatically, so generally scripts would not even reference it. The reason for the split is historical and these 2 may get merged later... ### org.hibernate.build.gradle.testing.database.DatabaseProfilePlugin This plugin is responsible for determining which databases are available for testing in the given environment. It does this by performing a directory search. Well actually it can perform up to 2 directory searches: * The standard profile directory is named _databases_ at the base directory of the root project * A custom profile directory, which can be named by setting a system property named _hibernate-matrix-databases_ These directories are searched recursively. We leverage this in Hibernate to allow the standard _databases_ directory to hold local profiles too. That is achieved by a _.gitignore_ file which says to ignore any directory named _local_ under the directory _databases_. So one option to provide custom profiles is to drop them in there. That has the benefit of not having to specify _hibernate-matrix-databases_ Within these directories, the plugin looks for sub-directories which either: * contain a file named _matrix.gradle_. _matrix.gradle_ is a limited DSL Gradle file which currently understands just a specialized org.gradle.api.artifacts.Configuration reference named _jdbcDependency_. All that is a fancy way to say that _matrix.gradle_ allows you to specify some dependencies this database profile needs (JDBC drivers, etc). Any dependency artifacts named here get resolved using whatever resolvers (Maven, etc) are associated with the build. For example jdbcDependency { "mysql:mysql-connector-java:5.1.17" } * contain a directory named _jdbc_ which is assumed to hold jar file(s) needed for the profile. Such directories become the basis of a database profile made available to the build. The name of the profile (which becomes important when we discuss the next plugin) is taken from the directory name. Database profiles can also contain a _resources_ directory. An example layout using _matrix.gradle_ might be ├── mysql50 │ ├── jdbc │ │ └── mysql-connector-java-5.1.9.jar │ └── resources │ └── hibernate.properties Or ├── mysql50 │ ├── matrix.gradle │ └── resources │ └── hibernate.properties Either would result in a database profile named _mysql50_ Profiles can be ignored using the *hibernate-matrix-ignore* setting which accepts either * a comma-separated list of the database profile names to be skipped * the magic value **all** which indicates to ignore all profiles ### org.hibernate.build.gradle.testing.matrix.MatrixTestingPlugin The MatrixTestingPlugin essentially generates a bunch of Gradle tasks dynamically and adds them to your build. It does this based on all the database profiles found. Running `gradle tasks --all` will list all tasks available to the build including these generated ones. For each database profile the plugin will generate a task named *matrix_{profile}* that executes the tests against that particular database profile. It also generates a task named *matrix* that groups together all the profile-specific tasks so that running `gradle matrix` will run all the profiles. *see section below discussing SourceSet separation* ### Database Allocator (JBoss internally, VPN required) For developers on the Red Hat VPN, one option is to use the databases in the JBoss QA lab for testing. Note that this tends to result in **very** slow builds but the obvious trade off is not having to install and manage these databases locally. The JBoss QA team developed a servlet to allow management of "database allocations" including requesting an allocation be set up. The MatrixTestingPlugin is able to play with that feature allowing you to ask the build to allocate the database for you. This feature is disabled by default, to enable it, you need this system property named _hibernate-matrix-dballcoation_ which accepts either * a comma-separate list of profile names * the magic value **all** which indicates to allocate for all **supported** databases (see org.hibernate.build.gradle.testing.database.alloc.DatabaseAllocator.SUPPORTED_DB_NAMES for details) For example, if you want to run matrix test on PostgreSQL 8.4, knowing that the database name for that is _postgresql84_, you can use this command: gradle matrix_postgresql84 -Dhibernate-matrix-dballocation=postgresql84 which would 1. talk to the database allocator service and make a database instance available 2. use the information returned from the allocator service to properly set up the connection information Hibernate would need to connect to that instance. 3. run the tests against the postgresql84 profile For some databases we need adjust the connection url with some options after get it from the database allocator. In these cases we can use the system property _hibernate-matrix-dballocation-url-postfix-${dbname}_. For example `-Dhibernate-matrix-dballocation-url-postfix-sybase155="?SQLINITSTRING=set quoted_identifier on&DYNAMIC_PREPARE=true"` A useful parameter to the allocator service when allocating a database is the _requester_ which is basically just a string meant to identify who is making the request. By default the Hibernate build uses _hibernate_. But you can specify an alternate requester using the system property _hibernate-matrix-dballocation-requestee_