как прикрутить JMeter script к Ant и Maven?


(Mykhailo Poliarush) #1

что нужно сделать?


(akeem) #2

Как прикрутить maven смотрите ссылку (это специальный плагин) правда в нем есть некоторые ограницения по памьяти http://wiki.apache.org/jakarta-jmeter/JMeterMavenPlugin

Как прикрутить ant смотрим ссылку про таску http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php

Для последнего вот пример:

<?xml version="1.0" encoding="UTF-8" ?>
<project name="OpenBizBox Load Tests With using JMeter" basedir="." default="loadtests-all"
xmlns:ac="antlib:net.sf.antcontrib">
    <description>Builds, testing, and runs the project OpenBizBox Load Test.</description>
    <property environment="env" />
    <property file="build.properties" />
    <property name="env.JMETER_HOME" value="/home/akeem/jakarta-jmeter-2.4" />
    <property name="jmeter.cmdtool.path" value="${env.JMETER_HOME}/lib/ext/JMeterPluginsCMD.jar"
    />
    <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpath="${lib.dir}/ant-contrib-1.0b3.jar"
    />
    <taskdef name="jmeter" classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"
    classpath="lib/ant-jmeter-1.0.9.jar" />
    <target name="checkProperties">
        <fail unless="env.JMETER_HOME">JMETER_HOME must be set</fail>
    </target>
    <target name="loadtests-all" depends="checkProperties,loadtests-wajke-baseline,loadtests-wajke"
    />
    <target name="loadtests-wajke-baseline" depends="checkProperties,constload-wajke-baseline,linearload-wajke-baseline"
    />
    <target name="loadtests-wajke" depends="checkProperties,constload-wajke,linear-wajke-loads"
    />
    <path id="wajke.constload.path">
        <fileset dir="${tests.basedir}/wajke" includes="*Const*.jmx" />
    </path>
    <path id="wajke.linearload.path">
        <fileset dir="${tests.basedir}/wajke" includes="*Linear*.jmx" />
    </path>
    <target name="constload-wajke-baseline" depends="checkProperties">
        <ac:for param="path.item">
            <path refid="wajke.constload.path" />
            <sequential>
                <echo message="@{path.item}" /><var name="testplan.prefix.src" unset="true" />
                <basename file="@{path.item}" property="testplan.prefix.src" suffix=".jmx" />
                <echo message="${testplan.prefix.src}" />
                <antcall target="constload-reuse">
                    <param name="bmk.name" value="wajke" />
                    <param name="testplan.prefix" value="${testplan.prefix.src}" />
                    <param name="host.url" value="bmk6s1.dev-planet.dk" />
                </antcall>
            </sequential>
        </ac:for>
    </target>
    <target name="linearload-wajke-baseline" depends="checkProperties">
        <ac:for param="path.item">
            <path refid="wajke.linearload.path" />
            <sequential>
                <echo message="@{path.item}" /><var name="testplan.prefix.src" unset="true" />
                <basename file="@{path.item}" property="testplan.prefix.src" suffix=".jmx" />
                <echo message="${testplan.prefix.src}" />
                <antcall target="linearload-reuse">
                    <param name="bmk.name" value="wajke" />
                    <param name="testplan.prefix" value="${testplan.prefix.src}" />
                    <param name="host.url" value="bmk6s1.dev-planet.dk" />
                </antcall>
            </sequential>
        </ac:for>
    </target>
    <target name="constload-wajke" depends="checkProperties">
        <ac:for param="path.item">
            <path refid="wajke.constload.path" />
            <sequential>
                <echo message="@{path.item}" />
                <ac:var name="testplan.prefix.src" unset="true" />
                <basename file="@{path.item}" property="testplan.prefix.src" suffix=".jmx" />
                <echo message="${testplan.prefix.src}" />
                <antcall target="constload-reuse">
                    <param name="bmk.name" value="wajke" />
                    <param name="testplan.prefix" value="${testplan.prefix.src}" />
                    <!--<param name="host.url" value="bmk6s2.dev-planet.dk" />-->
                    <param name="host.url" value="wajke.tc.openbizbox.com" />
                </antcall>
            </sequential>
        </ac:for>
    </target>
    <target name="linear-wajke-loads" depends="checkProperties">
        <ac:for param="path.item">
            <path refid="wajke.linearload.path" />
            <sequential>
                <echo message="@{path.item}" /><var name="testplan.prefix.src" unset="true" />
                <basename file="@{path.item}" property="testplan.prefix.src" suffix=".jmx" />
                <echo message="${testplan.prefix.src}" />
                <antcall target="linearload-reuse">
                    <param name="bmk.name" value="wajke" />
                    <param name="testplan.prefix" value="${testplan.prefix.src}" />
                    <!--<param name="host.url" value="bmk6s2.dev-planet.dk" />-->
                    <param name="host.url" value="wajke.tc.openbizbox.com" />
                </antcall>
                <property name="testplan.prefix.src" value="" />
            </sequential>
        </ac:for>
    </target>
    <target name="cleanup-results">
        <delete dir="${basedir}/results" verbose="true" />
    </target>
    <!-- SECTION WITH REUSABLE TARGETS This section contains code ac:for run const & linera loads -->
    <target name="init-load-reuse">
        <tstamp prefix="tmpstmp">
            <format property="touch.time" pattern="MM-dd-yyyy-HH-mm-ss" offset="-5" />
        </tstamp>
        <property name="results.dir" value="${basedir}/results/${bmk.name}/${tmpstmp.touch.time}"
        />
        <mkdir dir="${results.dir}" />
    </target>
    <target name="constload-reuse" depends="init-load-reuse">
        <ac:for param="users" list="1,10,20,50,75">
            <sequential>
                <antcall target="load-reuse">
                    <param name="loadname" value="const/@{users}" />
                    <param name="load.users" value="@{users}" />
                </antcall>
            </sequential>
        </ac:for>
    </target>
    <target name="linearload-reuse" depends="init-load-reuse">
        <antcall target="load-reuse">
            <param name="loadname" value="linear" />
        </antcall>
    </target>
    <target name="load-reuse" depends="init-load-reuse">
        <property name="result.log.dir" value="${results.dir}/${loadname}" />
        <property name="result.log" value="${result.log.dir}/${testplan.prefix}.jtl" />
        <jmeter jmeterhome="${env.JMETER_HOME}" jmeterproperties="${tests.basedir}/jmeter.properties"
        testplan="${tests.basedir}/${bmk.name}/${testplan.prefix}.jmx" resultlog="${result.log}">
            <property name="jppmfile" value="${results.dir}/${loadname}/${testplan.prefix}-perf-server-monitoring.jppm"
            />
            <property name="bmk.host.url" value="${host.url}" />
            <property name="threads.amount" value="${load.users}" />
            <property name="server.agent.port" value="4546" />
        </jmeter>
        <ac:for param="pngreport" list="ThreadsStateOverTime,BytesThroughputOverTime,HitsPerSecond,LatenciesOverTime,ResponseCodesPerSecond,ResponseTimesDistribution,ResponseTimesOverTime,ResponseTimesPercentiles,ThroughputOverTime,ThroughputVsThreads,TimesVsThreads,TransactionsPerSecond">
            <sequential>
                <java jar="${jmeter.cmdtool.path}" fork="true">
                    <arg value="--generate-png" />
                    <arg value="${result.log.dir}/${testplan.prefix}-@{pngreport}.png" />
                    <arg value="--input-jtl" />
                    <arg value="${result.log}" />
                    <arg value="--plugin-type" />
                    <arg value="@{pngreport}" />
                    <arg value="--relative-times" />
                    <arg value="yes" />
                    <arg value="--width" />
                    <arg value="1600" />
                    <arg value="--height" />
                    <arg value="1200" />
                    <arg value="--prevent-outliers" />
                    <arg value="yes" />
                </java>
            </sequential>
        </ac:for>
        <java jar="${jmeter.cmdtool.path}" fork="true">
            <arg value="--generate-csv" />
            <arg value="${result.log.dir}/${testplan.prefix}-AggregateReport.csv" />
            <arg value="--input-jtl" />
            <arg value="${result.log}" />
            <arg value="--plugin-type" />
            <arg value="AggregateReport" />
        </java>
    </target>
</project>