Home > Software, Web > Integrated load testing

Integrated load testing


There is a big hype since few years ago about continuous integration. There are a lot of tools helping you in this, mostly oriented in building releases.
For testing it stands out JUnit, but this is unit testing. I’ll show you now how to have continuous integration for functional and performance (load) testing for web applications.
Basically I will use only Ant and JMeter. I will not enter into any details of how to write your JMeter test plan. For this you have at your disposal the JMeter documentation and a very nice graphical interface. The fact is that you will have in the end a functional and load testing plan.
And now the integration part. Ant is a very good choice when it comes to this and I think this should be your first one to look into if interested in integration.
What I want to have in the end is an automated test plan, that runs (on a remote machine), generates some results and email them to me.
Another nice thing about JMeter is that it comes packed with an Ant task too, that you will find in the extras directory under the root.
So now we have everything, except the Ant file. I will write it now.

<project name="Integrated load testing" default="test" basedir=".">
    <description>
        This is the build file for integrated load testing.
    </description>

    <!-- set global properties for this build -->
    <property name="jmeter.home" location="c:/Program Files/jakarta-jmeter-2.3.3"/>
    <property name="testplan" location="test.jmx"/>
    <property name="log" location="log.jtl"/>
    <property name="report" location="report.html"/>
    <property name="reportd" location="report-detail.html"/>

    <!-- project libraries, for the JMeter Ant task -->
    <path id="libs">
        <fileset dir="${jmeter.home}/extras">
            <include name="ant-jmeter*.jar"/>
        </fileset>
    </path>

    <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" classpathref="libs"/>

    <target name="test">
        <!-- Delete previous reports files, if any -->
        <delete failonerror="false" file="${log}"/>
        <delete failonerror="false" file="${report}"/>
        <delete failonerror="false" file="${reportd}"/>

        <!-- Run the tests -->
        <jmeter jmeterhome="${jmeter.home}"
                testplan="${testplan}" resultlog="${log}"
                failureproperty="failed"
                >
            <!--proxyhost="a.proxy.if.needed" proxyport="8080"-->
            <jvmarg value="-Xincgc"/>
        </jmeter>

        <!-- Generate the reports from the log file -->
        <xslt in="${log}" out="${report}" style="${jmeter.home}/extras/jmeter-results-report_21.xsl"/>
        <xslt in="${log}" out="${reportd}" style="${jmeter.home}/extras/jmeter-results-detail-report_21.xsl"/>

        <!-- Mail the reports -->
        <mail mailhost="my.smtp.host"
              from="integrated@testing.com" tolist="all.interested@testing.com" replyto="no-reply@testing.com"
              subject="Testing report"
              messagemimetype="text/html" messagefile="${report}" files="${reportd}"/>
    </target>

</project>

Just to round up this nicely you have to schedule a task to run this Ant build whenever you think this is needed. Don’t run this too often on your production environment. Once a month, usually when you have low traffic hours should be fine. If you want to run this more often do it on a testing environment.
One more thing. For the mail to work in Ant and not to get the error Failed to initialise MIME mail: javax/mail/MessagingException you have to download JavaMail and JAF. Then just copy mail.jar (from JavaMail distribution) and activation.jar (from JAF) to <ant-dir>/lib.

And you’re all set up: a fast way to integrate functional and load testing for your web application.

Categories: Software, Web
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment