Being able to connect to databases is central to running integration tests in Liquibase, but we also recognize that developers rarely have all possible databases running and available in their system. Our integration test system is able to find your available databases and quietly ignore tests when a database is unavailable.

The instructions below explain how to configure an integration test database and make it available to the integration test framework.

Configure Database Connection Files

Update the Primary Configuration file

This is the primary configuration file used by the integration test infrastructure:

  • file location: liquibase-integration-tests/src/test/resources/liquibase
  • file name: liquibase.integrationtest.properties

The liqubase.integrationtest.properties file contains the default configuration for the integration test database connections. It is called by the docker-compose.yml and is discussed in more detail in the Docker Databases section below.

The properties file contains the following default information:

integration.test.username=lbuser
integration.test.password=LiquibasePass1

The properties file also contains the following database-specific information:

  • DB_NAME is the relevant database platform name. Find the DB_NAME you need from our supported databases table.
  • username is the username required to connect to the integration test database.
  • password is the password required to connect to the integration test database.
  • url is the JDBC URL required to connect to the integration test database.
integration.test.DB_NAME.username=liquibase
integration.test.DB_NAME.password=liquibase
integration.test.DB_NAME.url=jdbc:localhost:2638?ServiceName=liquibase

Override Primary Configuration with a Local Configuration file

If you ever need to test against a connection with a different configuration, you can create a local configuration file to provide specific database overrides.

Here are the steps to create and use this file:

  1. Create a liquibase.integrationtest.local.properties file in the same directory as the primary configuration file (liquibase-integration-tests/src/test/resources/liquibase) described above.
  2. Override ONLY the configuration values you need.
    • For example, if you are running against an oracle database on a different system, you can set only integration.test.oracle.url=YOUR_URL.
    • Do not check the liquibase.integrationtest.local.properties file into Git. It should remain local to your environment.

Set up and run Docker databases

To standardize configuration/installation of different databases, we have a https://github.com/liquibase/liquibase/blob/master/liquibase-integration-tests/docker/docker-compose.yml file stored in the liquibase-integration-tests/docker directory. The databases started through this setup will match the default liquibase.integrationtest.properties settings and are used as part of the build server.

Note: Currently, only mysql is configured. More databases will be added soon.

To start the test databases:

  • Install Docker and docker-compose
  • Startup one or more test databases
    • To start all databases
      • cd to the liquibase-integration-tests/docker directory
      • run docker-compose up
    • To start one database – in this case, start the mysql database
      • cd to the liquibase-integration-tests/docker directory
      • run docker-compose up mysql