Wednesday, 11 March 2015

Published Wednesday, March 11, 2015 by with 1 comment

Apache Jmeter: Introduction and Tutorial -1

Apache JMeter


  • JMeter is an "Apache" project that can be used as a load testing tool for analyzing and measuring the performance of a variety of services, with a focus on web applications.
  • Stefano Mazzocchi of the Apache Software Foundation was the original developer of JMeter

  • JMeter Features

Following are some of the features of JMeter:
  1. Its free and open source software.
  2. It has simple GUI with desktop application
  3. JMeter can load and performance test many different server types: Web - HTTP, HTTPS, SOAP, Database via JDBC, LDAP, JMS, Mail - POP3
  4. It is platform-independent tool. On Linux/Unix, JMeter can be invoked by clicking on JMeter shell script. On Windows it can be invoked by starting the jmeter.bat file.
  5. JMeter store its test plans in XML format. This means you can generate a test plan using a text editor.
  6. It's full multi-threading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.


  • How JMeter Works ?





- JMeter simulates a group of users sending requests to a target server, and return statistics that show the performance/functionality of the target server / application via tables, graphs etc. 

It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types.



Environment Set-Up : 




JMeter is a framework for Java, so the very first requirement is to have JDK installed in your machine.

Verify the presence of Java in the machine using below commands.




Else, Download Java development Kit from http://www.oracle.com/technetwork/java/javase/downloads/index.html


Once JDK was set, go for downloading the JMeter latest version from http://jmeter.apache.org/download_jmeter.cgi.


Run JMeter : 

After downloading JMeter, go to the bin directory and Run JMeter.

Depending on OS select respective file





On clicking on above mentioned shortcut from the bin directory, JMeter GUI should appear which seems as below...





Script recording using JMeter.

Follow below steps to setup JMeter for recording.
Step:1

Test plan :
Right click (ADD -> Threads(Users) -> Thread Group) and add thread group.

Thread Group : Right Click (ADD -> Sampler -> HTTP Request) and add HTTP request.

Work Bench : Right Click (ADD -> Non-Test elements -> HTTP Proxy server.)
By adding all the above steps, your Application interface will looks like 



Step:2
Now set the proxy to your browser,( Prefer Firefox as its an independent browser.)
Firefox -> Tools -> Options -> Advanced Settings
Here Change to manual proxy Configuration and Configure respective PC ip here.


Step:3
After setting the proxy, if you try to send any request from the browser it should show the proxy screen.


Step:4

Now go to your app, select Thread Group :
Thread Group elements are the beginning points of your test plan. As the name suggests, the thread group elements control the number of threads JMeter will use during the test. We can also control the following via the Thread Group:
  • By setting the number of Threads.
  • By setting the Ramp Up Time
  • By setting the number of test iterations.



Step:5

Http Request Defaults : 



Step:6

Http Proxy server is a major part in recording, In that assign the port number, select target controller and then click on start button to start recording.


Once we start the proxy server, Just reload the proxy browser page by entering the URL which u wanted to record the script.
As an Example, I will enter https://www.google.com, as we set the target controller as Test plan> Thread group (Refer above image), all the scripts will be recorded under thread group (Refer below image for sample recording)


if the page got loaded completely, can go for Stop button.

Now we can say that we are done with recording part, and we can go for analyzing part..

View Result Tree : 

Once all the requests that sent to server for loading a page (which we recorded as shown in above steps), we can check for the server response from 'View result tree'

Thread Group, Right click and add View result tree from the Listener

then select "Run"/ Ctrl+R to check the response data.



HAPPY TESTING :)





Read More
      edit

Saturday, 7 March 2015

Published Saturday, March 07, 2015 by with 3 comments

JMeter: Distributed testing(Master Slave configuration)




Distributed testing



To generate load from different locations or to generate more load than you could from a single computer.

Actually there is limitation of a single normal configuration machine to generate large user load test. So we use distributed load testing to use multiple machines for generating the load wherein you rightly said we used master slave configuration






Pre-Conditions : 
-- All the master and slave PC's should be connected to the same net.
-- Need to have same version of JMeter in master(system running JMeter GUI, control each slave) and slaves(system running JMeter-server, receive command from the master and send a request to server under test)

Step:1 Slave PC configuration - 
 Select bin directory from JMeter folder, select jmeter-server.bat(Windows Batch File) file to open





Step:2 Master PC configuration - 
  Select jmeter.properties (Properties file), Open with any editor(Say- notepad) and add all the slave machine ip's under # Remote Hosts - comma delimited


Now open the GUI of JMeter from bin > jmeter.bat file.

from the GUI, record the script of the JMeter which you needed. as of now am recording the google.com page and search with term 'Software Testing'

For recording the script, Please refer my previous tutorial http://bharati-
anuchuri.blogspot.in/2015/03/apache-jmeter-introduction-and-tutorial.html


Once the script got recorded, Run the result by remote starting the slave ip's.




Thus your actual load(No.of users) will be divided in between master and slave pc's.




HAPPY TESTING :)



Read More
      edit

Tuesday, 3 March 2015

Published Tuesday, March 03, 2015 by with 0 comment

Jmeter: Parameterization using 'CSV Data Set Config'

Parameterization using 'CSV Data Set Config'

Parameterization: It's a Technique for generalizing an same action at same time with many users.

Example 1 : Simple Search using different Keywords.
Say : Testing, Development and Design.

Step:1
Input keyword as "Testing" and Search in google (https://www.google.comgle). and record the respective script 

The recorded screen will be as follows.



Step:2

Open a notepad and enter the keywords as Testing, Development and design 


Save the page as 'search.csv' in the same place where the recorded script (.jmx) file being kept.

Step:3

From the recorded script, select the 'search' request > from 'send parameters with the request' > 
Change the parameter of 'q' - Testing to ${P}



Step:4

After replacing the parameter,  add 'CSV Data Set Config' by right clicking on the 'Search' element > Add > Config Element > CSV data set config.

Add, file name as search.csv (which we added on notepad and saved),Variable name as P and select the values as 'True' for Stop thread on EOF,  Apart from these don't make any other changes.



Step:5

Click on Thread Group and change Number of Threads as 3 and Ramp-Up Period as 3. I am suggesting to make it 3 because we are going to search 3 key words. Or you can say we are going to user 3 users to search each keywords.


Save the recorded script by pressing ctrl+s. Now we can say that, we are done with scripting part and now if needed  add some listeners and check the result or server response.

Am going  to add, View result tree to check the result.

 Step:6 

Right click on  the thread group > Add > Listener > View result tree.
Run the script (ctrl+R), response should be as follows.




Happy Testing :)

Read More
      edit