Thursday, December 13, 2012

Web Service : Perf Test

To show the how to performance test of any webservice which is taking some input and returning  output in response , i am using Yahoo Weather service for Demo purpose .

 http://weather.yahooapis.com/forecastrss?w=2442047&u=c

Input 1 W = 2442047 >>> Location Id 

Input 2 : u = c >> Celsius( Temp ) 

If User direct Request the  above url then it would return response like :

Yahoo! Weather - Los Angeles, CA
Yahoo! Weather for Los Angeles, CA
Conditions for Los Angeles, CA at 6:47 pm PSTFriday, December 14, 2012 8:17 AM

Current Conditions:

Fair, 12 C


Forecast:

Thu - Partly Cloudy. High: 16 Low: 8

Fri - Partly Cloudy. High: 14 Low: 9



Full Forecast at Yahoo! Weather


(provided by The Weather Channel)



To Automate the above requiremen follow the Step below :
  1. Add the Thread Group >>Add the Http Sampler   and add the Server name/ IP = weather.yahooapis.com  in Path  put the forecastrss?w=2442047&u=c   
  2. Now  w=2442047 and u =c  need to be parametrized  replace them with ${location}  and ${format} 
  

3.Add Csv data set config provide the File name of csv file and Variables location,format



 4.Add Test data in Csv File 




 5. To verify the Web service is working or not  Add the Assertion >>
      In this case you can add the Location name in text response Pattern an parametrize the  assertion text . I don't know thall location so i am  just adding the Response Code in Assertion





 

Correlation in Jmeter

To remove the dynamic value of Http request correlation is used .Jmeter Script can be correlated with help of Regular expression Extractor .

I have Recorded the login action of IRCTC Website   and  Correlated  the  Session_ID and Engine_ID

Refer the Screenshot below to view the Dynamic  Session_ID and Engine_ID

https://www.irctc.co.in/cgi-bin/bv60.dll/irctc/booking/planner.do?screen=fromlogin&
BV_SessionID=   @@@@1502947175.1355111858@@@@                        &
 {Left Boundary }        Dynamic Value                                               { Right Boundary}




Steps  of Correlation :

  1. Find the Dynamic Value in Http Request in this case  Session_ID and Engine_ID are Dynamic values
  2. Add Regular expression Extractor for Seesion_ID  e.g : BV_SessionID=(.*?)&     check  number of occurrences in  Regular expression  tester     
  3. Add Regular expression Extractor for BV_EngineID  e.g : BV_EngineID=(.+)">     check  number of occurrences in  Regular expression  tester 
   4. Provide the Template and Match No e.g for First match $1$ and
   5. Replace BV_SessionID and  BV_EngineID values with Variable ${S} and ${E}
Refer the screen Shot Below







Wednesday, December 12, 2012

Jmeter Parametrization



Parametrization is process of generalizing some user data so as to use it for multiple  users ,  Suppose i want to  the Log in  in the application with different set of data then i have to Parametrize the Username and Password .

Steps : Parametrization of Username and Password

1. Go to  the HTTP sampler where Username and Password are defined >> Change them with variable
  ${user}  and ${password} 



2. Add Config Element >> CSV data Set config

3.  In CSV data Set config  add the variable  name as defined above  e.g user,password
4. Provide CSV file Location  e.g . C:/Login.csv
5. Add Username and Password data in  csv file .




In Jmeter  you can Parametrized any variable , User Input field , Server name , Port  etc .