Creating load data for stress test with Benerator

Anyone working on a project with huge non-functional requisites such as handling high data volumes probably faced the challenge of creating the test data for simulating the system load. Depending on the system, the creation of the data might involve creating a simple program for outputting a csv or similar format.

But the problem is, this program from a simple program might end up in a complex program full of lookup tables (for cities, customer categories), complex data formats, etc. But, instead of hurrying to start coding your own program load creator, give a try on Benerator.

Benerator is based on an XML file that drives the data generation, it also comes with facilities for creating custom complex types, outputting data from pre-defined CSV files, etc.

Below is an example xml file from benerator:

<?xml version="1.0" encoding="iso-8859-1"?>
<setup	xmlns="http://databene.org/benerator-0.5.5.xsd"
		xsi:schemaLocation="http://databene.org/benerator-0.5.5.xsd org/databene/benerator/benerator-0.5.5.xsd">
	<include uri="customers.properties" />
    <create-entities name="customers" count="{${count}}">
        <attribute name="customer_id" type="long" min="1" max="9223372036854775807" distribution="step"/>
		<attribute name="zip" pattern="[0-9]{6}[0-9]{3}" />
		<variable name="countryCSV" type="entity" source="src/countries.csv" distribution="random"/>
        <attribute name="countryName" script="{${countryCSV.desc}}"/>
		<variable name="person" generator="org.databene.domain.person.PersonGenerator"/>
        <attribute name="personName" script="{${person.givenName} ${person.familyName}}"/>
		<attribute name="gender" pattern="[MF]{1}" />
		<variable name="birthDate"  generator="org.databene.domain.person.BirthDateGenerator" dataset="{${country}}"/>
        <attribute name="birthDate" script="{${birthDate?string('yyyyMMdd')}}"/>
        <consumer id="csv" class="org.databene.platform.csv.CSVEntityExporter">
<property name="uri" value="gen/customers.csv"/>
<property name="properties" value="customer_id,countryName,personName,gender,zip,birthDate"/>
<property name="datePattern" value="yyyyMMdd"/>

This, when executed through Benerator generates a CSV with 6 columns and the number of entries (or rows) will be configured in a properties file called customers.properties.
Here is a sneak peak of a possible output of the execution of the sample project:

1,China,Daniel Johnson,M,682587482,19760526
2,United States,Samantha Morgan,F,161370995,19580313
3,China,Hannah Moore,M,240197663,19780109
4,China,Ava Williams,M,723234265,19370319
5,China,Olivia Lee,F,864928029,19480817
6,Brazil,Hannah Morris,F,741226969,19350909

In order to make it simple for anyone willing to give a try on Benerator, I’ve provided a sample Eclipse project. Open the PDF and save the attached tar.gz, later import it into Eclipse using “Import Existing Projects” option.

Run the sample right clicking Benerator.launch, choosing “Run as” and then “Benerator”.

One last note: You need JDK6 in order to run Benerator since it need classes from javax.script package.


This post is outdated since benerator syntax changed a lot between 0.5 and 0.6 series (which documentation says is more aligned towards 1.0 final syntax). I’ll try to provide a new post dedicated to other benerator features and already covering the new syntax.


0 Responses to “Creating load data for stress test with Benerator”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 353,192 hits since aug'08

%d bloggers like this: