Giter Club home page Giter Club logo

dbtestcompare's Introduction

DBTestCompare

Application to compare results of two SQL queries

DBTestCompare Build

It reads tests definitions in XML format form specified directory and than runs them (as TestNG test).

You can generate automated tests for your database using DBTestCompareGenerator

If two SQL returns different results -> test fails.

Application supports TeamCity Service Messages (##teamcity messages) so if teamcityLogsEnabled is set to "true" (config file or command line parameter), you will see nice test tree in TeamCity logs.

To execute tests run program (Java 8 must be installed first (JDK or JRE)):

If you set JAVA_HOME variable:

java -jar DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar

or to add automatically all drivers from the directory to the classspath (jdbc_drivers/*) Windows

java -cp "DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar;jdbc_drivers/*" uk.co.objectivity.test.db.RunTests

Linux

java -cp "DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar:jdbc_drivers/*" uk.co.objectivity.test.db.RunTests

or e.g.

"C:\Program Files\Java\jdk1.8.0_92\bin\java" -jar DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar

The application provides the following features:

  • Platform independence - possibility to run on Windows and Linux as well (Java Runtime Environment 8 needed)
  • Supports all databases with JDBC drivers provided (tested with Microsoft SQL Server, Teradata, Snowflake, PostgreSQL and MySQL\MariaDB)
  • Supports all Continuous Integration tools thanks to TestNG Java unit test framework
  • Possibility to compare data between two different database engines even for huge data sets without "Out of memory problem" thanks to an incremental solution, more details here
  • Possibility to compare query to expected data defined in csv file and generate Excel test report, more details here
  • Possibility to compare data in one database engine in the fastest way using MINUS/EXCEPT Sql operator, more details here
  • No need to compile program in order to add new tests - thanks to Test Adapter DataDriven mechanism from TestNG
  • Possibility to execute tests in parallel by setting Threads parameter in the connection file.
  • Possibility to build multilevel tests structure
  • Possibility to save query results to flat files
  • Real-time test execution progress in TeamCity, more details here
  • Possibility to store Queries in separated files or inline in xml test definitions, more details here
  • Connection pool used for executing tests - connections to databases are not closed after each tests, but when all tests are finished
  • Possibility to compare query to expected data defined in csv file, more details here
  • Possibility to compare query to expected number of rows defined in XML test definition, more details here
  • Possibility to choose exit code in case of test failure
  • Possibility to connect to OLAP - compare mdx queries, more details here
  • Possibility to define "delta" precision of comparing floating-point numbers
  • Possibility to filter tests for execution by including or excluding, more details here
  • Standard TestNG html test report in "test-output" folder, more details here

How DBTestCompare works:

Comparing databases:

DBTestCompare

With test data delivered by file:

DBTestCompare

The program searches for test definitions by default in folder "test-definitions".

JDBC drivers must be present in "jdbc_drivers" folder. Licensed database drivers are NOT included, only open source like MySQL, MariaDB and PostgreSQL. Download licensed database drivers from the producer of the database e.g. Microsoft and put them in "jdbc_drivers" folder (on the same level as *.jar file).

More details here

You can override some of the application configuration properties, run app with:

-DtestsDir=path -set tests directory (default: test-definitions)

-DteamcityLogsEnabled=true -log test output in TeamCity format

-DfilterInclude=a.b,g.z.f -comma separated directories or test files which you want to include

-DfilterExclude=a.b.test -comma separated directories or test files which you want to exclude

for example:

java -DtestsDir=my_tests -jar DBTestCompare-1.0-SNAPSHOT-jar-with-dependencies.jar

More details here

3'rd party libraries: Software:

  • SIROCCO :: Text Table Formatter
  • Apache Log4j
  • com.sun.xml.bind :: JAXB Runtime
  • com.mchange :: c3p0 - a JDBC Connection pooling / Statement caching library

More details here

Where to start?


Checkout the code or get compiled jar file from releases page


To compile app to a runnable fat jar file, run (Maven must be installed first):

mvn clean compile assembly:single

jar will be created in target directory.


You can manage the application by attached ANT (ANT must be installed first) build.xml file (in folder \deploy), the script allows to :

-compile app

-replace tokens in connection definition

-replace tokens in SQL queries

more details here and here

dbtestcompare's People

Contributors

dependabot[bot] avatar maciejrudy-zz avatar pniewiadowski avatar raczeja avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbtestcompare's Issues

Support UNION in MINUS with minusQueryIndicatorOn

Compare queries with UNION, e.g.

SELECT ...
UNION
SELECT ...

The problem is that "secondMinusQueryIndicatorText" is added only to nth FROM occurrence, defined by "minusQueryIndicatorOccurence".
minusQueryIndicatorOccurence supports only an integer.

Support also "*" to replace all "FROM" occurrences.

Snowflake

How I can add Snowflake? Are you able to help or point me where I can start adding this database to DBTestCompare tool?

Use MINUS ALL in Teradata to get full result set

Use MINUS ALL in Teradata, instead of just MINUS:

query1 MINUS ALL query2
UNION ALL
query2 MINUS ALL query1

Not for all databases, as e.g. Microsoft SQL Server does not support the ALL clause.

JDBC connection

Unable to connect to SQL Server.
I have kept sqljdbc41.jar file in /jdbc_drivers path.
But it is showing Classnotfoundexception for Class com.microsoft.sqlserver.jdbc.SQLServerDriver.

SQL_SERVER
com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc:sqlserver://172.22.238.XX\MyDB;databaseName=Travel
XXXX
XXXX

It is working with mysql database.So are you loading the jars in the jdbc_driver folder at run time?

image

Could not load driverClass com.teradata.jdbc.TeraDriver

Hi there,

I am trying to run some test scripts for teradata, but I am stuck with the issue of driver loading.
I have Teradata JDBC Driver 17.00.00.03 terajdbc4.jar located in jdbc_drivers directory and in cmpSqlResults-config.xml
I have following configuration for teradata:

<datasource maxPollSize="6">
            <name>TERADATA_SERVER</name>
            <driver>com.teradata.jdbc.TeraDriver</driver>
            <url>jdbc:teradata://host.name/DATABASE=database_name,DBS_PORT=1025,LOGMECH=LDAP</url>
            <user>username</user>
            <password>password</password>
        </datasource>

Once I run the app it shows in log something like this:
[WARN ] 2021-01-26 10:00:12,647 DriverManagerDataSource:delta.floating_point.Teradata_test - Could not load driverClass com.teradata.jdbc.TeraDriver

I have DBeaver runing teradata connection without issue.

I was trying to:

  • add tdgssconfig.jar to jdbc_drivers
  • change <driver>com.teradata.jdbc.TeraDriver</driver> to <driver>com.ncr.teradata.TeraDriver</driver> or even to <driver>com.teradata.TeraDriver</driver>

But still not luck.
Anybody is able to help with this?

Use UNION ALL in MINUS comparison

MINUS test uses "UNION" by default. This removes duplicates from the result set.

Change UNION to UNION ALL, to get all differences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.