Monday 24 February 2014

Capturing the response data size limit in JMeter

View Results Tree is very useful listener especially when you are debugging your test plan. You can review the response data and ensure that your test plan works good. But sometimes you you can see a message in the beginning of the response data like "Response too large to be displayed. Size: 313674 > Max: 204800, Start of message:".



And unfortunately you are not able to see the whole response data. By default JMeter shows only first 200 Kb of response data. To resolve this problem you should edit the file jmeter.properties and uncomment the line:

view.results.tree.max_size=0 This will disable response data size check at all.


After you have saved jmeter.properties you will never see this message again.


How to save test results in jmeter


There is one more way about how to do it - using the command line options.

So, if you want to run the test plan from file test.jmx and save the testing results to the file log.jtl, use the following command:

jmeter -n -t test.jmx -l log.jtlYou can configure how the result data will be saved by editing the file jmeter.properties (section "Results file configuration"). For example, if you want to save the results in CSV format you should edit the following property:

jmeter.save.saveservice.output_format=csvThis way is more powerful than the one described in the previous part (Simple Data Writer) because it allows you to set some additional options like CSV delimiter, timestamp format, etc. Sometimes it could be very helpful.

Troubleshooting the Astra Load Test Monitor

How the Monitor Works

The monitor will run the script in the Astra LoadTest (ALT) application. It is running through perfex, and will spawn an mdrv process to execute the script. Perfex is required so that the mdrv process will be created with the credentials supplied in the ALT Recorder page.

The script is run in exactly the same way as it is run under Astra LoadTest in load mode. Astra Load Test will use the credentials defined in the Recorder page.

The Astra LoadTest log files are kept in the SiteScope\cache\tempbysize directory. The monitor parses this log file to get the transaction times and errors/warnings. By default, SiteScope saves only the log files of failed runs. If the run finished successfully, the log is not saved. However If you want to keep all the log files, you have can open the SiteScope/groups/master.config file and set to "true" the following entry:

_astraKeepLogFiles=

How to Troubleshoot

1. Make sure you have Astra LoadTest version 5.4.3 or later. It must be installed on the same machine where SiteScope is running.

2. When setting up the script initially in ALT, you must define at least one Transaction while recording (with Start and Stop points), or the monitor will fail in SiteScope.

3. The credentials (in Recorder page) have to be the same as the user that was logged in when Astra LoadTest was installed.

4. Check that you can run the script in Astra LoadTest directly. If the script runs in Astra Load Test but times out in SiteScope, then use WinInet mode to execute the script instead. In order to switch between WinInet and Turbo replay you have to go to the RTS – Browser Configuration tab and check/uncheck the Use Turboload Technology option.

5. If you are running SiteScope service as a LocalSystem Account, add the user credentials located in the Astra LoadTest Runners Preference page. This is in the help manual at:

http://your SiteScope server name and port/SiteScope/docs/recorderPrefs.htm

SiteScope should run as an interactive service in the context of the LocalSystem account. It can be changed in Control Panel -> Services -> Sitescope -> Properties -> Log on. Select the Allow interaction with desktop checkbox.

6. Every time SiteScope restarts, it cleans up the oldest Astra LoadTest log files in the SiteScope/cache/tempbysize directory according to the max size limit defined for this directory in the SiteScope/groups/master.config file. The entry is:

_tempDirMaxSize=10000 (the size is in KB)

In SiteScope 7.8.1.0, there is no default value for that entry, and that will cause all the files in the directory to be deleted. There is a default of 10000 in SiteScope 7.8.1.2 and later. If the entry is not there, then add the above entry to the master.config file, save it, and restart SiteScope. After that, the log files should be kept until the directory gets to the limit defined.

Note – Astra Load Test has been deprecated as of SiteScope 7.9.0.0 or later. It is only available in these versions if SiteScope has been upgraded from a pre-7.9.0.0 version.

JMETER TIPS AND TRICKS

1. How to add JMeter requests manually and 
2.Need to capture the traffic for a web front end that’s heavy in AJAX. So there’s a lot going on in the background that I don’t get to see by just making a request to the page. I could use a third party app or an addon like Firebug to grab all the traffic but when that functionality is built into JMeter I’d just be making work for myself.

I have the bare bones of my test plan in place. In the test plan node I create a User Defined Variable called serverName with the relevant target server name as the value. I’m ready to record the transactions for a short user story. I create a blank transaction controller to group the page requests (this relates to another tip I’ll post later) then in the Proxy Server config I set the Target Controllerto this empty one.

Changing the proxy server and port in the browser, I point the browser at the required location and record the transaction. For the next step I create another empty Transaction Controller, update theTarget Controller of the Proxy Server, and continue with the user story, repeating this process for each step.

This can seem cumbersome but it lightens the work load. It also allows you to go back and edit the request, adding whatever assertions you feel may be warranted while the step is clerar in your mind. An alternative would be to set the Grouping on the Proxy Server to Put each group in a new controller and later copy and paste these grouped requests into transaction controllers seperately. Either way would work. Just don’t get too far ahead of yourself and record a large slice of your user story without analysing it.

Now if I go back and look at an HTTP request created during the user story, the Server Name or IPfield has been automatically filled with the appropriate variable i.e. ${serverName}. Any other variables I set are also automagically entered into their appropriate fields.

Creating Regular Expressions in JMeter

Creating Regular Expressions

Regular expressions can be a bit daunting at first, so here is a suggested procedure to help create them.

Getting Started
Ensure you have an exact copy of the source document that you want to operate on.

One way to do this is to attach a Save Responses to a file Listener to the Sampler, and run the test to create a copy of the resource.

You can then use the HTTP Sampler with the “file:” protocol to retrieve the page at any time.

Extract the section you are interested in
Find the variable part that you want to extract (in the file, or in the Tree View Listener), and start by using that as the regular expression.

For example, suppose you want to find the value from the following snippet:

input type=”hidden” name=”secret” value=”CAFEBABE.12345(3)”

Start with exactly that as the regular expression, and check that it works, for example in the Tree View Listener Regex tester panel.

If not, examine the expression for any meta-characters (characters that have a special meaning in regexes).In this case, the only special characters are the “.” and the parentheses “(” and “)”.These need to be escaped, by being prefixed with “\”. We now have:

input type=”hidden” name=”secret” value=”CAFEBABE\.12345\(3\)”

This should now match the whole phrase.

The next stage is to tell the regex processor which part of the section you want to use. This is easy, just enclose the characters in parentheses.

So assume you want to match just

CAFEBABE.12345

Your regular expression then becomes:

input type=”hidden” name=”secret” value=”(CAFEBABE\.12345)\(3\)”

Fix the expression so it matches variable text

Of course, the previous expression is not much use, as the text it matches is already known. We want to match variable text, so we have to replace the fixed characters of the target text with meta-character expressions that will match all possible variations of the target.

This requires knowledge (or a good guess) as to what possible characters can be used in the target.

In this case, it looks as if there is a string of hex characters followed by a number, followed by a digit in parentheses.

A digit is easy, that’s “\d”, so a number is “\d+”, where the “+” means one or more of the previous item.

A hex character can be represented by “[0-9A-Za-z]“. The enclosing “[ ]” create a ”character class” which matches one of the specified characters.
The “-” here means a range.

So putting that together, we get:

input type=”hidden” name=”secret” value=”([0-9A-Za-z]+\.\d+)\(d\)”

Now suppose we wanted to match the whole of the value. We could move the closing capture parenthesis to the end of the value.

This would be suitable if there were other values with different patterns that we did not want to match.

However, if we just wanted to capture the quoted value, then we could use:

input type=”hidden” name=”secret” value=”([^"]+)”

The character class in this case is ”[^"]” which means any character except double-quote. The “+” suffix means we want as many as there are in succession.

This will take us up to the end of the value.

If the expression matches more than once in the source, you have a choice:

* specify which match to use
* extend the expression to include more context at the beginning or end so the match is unique

Installing Apache JMeter in Windows XP

Prerequisites for installing Apache JMeter

Apache JMeter is a utility based on Java. We need Java runtime already installed to use Apache JMeter. After confirming that our Windows XP system has proper Java runtime installed we can proceed for installing Apache JMeter.

For checking whether we have Java runtime installed we can follow one of the methods given here. The second method given on that page is the easiest and that is opening a command prompt and typing the command:

java -version

If the command works Java is installed and you will also know the version of Java.

Apache JMeter runs on a fully compliant JVM 1.4 or higher. (It is found that some early versions of Java 1.5 below update 7 do not recognize some JVM switches and hence the jmeter.bat script file needs some changes to run JMeter, described at the end of post).

Steps for installing Apache JMeter


The Apache JMeter Home page contains links for downloads. When we visit Apache JMeter home page the Apache Jakarta project symbol of a bird feather can be seen with introduction to JMeter.






As shown in the image below we have to select the Download Releases link from the home page.



The download page presents many options for download. Usually the suggested mirror is the best mirror but we can choose another one if the suggested mirror gives error or seems slow. For just using the tool we need only the binary release. The screen below shows the version current at the time of writing this article. The TGZ version of the binary is relatively smallest in size. Click on that link and save the download when prompted by the browser.

Alternatively you can click on the ZIP version given below and use any standard UNZIP utility to extract the files.



I have saved the TGZ file and extracted the contents by using 7Zip utility for windows. After extracting the TGZ file we get a folder named jakarta-jmeter-n.n.n, where n.n.n is the version number which we downloaded.

The executable script for Apache JMeter is located in the bin directory.



The screen below shows all the contents of the jmeter bin folder.

Starting Apache JMeter tool


The executable script for Windows platform is jmeter.bat for Linux systems it will be jmeter.sh
These scripts are used to start JMeter in GUI mode. Let us double click the jmeter.bat script to start the tool.



Double clicking the jmeter.bat file will start one command prompt and the JMeter utility in GUI mode, as shown below. The command prompt is tied with the GUI and hence cannot be closed. If the command prompt is closed the GUI will terminate. We can keep the command prompt minimized while working with JMeter GUI. The command prompt is useful in viewing any JMeter exceptions that may occur.



We saw how to download, install and start the Apache JMeter utility.

NOTE: Although Apache JMeter can run on any fully compliant Java version above Java 1.4 (It is found that some early versions of Java 1.5 below update 7 do not recognize some JVM switches and hence the jmeter.bat script file needs some changes to run JMeter. If you happen to have early Java 1.5 version below update 7 then you may get error when double clicking the jmeter.bat file. The error can be fixed by commenting line "set DUMP=-XX:+HeapDumpOnOutOfMemoryError" in the jmeter.bat file. Open the jmeter.bat file by right clicking and choosing Edit option. add REM before that line and you are ready to go.

Reference:

1) http://jakarta.apache.org/jmeter/usermanual/get-started.html#install