Skip to content
kataggart edited this page Apr 19, 2022 · 1 revision

Testing Your PR - Developer Test-Harness Use

Overview

The Liquibase Test-Harness is our primary test system for the following classes of changes:

  • Data Type - code changes that affect a Data Type produced by Liquibase (for a specific database or set of databases)
  • Incorrect SQL - code changes that affect the SQL that is generated by Liquibase for a changetype (for a specific database or set of databases)

NOTE: please continue to add any relevant unit or integration tests in the main liquibase repository, as appropriate.

Setup

The test-harness is a separate repo and project, so it needs to be set up separately from liquibase:

  1. Clone https://github.com/liquibase/liquibase-test-harness to a sibling directory of where liquibase is checked out
  2. Checkout the develop branch in liquibase-test-harness
  3. This is the base branch for testing and working on snapshot liquibase builds
  4. The liquibase-test-harness main branch is only used to test the latest released liquibase build, it is not used to test against snapshot builds
  5. Update your local liquibase-test-harness pom.xml file
  6. Update the liquibase-core dependency version from [4.3.0,0) to 0-SNAPSHOT
  7. Move the liquibase-test-harness pom.xml file to a “don’t commit” git changeset or whatever you need to do so you don’t commit that file
  8. (Optional) Import the liquibase-test-harness/pom.xml into your IDE to create your project

Running Test Harness

The liquibase-test-harness readme file explains how to run the test harness tests. Especially the “Running the Tests” section.

Notes:

  • The docker database configurations used by liquibase-test-harness conflict with the configurations used by the liquibase tests. “Conflicts” == same ports but different username/password/schema/etc. So you will have to stop and start containers as you work on different tests
  • The -D settings from the Maven section for controlling which tests to run apply to running them via the IDE as well
  • The “Change Objects Test” is the type of test we use for testing both the Data Types and the Incorrect SQL. Datatypes are tested by adding to the datatypes.*.xml changelog files. Change objects are tested by adding new changelog xml files

Submitting Code & Tests

As you develop, make code changes in liquibase and add/modify tests in liquibase-test-harness.

REMEMBER: test-harness runs whatever is installed in your local maven cache as version 0-SNAPSHOT, so run mvn install on liquibase when you want to test a new liquibase build.

Once you have liquibase and liquibase-test-harness changes that are ready to submit:

  1. Commit and push changes to liquibase to a branch
  2. Commit and push changes to liquibase-test-harness in the same named branch
  3. Open a PR in liquibase-test-harness
  4. The first build may fail because liquibase doesn’t have a PR yet. That’s fine, the liquibase PR will trigger it to run again
  5. Open a PR in liquibase
  6. In the PR description, include a reference to the test-harness PR
  7. Assign both PRs to whomever needs to review them
  8. Put the liquibase PR in “code review” on the Liquibase Community project board
  9. When the reviewer OKs them, they move the liquibase PR directly to “ready to merge”
  10. Community team member merges PRs in the “ready to merge” column when it is a good time