Friday, September 23, 2011

JMeter -- Process Setup 06 -- Explaining Build File 01

This is part six of our setup.  Part five can be found here: http://dudewheysmehblog.blogspot.com/2011/08/jmeter-process-setup-05-editing.html

If you've been following along, you'll know by now that the heart of this process lies in the Ant build.xml file.  Here is the one which you can use / tweak for your purposes: https://docs.google.com/leaf?id=0Byis5NEZXwweZmQ1YjA4NjctYTgwNi00ZTU1LWExMjMtMDA3ODI1Yzg4ZjIz&hl=en_US

If you have any doubts about anything, please read through the Ant Manual.

We start off with a huge commented out section with basic information about where the instructions I followed were from http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php.  It also goes on to say that we should execute the commands from an Admin command prompt if possible.  Then we have directions on how to run a script and a checklist of things that we should make sure of before running a test.
Please read through this and understand how to call Ant properly.

  • Project
    • the name of the project.
    • the default target to start from (if we don't specify a target from the command line)
      • the default we specify is the target named "build"
    • the base directory where this file is located.
  • Taskdefs
    • These are the tasks which we are extending Ant with.
      • Jmeter
        • name is jmeter
        • classname is given -- no need to change
      • AntContrib
        • resources is given -- no need to change
      • Antelope If Task
        • name is if
        • classname is given -- no need to change
        • classpath is where the antelopetask-3.2.10.jar is located -- if you have this in a different location, please specify it here.
  • Set timestamp & base properties
    • Current Timestamp is captured and stored in 3 variables, time, timeFull, and timeIntl.  Each of them have a different format.
    • 3 properties are set.
      • file = *
        • if file is not set when calling Ant, it will default to all the files in base directory -- all of them will be run.  Note: Not specifying a file usually results in transformation failing.  I haven't gotten a workaround in place for this to work correctly.
      • folder = ""
        • if no folder is set when calling Ant, it will be blank
      • extra.properties is loaded.
        • all of the parameters/properties set in the extra.properties file is loaded and populated in the build.
  • Targets - these are the main containers for the various actions we want performed: start/stop Perfmon, starting Jmeter, doing a transformation, compiling the mail, sending the mail, etc..  You can read the descriptions for each target in the build.xml file.
I'll explain a few flows now, and hopefully by the end you'll understand be able to apply to understand the rest of them.  For each of the following examples, the hypothetical test script name is BCTest.jmx which is located in the scripts/BC folder.

All this script does is navigate to the BCRich http://www.bcrich.com/shape/beast/guitars-and-bass/3 -- one thread, one second rampup time, and 1 iteration.
Make sure that in extra.properties, remote = false (because we're running this off of the local machine).

  1. Open the command prompt (Win+R) > cmd, enter.
  2. Navigate to the jmeter/bin folder:
    cd C:\jakarta-jmeter-2.4\bin
  3. Execute the Ant command:
    ant -Dfile="BCTest" -Dfolder="BC" -Dproject="BC Project"
    1. -Dfile tells ant that the variable file = "BCTest".
    2. BCTest is located in the folder "BC" (which is what -Dfolder states).
    3. When we save the results and report, we want it saved in the Project folder named "BC Project" with a space.
  4. We should get a success message:

  5. We will see the "BC Project" folder created under both the reports and results folder, each of them containing a file corresponding to this run:

So lets dig into the build.xml file to see exactly what just happened.

  1. Firstly since we didn't specify to Ant which target to use, it used the build target by default (look above to the Project section).  If we wanted to specify a target, we'd use the argument -t targetName.
  2. So the build target is calling 2 other targets -- firstly it is calling jmeterStart and then transformationOld.
  3. Let's look under jmeterStart to see what is going on:
    1. First the timestamp is being captured and output to certain files in the var folder for use later.
    2. Next, we have an echo of the inputs.
    3. Next we have the jmeter section, which has the following:
      1. jmeter's bin location
      2. where the result will be saved (results\projectName\Testfilename_time.jtl)
      3. whether to run remotely or not (pulled from extra.properties)
      4. which file will be run (located in the scripts folder, under the subfolder "folderName" and including the file we specified (BCTest.jmx)
    4. Next, we have another timestamp being captured and output to certain files in the var folder for use later.
  4. Under transformationOld, we only have the XSLT instructions:
    1. The input file (which was the .JTL log file from JMeter).
    2. The output file (which is the .HTML file which gets generated).
    3. Which XSL file to use for the transformation (which is found in the reportXSLs folder).  For this run, the uncommented xslFilename from the extra.properties is used (jmeter-results-detail-report_21).
    4. Whether to overwrite the report file (if for some reason there is one with the same name present) -- which is set to true (otherwise, if that case did happen, the build would fail).
This flow is almost exactly like that of the original ant run we did in Process Setup 03.

In Process Setup 07, we will go more in depth with other parts of the build.xml file.

3 comments:

  1. HIWhen will you publish Part7??

    ReplyDelete
  2. Hi , Wonderful Job, but u left me wanting for more.
    I have configured it perfectly so far. but i wanted to completely automate my tests runs. I need to include those jmeter plugins features . How do i inculcate them in here.

    ReplyDelete
  3. Hi Sree & Veerendra Kumar, thanks for the comments & motivation to continue this. I finally have found some time, and Part 7 has been finished: http://dudewheysmehblog.blogspot.com/2013/07/jmeter-process-setup-07-explaining.html. I'll try to finish the rest quickly! I had made some changes to the build.xml file and the extra.properties file, so you can redownload them from Google Drive: https://docs.google.com/leaf?id=0Byis5NEZXwweZmQ1YjA4NjctYTgwNi00ZTU1LWExMjMtMDA3ODI1Yzg4ZjIz&hl=en_US. Thanks for your patience! --Rishi

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...