Sunday, July 14, 2013

JMeter -- Process Setup 07 -- Explaining Build File 02


This is part seven of our setup.  Part six can be found here: http://dudewheysmehblog.blogspot.com/2011/09/jmeter-process-setup-06-explaining.html

My apologies for the large time gap between part 6 and part 7.  Let's get to it!

We will be covering what the following targets are doing: transformation, transform, perfStart, perfStop, mailSuccessCompile, mailSend, fullrun, and fullrunOneTransform.

target="transformation"
This is exactly the same as transformationOld, except with two transformations: a less detailed one and a more detailed one.  The reason why I did this is simple.  After the test is completed, people get a mail notifying them with links to the report files.  Some people like to check their work mail on the phone.  The detailed report is very large and takes forever and a day to load.  The less detailed report loads very quickly and gives a good summary of what has happened in the test.

target="transform"
Sometimes a test will stop or be stopped prematurely, but you still want to see a report.  What you need to do:
  1. Go to the results folder and see if there is a .JTL file associated with the test -- you can tell by the filename's timestamp.  If the .JTL is not there, you'll have to re-run.
  2. If the .JTL is there the XML will probably be malformed.  Open it up in Notepad++ and check the end of the file.  It should have a closing </httpSample> tag and it should end with </testResults>.  If a tag is missing, add it in the correct spot, save the file, and close it.
  3. Now you can use the transform target to just run the XSL transformation on the .JTL file.  You have three options:
    1. ant -Dfile="[JTLFilename_without.jtl_atTheEnd]" -Dproject="[projectName]" transform
      1. This does absolutely nothing.  You need to add the -Dxsl flag at the end and set it to either "full" or "less".
    2. ant -Dfile="[JTLFilename_without.jtl_atTheEnd]" -Dproject="[projectName]" transform -Dxsl="full"
      1. This runs two transformations on the .JTL file, the Detailed and the Less Detailed ones.  Two reports are generated.
    3. ant -Dfile="[JTLFilename_without.jtl_atTheEnd]" -Dproject="[projectName]" transform -Dxsl="less"
      1. This runs one transformation on the .JTL file - the Less Detailed one.  One report is generated.
target="perfStart"
This target is called by other targets in order to set a counter name and start Perfmon.  It uses a built in utility in Windows called logman, which I'll get into once we reach Process Setup 10.  To satisfy your curiosity, open a command prompt and enter: "logman query".  You should see something like this:


  • We are using the Ant "exec" command to build up a command which will be executed.  Think about this as if we are telling Ant to open a command prompt and enter a string of commands.
  • After the first echo, we are building up the following command: logman update=[${counterName}] -o "C:\PerfLogs\Admin\${project}\ReportLog_${time}\WebServer.blg -u ${compU} ${compP}
    • counterName is the name of the Data Collection Set that we will be using.  As an overview, we will create a Data Collection Set and choose all of the different performance counters that we are interested in tracking.  This command updates this counter to OUTPUT the data to a folder specific to this Project & this Test, so that it's easy to find later on.  counterName is set in extra.properties.
    • compU and compP are the user name and password that are needed to edit the Data Collection Set.  If I recall correctly, it should be the same as your windows login and password, IF NEEDED.  These are also set in extra.properties.
  • After the second echo, we again use exec to build up the command to start logman, which is simply: logman start ${counterName}.

target="perfStop"
Similar to the last part of the perfStart target, this utilizes the Ant exec command to stop Perfmon: logman stop ${counterName}.

target="mailSuccessCompile"
It's was not easy, at least when I created this, to concatenate and manipulate strings, which is why the var folder was necessary.
  • We start by copying the contents of the ${project} variable into the project.txt file.  We then replace spaces in the file with the HTML encoded value "%20".  We repeat this for ${file} > file.txt and ${folder}> folder.txt.
  • All of the var files are loaded into variables.
  • A lot of the rest of this target is just doing math & string operations in order to output a nicely formatted calculation of the time in the email.
  • The last part of this target puts text into two var files, subject.txt and mailbody.txt.
    • The subject will be, for our example: "BC Rich Load Test <timestamp> - Success"
    • The body will be an HTML document with a funny picture, a table with test time info and links to the reports.
      • The table contains: Test name, Start Time, End Time, and Total time.
      • The reports are the Detailed JMeter Report, the Less Detailed JMeter Report, and the Perfmon .BLG's & HTML report.

target="mailSend"
This target sends a mail depending on the status.  It checks if the value of the var/failed.txt file is "No" and if so, it gets all the pieces together and sends the Succes mail out, otherwise it sends the Failure mail.  Some properties (enableStartTLS, user, password, and ssl) are required if using a gmail address & can probably be removed if you're using an internal address.

target="fullrun"
This target pretty much just calls all the other targets in sequential order.  The calls to the other targets are located within a trycatch statement, which checks to see if there are any errors.  If there are any errors, the sequence stops, the var/failed.txt is set to Yes, and a Failure mail is sent.  To use this target, use the command: ant -Dfile="[filename]" -Dfolder="[folderName]" -Dproject="[projectName]" fullrun
  • It starts by resetting the var/failed.txt file to No and then calls:
    • perfStop (to stop the counter if it is running)
    • perfStart (to properly set the counter/log and start the monitoring)
    • jmeterStart (to run the test)
    • transformation (to perform two transformations)
    • perfStop (to stop the counter)
    • mailSuccessCompile (to compile the Success Mail)
  • If any of the previous calls fails, the failMessage is stored and var/failed.txt is set to Yes
  • mailSend (to send the Success Mail)

target="fullrunOneTransform"
This is exactly the same as fullrun, except it performs a single transformation (by using transformationOld instead of transformation).  To use this target, use the command: ant -Dfile="[filename]" -Dfolder="[folderName]" -Dproject="[projectName]" fullrunOneTransform

Summary:
The build file has many targets, some of which are meant to be called from the command line, and others which are meant to be called sequentially.  You are welcome to tweak each one as you see fit.  Pretty much anything you can do manually on the computer can be automated using Ant -- you just need to find the proper command and modify the build file.

Recap & Next Steps:
We have covered how to set up JMeter and Ant and get your tests' reports up and running.  We have tweaked our properties and have modified our build files.  Next we will go over what the XSL files are doing, setup a way to programmatically run our tests (locally or on remote machines) with batch files, and then monitor everything being used with Perfmon.

In Process Setup 08, we will look into the XSL files and how to tweak them.
Part eight has not yet been completed.

Sunday, April 28, 2013

Removing all Hyperlinks in MS Word 2010

Found this neat keyboard shortcut for MS Word 2010 today:
Remove all hyperlinks in a document by highlighting all of the text and hitting:
 CTRL  +  Shift  F9 
In MS Office 2010, it removes the hyperlink and changes the text to the normal color.  In older versions, the text may still be blue.  To change it, just keep the text highlighted and change the font color like you normally would.

Friday, December 14, 2012

Condolences and Gun Control arguments

My heart goes out to those who have passed and those who are suffering in Newtown, Connecticut.

I've heard many people from the NRA state that "Guns don't kill people.  People kill people."  That's true.  Guns are just tools, like a hammer, a knife, or a car.

While people can kill other people using these tools, that doesn't make all tools equal.

  • A hammer can be used to hit a nail, or to hit a person.  It was created though to hit a nail.
  • A knife can be used to cut a fruit, or to to cut a person.  It's normal use though,  is to cut food.
  • A car can be used to drive from A to B, or to drive into a person or into another car.  It was created as a mode of transportation, and that is it's normal use.
A gun can be used for killing animals for fun/sport, or for killing people.
It's a tool for killing.  You can't build a house with a gun.  You can't cut an apple to feed your baby with a gun.  You can't drive from A to B with a gun.

A gun is for killing.  Nothing else.

Having a gun for "defense" means that you want to defend yourself by killing someone else.  If someone ever broke into a gun owner's house, the chances are high that he'll get shot "center mass," and be leaving in a body bag.

A gun is for killing.
And the prime use is for killing other people.

Should all guns be banned?  Probably not, but something definitely needs to be done.

Sunday, November 11, 2012

Random thoughts - Best Beginnings

While going through the daily motions today, I remembered two of my all-time favorite opening sequences:

Gandalf's Fall (at the beginning of the Two Towers)
and

Nightcrawler, taking out everyone (from X-Men 2)

I guess I like movies like that where I know the characters before hand and how bad-a** they are (and will be), and I don't get too disappointed (especially when there's a good director involved)!

What opening sequences dropped your jaw when you first saw it?
Related Posts Plugin for WordPress, Blogger...