Before submitting an enhancement or fix, run the tests outlined in this guide to reduce the risk of regressions. Include evidence in the pull request, such as unit test output and comparison summaries.
In addition to the database compare tests below, the project includes fast JUnit unit tests (no database required) that lock in the exact compare/hash SQL generated for each data type and platform. These act as a regression guard: cross-platform correctness depends on the source and target producing byte-identical hash input, so any unintended change to a generated expression is a correctness bug.
Always run the unit tests before committing changes to DataTypeCastingUtils, the column metadata builders, or the threading classes.
mvn test
mvn test -Dtest=DataTypeCastingUtilsTest
mvn test -Dtest='DataTypeCastingUtilsTest$TimestampCasting'
mvn test -Dtest='DataTypeCastingUtilsTest#postgresTimestamptzGetsUtcConversion'
mvn install # compiles, runs tests, builds the jar
mvn install -DskipTests # skip tests (used by the Docker image build)
- The console reports
Tests run: N, Failures: 0, Errors: 0followed byBUILD SUCCESSorBUILD FAILURE. - On failure, Surefire prints the exact string diff (
expected: <...> but was: <...>), pinpointing which generated SQL changed. - Detailed reports are written to
target/surefire-reports/.
If a casting change is intentional, update the corresponding expected value in the test AND re-validate against real source/target databases using the database test plan below.
As part of the Data Validation Tool project (https://github.com/GoogleCloudPlatform/professional-services-data-validator), the Google Database Black Belt Team created a sample set of tables and data for testing data comparison tools. These tables are recommended, but not required, for pull request validation.
Evidence, summary of compare output vs expectations, should be included in any pull request. The sample data used must include all core types (character, number, timestamp, etc.). In addition, the test must be performed on two different database platforms.
Deploy the sample data under the database directory to the appropriate database or use the DVT sample data.
pgcompare init
pgcompare discover
pgcompare compare --batch 0
UPDATE hr.location SET location_code=1234567890.1234567 WHERE city='Miami';
DELETE FROM hr.location WHERE city='Chicago';
INSERT INTO hr.location (longitude, latitude, city, state, zip, location_code) VALUES (-81.655647, 30.332184, 'Jacksonville', 'FL', 32257, 1234567890.123456789);
pgcompare compare --batch 0
pgcompare check --batch 0
Set column-hash-method=hybrid and rerun the comparison:
pgcompare compare --batch 0