Test with DbFill

DbFill is a testing utility used to write random data to a database. It is designed to provide a simple interface for populating a single table or an entire schema. DbFill gets all of the information it needs from the database meta-data, freeing up the user to spend more time testing. Values are randomly generated given the database and column type. Foreign keys are examined to ensure data is inserted in the proper order.

dbfill output

The most basic use of DbFill is inserting a single record. The following is an example of inserting a single record into the tables weather and city.

dbfill -p server.properties –schema public weather city

The resulting random data seen after selecting * from weather.

Additional tables can be included by including the table names as arguments. If the table weather had a foreign key dependency on an additional table not included, DbFill would report an error with the name of the foreign table required. The additional table could be added to the table name list or the –cascade argument could be used. When the –cascade flag is used, all foreign key dependent tables will be included.

If more than one record per table is desired, use the –count argument. The following example should be used to generate 1000 records in every public table schema.

dbfill -p server.properties –schema public –count 1000 –ignore sym_

The –count argument is used to indicate the number of records per table to insert. Notice no table names are used in this example. This indicates that all of the tables in the public schema should be populated. There may be a set of tables that we do not want to populate. These tables can skipped by using the –ignore argument and specifying a table name or prefix. If we are testing synchronization scenarios with SymmetricDS, we do not want to insert dummy data into the sym tables.

DbFill is designed to be used with multiple databases and column types. If you find a database or column type that DbFill does not work with, let us know on the forum and together we can continue to increase the robustness of DbFill.