Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_cn
Articles_de
Articles_pt
Articles_zh




JSPWiki v2.2.33

[RSS]


Hide Menu

TestData


This is version 20. It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]


How to generate random test data for your database.

dbMonster is a tool which helps database application developers with tuning the structure of the database, tuning the usage of indexes, and testing the application performance under heavy database load. dbMonster generates as much random test data as you wish and puts it into SQL database. I used dbMonster to add several thousand users to appfuse to test how it will impact performance, especially displaytag peformance.


First you want to download dbmonster (dbmonster-core and dbmonster-ant)

I found it easiest to run dbMonster with ant on my system. I'm using Windows XP and cygwin. dbmonster-core was extracted to f:\tools\dbmonster-core-1.0.3 and dbmonster-ant-1.0.1.jar was saved to f:\tools\monster\

Create 2 new directories inside of dbmonster-core-1.0.3 called config and schema.

mkdir config
mkdir schema

Create a file called dbmonster.properties inside of the config directory you just made.

dbmonster.jdbc.driver=org.postgresql.Driver
dbmonster.jdbc.url=jdbc:postgresql://127.0.0.1/YourDatabase
dbmonster.jdbc.username=postgres
dbmonster.jdbc.password=YourPassword

dbmonster.max-tries=1000

dbmonster.rows=1000

dbmonster.progress.monitor=pl.kernelpanic.dbmonster.ProgressMonitorAdapter

Next you want to map the schema of the tables that you want to generate data for. To do this, you will make a new file called appfuse-schema.xml. This example will allow you to generate 1500 new users at a time. If you want more you can run the application more than one or change rows="1500" in the file below.

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE dbmonster-schema PUBLIC
    "-//kernelpanic.pl//DBMonster Database Schema DTD 1.1//EN"
    "http://dbmonster.kernelpanic.pl/dtd/dbmonster-schema-1.1.dtd">

<dbmonster-schema>
        <name>User Schema</name>
                <table name="app_user" rows="1500">
                        <!--
                        <key databaseDefault="false">
                                <generator type="pl.kernelpanic.dbmonster.generator.MaxKeyGenerator"
                                        <property name="columnName" value="id"/>
                                </generator>
                        </key>
                        -->
                        <column name="username">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>
                        <column name="version">
                                <generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minValue" value="1"/>
                                        <property name="maxValue" value="5"/>
                                        <property name="returnedType" value="integer"/>
                                </generator>
                        </column>
                        <column name="password">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>
                        <column name="first_name">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>
                        <column name="last_name">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>
                        <column name="city">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>
                        <column name="postal_code">
                                <generator type="pl.kernelpanic.dbmonster.generator.NumberGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minValue" value="10000"/>
                                        <property name="maxValue" value="77007"/>
                                        <property name="returnedType" value="integer"/>
                                </generator>
                        </column>
                        <column name="email">
                                <generator type="pl.kernelpanic.dbmonster.generator.StringGenerator">
                                        <property name="nulls" value="0"/>
                                        <property name="minLength" value="4"/>
                                        <property name="maxLength" value="15"/>
                                        <property name="allowSpaces" value="false"/>
                                </generator>
                        </column>


                </table>
</dbmonster-schema>


<project name="dbmonster task example" default="gendb" basedir=".">

  <property file="build.properties"/>

  <!-- setup classpath -->
  <path id="dbmonster.classpath">
    <fileset dir="${dbmonster.ant}">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${dbmonster.home}">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <taskdef
    name="dbmonster"
    classname="pl.kernelpanic.dbmonster.ant.DBMonsterTask"
    classpathref="dbmonster.classpath">
  </taskdef>

  <target name="gendb">
    <dbmonster
      config="${dbmonster.config}/dbmonster.properties" verbose="true">
      <fileset dir="${dbmonster.schemas}">
        <include name="*.xml"/>
      </fileset>
    </dbmonster>
  </target>
</project>

dbmonster.home=/tools/dbmonster-core-1.0.3
dbmonster.ant=/tools/monster
dbmonster.config=/tools/dbmonster-core-1.0.3/config
dbmonster.schemas=/tools/dbmonster-core-1.0.3/schema

Run Ant

ant

Cool!:

Buildfile: build.xml

gendb: dbmonster Starting dbMonster random data generator... dbmonster 2005-06-12 15:17:40,639 INFO DBMonster - Let's feed this hungry database. dbmonster 2005-06-12 15:17:41,731 INFO Schema - Generating schema . dbmonster 2005-06-12 15:17:41,741 INFO Table - Generating table . dbmonster Generating table: app_user for schema: User Schema dbmonster ..................................................500/1500(info) dbmonster ..................................................1000/1500(info) dbmonster ..................................................1500/1500(info) dbmonster 1500/1500(info) dbmonster Table app_user finished. dbmonster 2005-06-12 15:17:50,313 INFO Table - Generation of table finished. dbmonster 2005-06-12 15:17:50,313 INFO Schema - Generation of schema finished. dbmonster 2005-06-12 15:17:50,413 INFO DBMonster - Finished in 9 sec. 784 ms. dbmonster Finished dbMonster random data generator.

BUILD SUCCESSFUL
Total time: 12 seconds




Go to top   More info...   Attach file...
This particular version was published on 06-Nov-2006 13:52:48 MST by DanQuellhorst.