You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by di...@apache.org on 2002/12/18 15:45:14 UTC

cvs commit: jakarta-turbine-maven/src/plugins-build/latka jmeter2suite.jelly plugin.jelly

dion        2002/12/18 06:45:13

  Modified:    src/plugins-build/latka/xdocs index.xml goals.xml
               src/plugins-build/latka plugin.jelly
  Added:       src/plugins-build/latka jmeter2suite.jelly
  Log:
  Added the ability to convert JMeter jmx files to Latka suites
  
  Revision  Changes    Path
  1.3       +43 -0     jakarta-turbine-maven/src/plugins-build/latka/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/latka/xdocs/index.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- index.xml	17 Dec 2002 16:21:50 -0000	1.2
  +++ index.xml	18 Dec 2002 14:45:13 -0000	1.3
  @@ -12,6 +12,7 @@
         <ol>
           <li><a href="#Overview">An overview of how this plugin works</a></li>
           <li><a href="#Customizing Latka">How to get more from Latka</a></li>
  +        <li><a href="#Generating Suites">How to generate Latka test suites</a></li>
           <li><a href="#Futures">What's in store for the Latka plugin</a></li>
         </ol>
       </section>
  @@ -80,6 +81,48 @@
             </ul>
           </p>
         </subsection>
  +    </section>
  +
  +    <section name="Generating Suites">
  +      <p>
  +        The plugin has a goal <strong>(latka:jmeter-convert)</strong>
  +        that takes a set of requests as recorded by 
  +        <a href="http://jakarta.apache.org/jmeter/index.html">JMeter</a>'s
  +        Http Proxy and converts them into a Latka suite. You can easily set up
  +        a browser with the correct proxy settings, and simply by using
  +        your web application, you can create tests that this plugin can
  +        later replay.
  +      </p>
  +      <p>
  +        The JMeter documentation contains a section on setting up the HTTP
  +        Proxy feature. This allows you to set 'listen' to requests being
  +        sent to the application and save the request details in XML format.
  +        JMeter can be set up to filter out requests by specifying a regular
  +        expression to match the incoming requests. This lets you only record
  +        relevant requests for your tests, e.g. HTML or JSP files, Struts
  +        actions with a .do extension etc.
  +      </p>
  +      <p>
  +        The <code>jmeter-convert</code> goal looks for a property passed to
  +        Maven, <code>jmeterFile</code>. If this file exists, the plugin
  +        blindly assumes it's a JMeter file and generates a corresponding
  +        Latka suite, containing all the requests in the JMeter file with
  +        the appropriate web server, port, request path and parameters.
  +      </p>
  +      <p>
  +        The file that is generated, 
  +        <code>${maven.build.dir}/latka/jmeter-suite.latka</code>, can then
  +        be editied and placed in the Latka source directory.
  +      </p>
  +      <p>
  +        To convert a file, say <code>C:\JMeter\test.jmx</code>, into a Latka
  +        suite, invoke Maven like this:
  +      </p>
  +      <source>maven -DjmeterFile=C:\JMeter\test.jmx latka:jmeter-convert</source>
  +      <p>
  +        This will produce a file, <code>target\latka\jmeter-suite.latka</code>
  +        ready for editing or execution.
  +      </p>
       </section>
       
       <section name="Futures">
  
  
  
  1.2       +6 -0      jakarta-turbine-maven/src/plugins-build/latka/xdocs/goals.xml
  
  Index: goals.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/latka/xdocs/goals.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- goals.xml	8 Dec 2002 12:41:33 -0000	1.1
  +++ goals.xml	18 Dec 2002 14:45:13 -0000	1.2
  @@ -21,6 +21,12 @@
             This goal runs all latka tests in the <code>${maven.latka.src.dir}</code>
           </description>
         </goal>
  +      <goal>
  +        <name>latka:jmeter-convert</name>
  +        <description>
  +          Convert a jmeter jmx file to a latka suite
  +        </description>
  +      </goal>
       </goals>
    </body>
   </document>
  
  
  
  1.4       +24 -1     jakarta-turbine-maven/src/plugins-build/latka/plugin.jelly
  
  Index: plugin.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/plugins-build/latka/plugin.jelly,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- plugin.jelly	8 Dec 2002 13:22:29 -0000	1.3
  +++ plugin.jelly	18 Dec 2002 14:45:13 -0000	1.4
  @@ -1,12 +1,15 @@
   <?xml version="1.0"?>
   
  -<project xmlns:j="jelly:core" xmlns:u="jelly:util">
  +<project xmlns:j="jelly:core" 
  +         xmlns:u="jelly:util"
  +         xmlns:x="jelly:xml">
   
   
     <goal name="latka" description="Run the project's latka tests">
       <attainGoal name="latka:test" />
     </goal>
   
  +  <!-- run all Latka tests in the project -->
     <goal name="latka:test" description="Run the project's latka tests">
   
       <j:set var="latkaSrcDir" value="${maven.latka.src.dir}"/>
  @@ -39,4 +42,24 @@
       <j:if test="${!latkaSrcDirExists}"><echo>No Latka source directory found</echo></j:if>
     </goal>
   
  +  <!-- convert a jmeter set of requests to a latka suite -->
  +  <goal name="latka:jmeter-convert"
  +    description="Convert a jmeter jmx file to a latka suite">
  +
  +    <u:available file="${jmeterFile}">
  +      <j:set var="outFileName">${maven.build.dir}/latka/jmeter-suite.latka</j:set>
  +      <echo>Converting ${jmeterFile} to a latka test suite</echo>
  +      <!-- Major hack - set jaxp properties as they are foobared -->
  +      ${systemScope.setProperty('javax.xml.transform.TransformerFactory','org.apache.xalan.processor.TransformerFactoryImpl')}
  +
  +      <x:parse xml="file://${jmeterFile}" var="jmeter"/>
  +      <mkdir dir="${maven.build.dir}/latka" />
  +      <j:file name="${outFileName}" prettyPrint="true">
  +        <j:import uri="jmeter2suite.jelly" inherit="true"/>
  +      </j:file>
  +      <echo>Latka test suite '${outFileName}' created</echo>
  +    </u:available>
  +
  +  </goal>
  +  
   </project>
  
  
  
  1.1                  jakarta-turbine-maven/src/plugins-build/latka/jmeter2suite.jelly
  
  Index: jmeter2suite.jelly
  ===================================================================
  <?xml version="1.0"?>
  <m:project xmlns:j="jelly:core"
    xmlns:test="jelly:junit" 
    xmlns:m="jelly:jeez"
    xmlns:x="jelly:xml"
    xmlns:l="jelly:org.apache.commons.latka.jelly.LatkaTagLibrary"
    xmlns="dummy">
  
    <suite>
      <session>
        <x:forEach select="$jmeter//testelement[@class='org.apache.jmeter.protocol.http.sampler.HTTPSampler']">
          <j:set var="host"><x:expr select="property[@name='HTTPSampler.domain']/text()"/></j:set>
          <j:set var="port"><x:expr select="property[@name='HTTPSampler.port']/text()"/></j:set>
          <j:set var="path"><x:expr select="property[@name='HTTPSampler.path']/text()"/></j:set>
  
          <request host="${host}" port="${port}" path="${path}">
            <!-- params next -->
            <x:forEach select=".//testelement[@class='org.apache.jmeter.protocol.http.util.HTTPArgument']">
              <param>
                <paramName><x:expr select="property[@name='Argument.name']/text()"/></paramName>
                <paramValue><x:expr select="property[@name='Argument.value']/text()"/></paramValue>
              </param>
            </x:forEach>
            <validate><statusCode /></validate>
          </request>
        </x:forEach>
      </session>
    </suite>
    
  </m:project>