CheatSheet for JMeter __time Function Calls

Often I have to deal with dates and times in my scripting and luckily JMeter is quite good at dealing with them. The function to call is __time (JMeter doco http://jmeter.apache.org/usermanual/functions.html). The thing is the doco is pretty sketchy about all the different formats it can take. So I just created a test script to see what works. The examples are below ready to copy & paste. I also have included scripts for time and date manipulation for completeness.

Continue reading

My Daily Tool Use

SublimeAs a performance tester I spend most of my daily time somewhere between the browser and a web server. I also so spend a lot of time on servers themselves analysing data. So I thought I’d write a bit about the tool landscape I tend to use. In my tool selection I favour Open Source software. Mainly because I don’t have to fluff around with licenses but also because I can look at code if I need to. It allows me to focus my resources on training people. I do tend to feed back into OSS, whenever I can (which is seldom as I am usually not that clever;-) ).

I also do a lot of bespoke programming to automate processes. This is not at the level a developer would do things but more on a simple scripting level. But not to be underestimated what power this can unleash in your day to day work.

Continue reading

Extracting a value from JSON with JMeter

So again an issue I had and thought I’d share. I found very little about this on Google. The problem I had was, that I got a JSON response from a site that contained an ID I’d need to use on the next page. The challange was that I had a variable in the regex which JMeter doesn’t seem to like. The easiest way to do this is to use JMeter-plugins!!!

Short post, if it were not for the unlucky fact that I couldn’t use the plugins. So here the long answer….

Continue reading

Iterating over a CSV file in JMeter

A common problem in JMeter is that you want a CSV file as an input and want to execute each line, then continue. So from a script perspective that would look something like this:

Thread Group
 |-For Each CSV Line
 |  |-HTTP Request (CSV input)
 |-Do something else

The issue though is there is no “For Each” concept in JMeter. I know that it is called a ForEach Loop in JMeter but it isn’t from a developer view. You need to know the length of your CSV file. You could just tell the For loop how many lines there are but that would make it very unflexible. You’d need to adjust the script every time the CSV changes.

So here is how I solved it. Not elegant but it actually works quite well.

Continue reading

KWST 2015

Just a follow up on the 2015 Kiwi Workshop on Software Testing (Aug 2015). Find my write-up here:

http://www.associationforsoftwaretesting.org/2015/10/11/grant-program-kwst2015/

KWST 2015

In attendance this year were:
James Bach, Oliver Erlewein, Richard Robinson, Aaron Hodder, Sarah Burgess, Andy Harwood, Adam Howard, Mark Boyt, Chris Priest, Mike Talks, Joshua Raine, Scott Griffiths, John Lockhart, Sean Cresswell, Rachel Carson, Till Neunast, James Hailstone, David Robinson and Katrina Clokie

by
Oliver Erlewein

Loading File Contents Into a JMeter Variable

Sorry for the ongoing spam about JMeter stuff but I am writing a LOT of coding at the moment and I thought I’d share some of the knarly stuff I come accross so others might benefit.

So I had the issue that I need to cobble together MIME HTTP/SOAP calls that contain attachments. JMeter has the ability to add files statically to an HTTP Request (Body Data) but if you need more control you need to roll your own. Best way to do this would be to load the file into a variable and just attach like this:

...
--MIME_boundary
Content-Type: application/pdf
Content-Transfer-Encoding: binary
Content-ID: <MyFile.pdf>
Content-Disposition: attachment; name="MyFile.pdf"

${AttachmentFile}
--MIME_boundary--
...

But how do you get it into the variable?

Continue reading

HMAC and SHA256 in JMeter

Some projects require authentication features that involve some quite intricate steps. But fret not, in JMeter we can use Groovy to do the heavy lifting. Below is a very simple example of how you can do a HMAC encryption. It also includes the SHA256 hashing and base64 encoding. The only thing missing are the functions to read the variables from JMeter and publish the hash to JMeter but that is trivial and you can fit it into whatever you already have scripted.

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;

String secretKey = "secret";
String data   = "Message";

Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKeySpec = new SecretKeySpec(secretKey.getBytes(), "HmacSHA256");
mac.init(secretKeySpec);
byte[] digest = mac.doFinal(data.getBytes());
encodedData = digest.encodeBase64().toString();
log.info("HMAC SHA256 base64: " + encodedData);

by Oliver Erlewein

 

KWST 2014

A late report from our workshop last year. I stumbled across it again in my preparations for KWST (Kiwi Workshop on Software Testing) 2015. It was supposed to be published through our gracious sponsor, The Association for Software Testing (AST), but it never eventuated. So I thought I’d post it here. Better late than never.

So here goes….

For the fourth year in a row, Wellington (New Zealand) has successfully hosted the Kiwi Workshop on Software Testing. The two-day intensive testing workshop is one of the key drivers of the Context-Driven Testing (CDT) community Down Under.

In its beginnings, the aim was to give the experienced and senior community members a platform to drive innovation and exchange ideas. The impact of KWST in the community over these past years has had far reaching effects in New Zealand as well as Australia.

Workshops, conferences, and magazines have emerged since, which have lifted the game right across the board. KWST 2014 was specifically aimed at involving new faces in the community and not drawing as much on the established KWST crowd.

The topic this year was:

“How to speed up testing? – and why we shouldn’t”

Continue reading

Current ISO #stop29119 & Petition

As you probably can’t have overlooked there is a Petition out for stopping ISO29119. On this blog we have all signed the petition and wholeheartedly agree with the sentiments/concerns that a lot of testers have. Since there’s been a lot written about this we don’t think we have much detail to add. So if you want to sign the petition go here:

 

If you need the short and low down we suggest reading the excellent abstract by Michael Bolton here. The CAST presentation/video that kicked it all off here.

Also see our original post from way back when hereFor MUCH more in depth stuff read everything you can find here (see you in a week or so ;-) ).

We’re all hoping you will join in supporting this cause. Also follow twitter hashtag #stop29119 for new developments.

by Oliver Erlewein

Test Metrics Debunked – Defect Density (3/5)

This post is the third in our series on metrics in software testing. So far we’ve looked at residual risk (here), coverage (here), and this time it’s defect density.

The following is taken from the post that sparked the series…

3.  Defect density is another metric that matters. It translates into where are the defects and how many are there? Identify each of the parts of the solution that you care about (front end, back end, service layer), or user type, or functional area, or scenario then make sure everyone know these identifiers and uses them whenever a defect is raised.

From a bird’s eye view the idea of defect density is a good one, but as testers we know that the devil is in the detail. It could be seen as a powerful risk evaluation technique to be able to know where the defects are located in a particular product. However, the value stops with this illusion. It is about as useful as asking where the developer hid all the defects.

Continue reading