2013-01-13

How to record steps for load test in JMeter?

In this article we are going to see the process of recording steps in JMeter for Load Testing.

Planning for the test : In the beginning, we have to decide what to test. What should be in the test. After that , we write the steps in doc. For EX- I am writing my steps to test goole search load test. So my steps will be
a. Open Browser and write URL www.google.com
b. Accept certificate if they are asking for that.(In case of https)
c. Write a text in the search text box(I wrote "Example of jmeter recoding)
d. Click Search

After writing the steps, We have to make plan to record in jmeter. Jmeter record steps by capturing data through proxy. So, we have to set a proxy from browser and use a proxy server from jmeter to record that. 

So, Lets start Jmeter Part

1. Download and Install JMeter
2. Run JMeter, It will be opened with a Test plan
3. Add a HTTP Cookie Manager under Test plan[For global cookie]
4. Add a Thread group under Test plan(I have used 3 user for 2 second and 3 cycle to run)
5. Add a Test Fragment under Test plan(Test fragment is the helper for test case making, we will record with this)
 
6. Add Recording Controller under Thread group
 
7. Add a HTTP Proxy Server under Test Fragment

Note : For Jmeter 2.28we will not get by add element under test fragment. We have to add a HTTP proxy server under workbench and then move(cut/past) that under test fragment.
8. Add a Listener(View Results Tree) under HTTP Proxy Server[Optional]

9. Now, See HTTP Proxy Server, I use port 8080 and http client 3.1 for proxy
10. Now, open a browser( I use Firefox) and set proxy as localhost with port 8080.
Note: Use all protocols to use the same proxy
For Firefox :
Tools-> Options -> Advance ->Network ->Connection -> Settings
a. Select, Manual Proxy Configuration
b. Set HTTP Proxy as localhost , port 8080
c. Select Use the proxy server for all protocols
Press ok and come fo main window.
11. From JMeter, HTTP Proxy server, Start the server
11. From browser , Execute the steps that we have planned to do.
- Hit URL www.google.com
- Enter text for search
- Click search button
12. Stop HTTP Proxy server in jmeter
13. Now, Expand Recording Controller and we can see the recorded steps.

Note:
-If we see View Results Tree under HTTP proxy server, we will also see the steps executed and their results
 
-For HTTPS web application, the security certificate should be trusted, and added to the browser..
 
14. Now, Add necessary listener under Thread Group(I have added View Results Tree/View Results in Table)
 
15. Run the test from Run Menu

We have successfully completed recording steps and running that for load testing.
Some time while recording , there may be unnecessary requests gone inside proxy. We need to see and refactor(if needed) the recorded steps.

Tips :
1. You may directly config proxy server to record under Recording Controller .
2. For ajax & JS based page, Add HTTP Cache Manager,HTTP Cookie Manager under the Recording Controller.[It works perforect for ajax requests)

Thanks...:)

How ro run JMeter with a proxy?

In this article, we will see how to run JMeter for testing a web application under proxy environment. This article is for novice who are learning jmeter.

If we need to run JMeter with a web proxy (in the network) , we need to run the jmeter.bat/jmeter file from a command line with the following parameters

jmeter -H -P -u -a -N  

In here
-H [proxy server hostname or ip address]
-P [proxy server port]
-N [nonproxy hosts] (e.g. *.apache.org|localhost)
-u [username for proxy authentication - if required]
-a [password for proxy authentication - if required] 

And those <>, need values. 

Thanks...:)

How run JMeter in different modes?

In this article we are going to learn how to run JMeter in different mode or ways. This is introductory article for novice users.

After downloading JMeter , in the bin directory if we run

jmeter.bat [Run JMeter with GUI]
jmeter-n.cmd [run a non-GUI test dropping a JMX file]
jmeter-n-r.cmd [run a non-GUI test remotely dropping a JMX file]
jmeter-t.cmd  [drop a JMX file on this to load it with GUI]
jmeter-server.bat [start JMeter in server mode]
mirror-server.cmd [runs the JMeter Mirror Server in non-GUI mode]
shutdown.cmd [Stops a non-GUI instance gracefully]
stoptest.cmd - [Stop a non-GUI instance abruptly]

Note: the special name LAST can be used with jmeter-n.cmd, jmeter-t.cmd and jmeter-n-r.cmd and means the last test plan that was run interactively.

We can override JVM settings using JVM_ARGS in the jmeter.bat script.
For example:
set JVM_ARGS="-Xms1024m -Xmx1024m -Dpropname=propvalue"
jmeter -t test.jmx ... 
 
To edit the jmeter shell script using JVM_ARGS(if JVM options are not supported by current JVM) For example:
JVM_ARGS="-Xms1024m -Xmx1024m" jmeter -t test.jmx [etc.]

This two i have not used yet, but I am configuring JMeter for my current work, so when ever I have finished, I will add an example with changed environment variable(JVM_ARGS)

There is another way to run jmeter in expert mode . If we edit the following line as true and enable it in jmeter.properties file. It will work.
-To Turn expert mode on/off [It will show expert-mode beans and properties]
jmeter.expertMode=true

Thanks...:)

2013-01-10

Configuring JMeter Part 1-How to configure plugins?

In this article we are going to see how can we change property of JMeter along with its plugins. For basic idea about JMeter and installing plugins, see my this post.

Jmeter has a very big number of properties. I will try to include one by one incrementally.

 In the jmeter installed bin directory(in my case C:\apache-jmeter-2.8\bin), we get a file named jmeter.properties. Open this with note pad. We can find various properties which are activated and some are not yet activated.

---------Section for jmeter.properties--------
- To enable/disabled correct graphs display which deal with threads after reloading the JTL file.
jmeter.save.saveservice.thread_counts=true
[By Default it is deactivate and false]

--------- jmeter.properties--------

We can configure some of the default behaviors of the plugin by adding the following lines(only the property part, not description) at the end user.properties file(it is in C:\apache-jmeter-2.8\bin in my PC) :
----Section for user.properties-----
- To Enable or disable the gradient paint for graphs. Default is true.
jmeterPlugin.drawGradient=true

-To Disable final zeroing lines in all graphs Globally. Default is false.
jmeterPlugin.neverDrawFinalZeroingLines=true

-To Disable current X lines drawing in all concerned graphs Globally. Default is false.
jmeterPlugin.neverDrawCurrentX=true

-To Enable or disable graphs Y Axis scaling for better readability. Default is true.
jmeterPlugin.optimizeYAxis=true

-To Use relative time in time based graphs. Default is true.
jmeterPlugin.useRelativeTime=true

-To make Prefix or not the Plugin items in JMeter menus. Default is true.
jmeterPlugin.prefixPlugins=true

-To Force line width for all line graphs. Default is '1.0'.
jmeterPlugin.graphLineWidth=3

-To Draw markers in relevent line graphs. Default is true.
meterPlugin.drawLineMarker=false

== CSV format Change ==
-To Force CSV separator character. Default is ',' if decimal separator is '.', ';' otherwise
#jmeterPlugin.csvSeparator=;
Note : This is deactivated. I decided to use
jmeterPlugin.csvSeparator=','

-To Force CSV time format (see link for more formats.)
jmeterPlugin.csvTimeFormat=HH:mm:ss
 Note : This is deactivated. I decided to use
jmeterPlugin.csvTimeFormat=yyMMddHHmmssZ
== CSV Format ==

-To use a custom path for lib/ext (not for utility jars)
search_paths=/app1/lib;/app2/lib

==Logging Section==
-To Log for Debugging
log_level.jorphan.reflect=DEBUG

-To Enable Proxy request debug log (it is disabled by default)
log_level.jmeter.protocol.http.proxy.HttpRequestHdr=DEBUG
==Logging==

---- user.properties---

  Configuring part is long post. You can see my other posts for more configurations.

...Thanks..:)