SlideShare uma empresa Scribd logo
1 de 15
JMeter Interview Questions and Answers
  Performance testing is an important process of any software development. Even though
  these are not common interview questions for Java developers, you can bring it up
  yourself to many open-ended questions. Setting up a performance/load test script is
  always the first step in fixing non-functional and hard to reproduce issues relating to
  memory leaks, database deadlocks, thread-safety, CPU usage, excessive disk I/O, etc.

  Q. How did you go about fixing a performance issue?
  A. Set up JMeter to reproduce the production like scenario to put through concurrent
  requests and put the system under heavy load. Used a profiling tool to monitor CPU times,
  memory usage, etc.



  Q. What are some of your recent accomplishments?
  A. Reduced the response time from 4 seconds to 2 seconds. Set up JMeter to put the
  system under peak load. Used a profiling tool to monitor CPU times, memory usage, etc.
  Identified the bottle neck, and improved the situation by fixing the offending database
  connection leak, back tracking regular expression, and a badly constructed SQL query with
  Cartesian joins.

  Q. How would you go about writing a JMeter based performance test case for the following
  scenario?
• XML/HTTP based RESTful Web Service calls are made against an order execution system.
  The system should be able to handle a basic load of 30 orders per 3 min. There will be 30
  concurrent users. This means 600 orders per minute.

• The test case should simulate at least 2 different account ids.

• 30 orders per 3 min x 60 minutes = 600 orders per hour.


  A. The JMeter version 2.4 is used for the following screenshots. The number of artefacts
  shown for this are as shown below.



  STEP 1: Relevant files.




• OrderExecution.jmx is the JMeter script.
• 1-OrderRequest.xml and 2-OrderRequest.xml are the two sample XML payloads that
  will be sent via an HTTP POST (RESTful Web service).
• TestData.csv is a data file used for retrieving values 1 & 2 to switch between 1-
  OrderRequest.xml and 2-OrderRequest.xml to simulate 2 different accounts.


  1-OrederRequest.xml


  <?xml version="1.0" encoding="UTF-8"?>
  <OrderRequest>
      <accountId>12345</accountId>
      <quantity>150</quantity>
      <unitPrice>12.50</unitPrice>
  </OrderRequest>




  2-OrederRequest.xml
  <?xml version="1.0" encoding="UTF-8"?>
  <OrderRequest>
      <accountId>6789</accountId>
      <quantity>200</quantity>
      <unitPrice>6.50</unitPrice>
  </OrderRequest>




  TestData.csv
  1
  2




  STEP 2: JMeter scripts

  If you open the OrderExecution.jmx script file, you will see something like this.
Lets' go through each of the elements. Thread Groups are equivalent of virtual users in
other performance testing system. You can add this element by right clicking on the test
plan and then selecting Add --> Threads (Users) --> Thread Group. As per the
requirements, the system should handle 30 concurrent users. The ramp up time is 180
seconds, which is 3 minutes. All 30 threads will get started in 3 minutes. The loop count is
set to 20, to produce 600 orders (i.e. 30 threads * 20 loops) .




It is a good practice to define some variables as shown below, so that these variables can
be used in downstream elements without having to hard code. If you want to run against
a different host, you can just change it in spot as opposed to having to change it in a
number of places. You can add this by right clicking on "Order Processing" and then
selecting Add --> Config Element --> User Defined Variables.
The CSV Data Config is a very useful element to read test data from CSV file and then
save the read values into some variable. In this example, the values 1 and 2 are read
from the file TestData.csv, and stored in a variable named "account". The one iteration will
set account to 1, and the next iteration will set it to 2, and then the same assigment
repeats since "recycle on EOF" is set to true.




The HTTP Header manager sets the HTTP headers. In this example, the content type is
set to application/xml because we are posting the XML files 1-OrderRequest.xml & 2-
OrderRequest.xml .
The HTTP request defaults sets the default values so that you don't have to repeat it in
each request. Also, note that the user defined variables in the first step are used within $
{} as opposed to literal values.




The loop controller can be added to loop through the samplers a number of times. In
this example, it is set to 1.




The samplers can be added by right clicking on the "Create Order" loop controller and
then selecting Add --> Sampler --> HTTP Request. It shows the path, method, and the file
to send. The actual RESTFul web service call will have the URL



http://localhost:8080/myapp/executionservices/execution/1.0/order/create
Also, note that in the File Path the ${DATA_PATH} is a user defined value, and ${account}
is a variable that is assigned from the TestData.csv file via the CSV Data Config element.
The account will be dynamically changed between 1 and 2 to retrieve the files 1-
OrderRequest.xml and 2-OrderRequest.xml respectively for each iteration.




JMeter supports a number of samplers like SOAP request, FTP request, JDBC request, JMS
publisher, JMS subscriber, etc to name a few.

The XPath assertions are used to assert the response for presence of
responseCode="SUCCESS" and a valid orderId > 0. The response message will look like


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OrderResponse>
   <orderId>50045671</orderId>
   <responseCode>SUCCESS</responseCode>
</OrderResponse>
The other three elements are reporting elements. There are many reporting elements to
choose from depending on the requirements. You can add reporting elements via Add
--> Listener.




Finally the Gaussian Timer that will delay the execution by 3 minutes (i.e. 180000 ms)
with a standard deviation of 10 seconds. This will ensure the throuput of 30 orders per 3
minutes.
Q. How would you go about automatically recording the your browser actions into JMeter?
  A. This can be achieved 2 ways.
• Use BadBoy, which is a tool to record your Web interactions.The recorded script can be
  exported as a JMeter file with the extension .jmx to be imported into JMeter. The
  generated script will not be pretty, but it can be cleaned up and further extended within
  JMeter with user defined variables, CSV data config, HTTP defaults, etc. You can record
  the script as you use your application.
• Use JMeter as an HTTP proxy server to record your browser actions.Firstly, set up your
  JMeter to act as a proxy server on an available port like say 9090 as shown below.




  Configure the proxy server as shown below:
• Port: 9090
• Target Controller indicates where to record. In the above diagram indicates to capture it
  in the WorkBench under the proxy server itself. This allows you to later on move the
  captured elements one by one into the TestPlan.
• You don't want to capture everything. So, filter it with include and exclude patterns. For
  example, Include: .*myapp.*, Exclude: .*.jpg.
• "Start" the proxy server.


  You need to set up your browser to use this proxy server.
Finally, start using the browser to record your actions. For example, you could use the
following URL

http://myhost:7001/myapp/home

Note: If you use localhost instead of myapp as the host, JMeter may not record your
actions. To overcome this, type ipconfig on your DOS prompt and copy the local IP
address and use that instead of localhost in your URL.



Q. What are Pre-Processor and Post-Processor elements? In what order does JMeter
process various type of elements?
A. A Pre-Processor executes some action prior to a Sampler Request being made. If a
Pre-Processor is attached to a Sampler element, then it will execute just prior to that
sampler element running. A Pre-Processor is most often used to modify the settings of a
Sample Request just before it runs, or to update variables that aren't extracted from
response text.



A Post-Processor executes some action after a Sampler Request has been made. If a
Post-Processor is attached to a Sampler element, then it will execute just after that
sampler element runs. A Post-Processor is most often used to process the response data,
often to extract values from it.

A Regular Expression Extractor can be used as a Post-Processor element to extract
values to be used elsewhere in subsequent requests. For example, if you are using JSF
and Seam frameworks, the jsfViewState and CID values can be extracted as shown
below:
The elements are executed in the following order as per the JMeter documentation.

  0.   Configuration elements
  1.   Pre-Processors
  2.   Timers
  3.   Sampler
  4.   Post-Processors (unless SampleResult is null)
  5.   Assertions (unless SampleResult is null)
  6.   Listeners (unless SampleResult is null)

  Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to
  which they apply. Logic Controllers and Samplers are processed in the order in which they
  appear in the tree. Other test elements are processed according to the scope in which
  they are found, and the type of test element.

  Q. What are some of the challenges you faced with JMeter?
  A.
• If a subsequent request rely on the cookie set by the previous request, the "cookie
  manager" element is required.
• When setting up the "CSV Data Set Config", don't have any spaces in the variable names.




  Q. Have you used any features of JMeter that gave you greater flexibility?
  A. Yes. The JMeter supports BeanShell scripting for greater flexibility. The BeanShell is a
  small, free, embeddable Java source interpreter with object scripting language features,
  written in Java.

  If you want to output all the order ids extracted out of the response messages for the
  response messages shown below
  <OrderResponse>
  <orderId>50013914</orderId>
  <responseCode>SUCCESS</responseCode>
  </OrderResponse>




  An XPath Extractor can be used to extract the "orderId" from the response message and
  store it in a variable named "orderId" as shown below.




  Now, the BeanShell PostProcessor can use the extracted "orderId" variable and write to
  a file (e.g. C:Temporder-processingid.txt ) as shown below.
You could do a lot more powerful things by writing your own embedded scripting with the
BeanShell. For example, You can create your own file named MyBeanShell.bshr and copy it
to $JMETER_HOMEbin folder. The MyBeanShell.bshr will have functions like
getReportStartDate()
{

 import java.text.SimpleDateFormat;

 cal = Calendar.getInstance();
 cal.add(Calendar.DATE, -10);
 sdf = new SimpleDateFormat("dd-MMMM-yyyy");
 return sdf.format(cal.getTime());

}

isTenth(int loopCounter)
{

 returnValue = false;

 if (loopCounter % 10 == 0)
 {
 returnValue = true;
 }

 return returnValue;

}
You could invoke these functions from your JMeter elements like



  ${__BeanShell(return getReportStartDate();)}




  Also, note that pre-defined functions like __time can be used as shown above. There are
  also handy JMeter plugins from Google code at http://code.google.com/p/jmeter-
  plugins/ containing useful functions, listeners, samplers, etc. Just download the zip file
  and extract the "JMeterPlugins.jar" into $JMETER_HOMElibext folder. This plugin features
  are prefixed with jp@gc.

  Finally, instead of BeanShell or simple functions out of the box like __time, you could also
  write your own Java based custom functions using
  the org.apache.jmeter.functions.Function interface by writing your function as
  described here http://gabenell.blogspot.com/2010/01/custom-functions-for-jmeter.html.

  Q. How do you ensure re-usability in your JMeter scripts?
  A.
• Using config elements like "CSV Data Set Config", "User Defined Variables", etc for
  greater data reuse.
• Modularizing shared tasks and invoking them via a "Module Controller".
• Writing your own BeanShell functions, and reusing them.

Mais conteúdo relacionado

Mais procurados

JMeter - Performance testing your webapp
JMeter - Performance testing your webappJMeter - Performance testing your webapp
JMeter - Performance testing your webappAmit Solanki
 
Perofrmance testing and apache jmeter
Perofrmance testing and apache jmeterPerofrmance testing and apache jmeter
Perofrmance testing and apache jmeterlethibichhoa
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van NghieXo Platform
 
How we can measure server performance using jmeter?
How we can measure server performance using jmeter?How we can measure server performance using jmeter?
How we can measure server performance using jmeter?BugRaptors
 
Performance testing with JMeter
Performance testing with JMeterPerformance testing with JMeter
Performance testing with JMeterMikael Kundert
 
Performance Testing from Scratch + JMeter intro
Performance Testing from Scratch + JMeter introPerformance Testing from Scratch + JMeter intro
Performance Testing from Scratch + JMeter introMykola Kovsh
 
Performance Testing With Jmeter
Performance Testing With JmeterPerformance Testing With Jmeter
Performance Testing With JmeterAdam Goucher
 
Using JMeter for Performance Testing Live Streaming Applications
Using JMeter for Performance Testing Live Streaming ApplicationsUsing JMeter for Performance Testing Live Streaming Applications
Using JMeter for Performance Testing Live Streaming ApplicationsBlazeMeter
 
Load Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSLoad Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSVladimir Ilic
 
Basic of jMeter
Basic of jMeter Basic of jMeter
Basic of jMeter Shub
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeterBhojan Rajan
 
Introduction to JMeter
Introduction to JMeterIntroduction to JMeter
Introduction to JMeterGalih Lasahido
 
JMeter Post-Processors
JMeter Post-ProcessorsJMeter Post-Processors
JMeter Post-ProcessorsLoadium
 
Perfromane Test Tool jmeter
Perfromane Test Tool jmeterPerfromane Test Tool jmeter
Perfromane Test Tool jmeterNaga Mallala
 
Automation - Apache JMeter
Automation - Apache JMeterAutomation - Apache JMeter
Automation - Apache JMeterWira Santos
 
Introduction to jmeter
Introduction to jmeterIntroduction to jmeter
Introduction to jmetertest test
 
Performance Testing using Jmeter and Capacity Testing
Performance Testing using Jmeter and Capacity TestingPerformance Testing using Jmeter and Capacity Testing
Performance Testing using Jmeter and Capacity TestingAkshay Patole
 

Mais procurados (20)

JMeter - Performance testing your webapp
JMeter - Performance testing your webappJMeter - Performance testing your webapp
JMeter - Performance testing your webapp
 
Perofrmance testing and apache jmeter
Perofrmance testing and apache jmeterPerofrmance testing and apache jmeter
Perofrmance testing and apache jmeter
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van Nghi
 
How we can measure server performance using jmeter?
How we can measure server performance using jmeter?How we can measure server performance using jmeter?
How we can measure server performance using jmeter?
 
Performance testing with JMeter
Performance testing with JMeterPerformance testing with JMeter
Performance testing with JMeter
 
Performance Testing from Scratch + JMeter intro
Performance Testing from Scratch + JMeter introPerformance Testing from Scratch + JMeter intro
Performance Testing from Scratch + JMeter intro
 
Load testing jmeter
Load testing jmeterLoad testing jmeter
Load testing jmeter
 
Performance Testing With Jmeter
Performance Testing With JmeterPerformance Testing With Jmeter
Performance Testing With Jmeter
 
J Meter Intro
J Meter IntroJ Meter Intro
J Meter Intro
 
Using JMeter for Performance Testing Live Streaming Applications
Using JMeter for Performance Testing Live Streaming ApplicationsUsing JMeter for Performance Testing Live Streaming Applications
Using JMeter for Performance Testing Live Streaming Applications
 
Load Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWSLoad Test Drupal Site Using JMeter and Amazon AWS
Load Test Drupal Site Using JMeter and Amazon AWS
 
Basic of jMeter
Basic of jMeter Basic of jMeter
Basic of jMeter
 
Performance testing jmeter
Performance testing jmeterPerformance testing jmeter
Performance testing jmeter
 
Introduction to JMeter
Introduction to JMeterIntroduction to JMeter
Introduction to JMeter
 
JMeter Post-Processors
JMeter Post-ProcessorsJMeter Post-Processors
JMeter Post-Processors
 
Perfromane Test Tool jmeter
Perfromane Test Tool jmeterPerfromane Test Tool jmeter
Perfromane Test Tool jmeter
 
Automation - Apache JMeter
Automation - Apache JMeterAutomation - Apache JMeter
Automation - Apache JMeter
 
JMeter Database Performace Testing - Keytorc Approach
JMeter Database Performace Testing - Keytorc ApproachJMeter Database Performace Testing - Keytorc Approach
JMeter Database Performace Testing - Keytorc Approach
 
Introduction to jmeter
Introduction to jmeterIntroduction to jmeter
Introduction to jmeter
 
Performance Testing using Jmeter and Capacity Testing
Performance Testing using Jmeter and Capacity TestingPerformance Testing using Jmeter and Capacity Testing
Performance Testing using Jmeter and Capacity Testing
 

Semelhante a Jmeter interviewquestions

Performancetestingjmeter 131210111657-phpapp02
Performancetestingjmeter 131210111657-phpapp02Performancetestingjmeter 131210111657-phpapp02
Performancetestingjmeter 131210111657-phpapp02Nitish Bhardwaj
 
Software testing
Software testingSoftware testing
Software testingnil65
 
Performance testing using Jmeter for apps which needs authentication
Performance testing using Jmeter for apps which needs authenticationPerformance testing using Jmeter for apps which needs authentication
Performance testing using Jmeter for apps which needs authenticationJay Jha
 
EAI Performance Analysis Web-Methods | Torry Harris Whitepaper
EAI Performance Analysis Web-Methods | Torry Harris WhitepaperEAI Performance Analysis Web-Methods | Torry Harris Whitepaper
EAI Performance Analysis Web-Methods | Torry Harris WhitepaperTorry Harris Business Solutions
 
Apachejmeterabriefintroduction
ApachejmeterabriefintroductionApachejmeterabriefintroduction
ApachejmeterabriefintroductionForedoomed
 
Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Shivakumara .
 
performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02Gopi Raghavendra
 
performancetestingjmeter-121109061704-phpapp02 (1)
performancetestingjmeter-121109061704-phpapp02 (1)performancetestingjmeter-121109061704-phpapp02 (1)
performancetestingjmeter-121109061704-phpapp02 (1)QA Programmer
 
J meter introduction
J meter introductionJ meter introduction
J meter introductionBharath Kumar
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meterPurna Chandar
 
Day1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewDay1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewSravanthi N
 
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip Bannon
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip BannonSoft Test Ireland - Introduction to Jakarta Jmeter - Philip Bannon
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip BannonDavid O'Dowd
 
"Introduction to JMeter" @ CPTM 3rd Session
"Introduction to JMeter" @ CPTM 3rd Session"Introduction to JMeter" @ CPTM 3rd Session
"Introduction to JMeter" @ CPTM 3rd SessionTharinda Liyanage
 
Tuning Robot Quick Tour
Tuning Robot Quick TourTuning Robot Quick Tour
Tuning Robot Quick TourActive Base
 
Performance eng prakash.sahu
Performance eng prakash.sahuPerformance eng prakash.sahu
Performance eng prakash.sahuDr. Prakash Sahu
 
ETM Server Program v1.0
ETM Server Program v1.0ETM Server Program v1.0
ETM Server Program v1.0Adam Dale
 

Semelhante a Jmeter interviewquestions (20)

Performancetestingjmeter 131210111657-phpapp02
Performancetestingjmeter 131210111657-phpapp02Performancetestingjmeter 131210111657-phpapp02
Performancetestingjmeter 131210111657-phpapp02
 
Software testing
Software testingSoftware testing
Software testing
 
Performance testing using Jmeter for apps which needs authentication
Performance testing using Jmeter for apps which needs authenticationPerformance testing using Jmeter for apps which needs authentication
Performance testing using Jmeter for apps which needs authentication
 
EAI Performance Analysis Web-Methods | Torry Harris Whitepaper
EAI Performance Analysis Web-Methods | Torry Harris WhitepaperEAI Performance Analysis Web-Methods | Torry Harris Whitepaper
EAI Performance Analysis Web-Methods | Torry Harris Whitepaper
 
Apachejmeterabriefintroduction
ApachejmeterabriefintroductionApachejmeterabriefintroduction
Apachejmeterabriefintroduction
 
Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02Performancetestingjmeter 121109061704-phpapp02
Performancetestingjmeter 121109061704-phpapp02
 
performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02performancetestingjmeter-121109061704-phpapp02
performancetestingjmeter-121109061704-phpapp02
 
performancetestingjmeter-121109061704-phpapp02 (1)
performancetestingjmeter-121109061704-phpapp02 (1)performancetestingjmeter-121109061704-phpapp02 (1)
performancetestingjmeter-121109061704-phpapp02 (1)
 
J meter introduction
J meter introductionJ meter introduction
J meter introduction
 
J meter
J meterJ meter
J meter
 
QSpiders - Installation and Brief Dose of Load Runner
QSpiders - Installation and Brief Dose of Load RunnerQSpiders - Installation and Brief Dose of Load Runner
QSpiders - Installation and Brief Dose of Load Runner
 
Performance testing and j meter
Performance testing and j meterPerformance testing and j meter
Performance testing and j meter
 
Day1_Apache_JMeter_Overview
Day1_Apache_JMeter_OverviewDay1_Apache_JMeter_Overview
Day1_Apache_JMeter_Overview
 
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip Bannon
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip BannonSoft Test Ireland - Introduction to Jakarta Jmeter - Philip Bannon
Soft Test Ireland - Introduction to Jakarta Jmeter - Philip Bannon
 
"Introduction to JMeter" @ CPTM 3rd Session
"Introduction to JMeter" @ CPTM 3rd Session"Introduction to JMeter" @ CPTM 3rd Session
"Introduction to JMeter" @ CPTM 3rd Session
 
Jmeter1
Jmeter1Jmeter1
Jmeter1
 
Tuning Robot Quick Tour
Tuning Robot Quick TourTuning Robot Quick Tour
Tuning Robot Quick Tour
 
JMeter Intro
JMeter IntroJMeter Intro
JMeter Intro
 
Performance eng prakash.sahu
Performance eng prakash.sahuPerformance eng prakash.sahu
Performance eng prakash.sahu
 
ETM Server Program v1.0
ETM Server Program v1.0ETM Server Program v1.0
ETM Server Program v1.0
 

Último

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 

Último (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

Jmeter interviewquestions

  • 1. JMeter Interview Questions and Answers Performance testing is an important process of any software development. Even though these are not common interview questions for Java developers, you can bring it up yourself to many open-ended questions. Setting up a performance/load test script is always the first step in fixing non-functional and hard to reproduce issues relating to memory leaks, database deadlocks, thread-safety, CPU usage, excessive disk I/O, etc. Q. How did you go about fixing a performance issue? A. Set up JMeter to reproduce the production like scenario to put through concurrent requests and put the system under heavy load. Used a profiling tool to monitor CPU times, memory usage, etc. Q. What are some of your recent accomplishments? A. Reduced the response time from 4 seconds to 2 seconds. Set up JMeter to put the system under peak load. Used a profiling tool to monitor CPU times, memory usage, etc. Identified the bottle neck, and improved the situation by fixing the offending database connection leak, back tracking regular expression, and a badly constructed SQL query with Cartesian joins. Q. How would you go about writing a JMeter based performance test case for the following scenario? • XML/HTTP based RESTful Web Service calls are made against an order execution system. The system should be able to handle a basic load of 30 orders per 3 min. There will be 30 concurrent users. This means 600 orders per minute. • The test case should simulate at least 2 different account ids. • 30 orders per 3 min x 60 minutes = 600 orders per hour. A. The JMeter version 2.4 is used for the following screenshots. The number of artefacts shown for this are as shown below. STEP 1: Relevant files. • OrderExecution.jmx is the JMeter script.
  • 2. • 1-OrderRequest.xml and 2-OrderRequest.xml are the two sample XML payloads that will be sent via an HTTP POST (RESTful Web service). • TestData.csv is a data file used for retrieving values 1 & 2 to switch between 1- OrderRequest.xml and 2-OrderRequest.xml to simulate 2 different accounts. 1-OrederRequest.xml <?xml version="1.0" encoding="UTF-8"?> <OrderRequest> <accountId>12345</accountId> <quantity>150</quantity> <unitPrice>12.50</unitPrice> </OrderRequest> 2-OrederRequest.xml <?xml version="1.0" encoding="UTF-8"?> <OrderRequest> <accountId>6789</accountId> <quantity>200</quantity> <unitPrice>6.50</unitPrice> </OrderRequest> TestData.csv 1 2 STEP 2: JMeter scripts If you open the OrderExecution.jmx script file, you will see something like this.
  • 3. Lets' go through each of the elements. Thread Groups are equivalent of virtual users in other performance testing system. You can add this element by right clicking on the test plan and then selecting Add --> Threads (Users) --> Thread Group. As per the requirements, the system should handle 30 concurrent users. The ramp up time is 180 seconds, which is 3 minutes. All 30 threads will get started in 3 minutes. The loop count is set to 20, to produce 600 orders (i.e. 30 threads * 20 loops) . It is a good practice to define some variables as shown below, so that these variables can be used in downstream elements without having to hard code. If you want to run against a different host, you can just change it in spot as opposed to having to change it in a number of places. You can add this by right clicking on "Order Processing" and then selecting Add --> Config Element --> User Defined Variables.
  • 4. The CSV Data Config is a very useful element to read test data from CSV file and then save the read values into some variable. In this example, the values 1 and 2 are read from the file TestData.csv, and stored in a variable named "account". The one iteration will set account to 1, and the next iteration will set it to 2, and then the same assigment repeats since "recycle on EOF" is set to true. The HTTP Header manager sets the HTTP headers. In this example, the content type is set to application/xml because we are posting the XML files 1-OrderRequest.xml & 2- OrderRequest.xml .
  • 5. The HTTP request defaults sets the default values so that you don't have to repeat it in each request. Also, note that the user defined variables in the first step are used within $ {} as opposed to literal values. The loop controller can be added to loop through the samplers a number of times. In this example, it is set to 1. The samplers can be added by right clicking on the "Create Order" loop controller and then selecting Add --> Sampler --> HTTP Request. It shows the path, method, and the file to send. The actual RESTFul web service call will have the URL http://localhost:8080/myapp/executionservices/execution/1.0/order/create
  • 6. Also, note that in the File Path the ${DATA_PATH} is a user defined value, and ${account} is a variable that is assigned from the TestData.csv file via the CSV Data Config element. The account will be dynamically changed between 1 and 2 to retrieve the files 1- OrderRequest.xml and 2-OrderRequest.xml respectively for each iteration. JMeter supports a number of samplers like SOAP request, FTP request, JDBC request, JMS publisher, JMS subscriber, etc to name a few. The XPath assertions are used to assert the response for presence of responseCode="SUCCESS" and a valid orderId > 0. The response message will look like <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <OrderResponse> <orderId>50045671</orderId> <responseCode>SUCCESS</responseCode> </OrderResponse>
  • 7. The other three elements are reporting elements. There are many reporting elements to choose from depending on the requirements. You can add reporting elements via Add --> Listener. Finally the Gaussian Timer that will delay the execution by 3 minutes (i.e. 180000 ms) with a standard deviation of 10 seconds. This will ensure the throuput of 30 orders per 3 minutes.
  • 8. Q. How would you go about automatically recording the your browser actions into JMeter? A. This can be achieved 2 ways. • Use BadBoy, which is a tool to record your Web interactions.The recorded script can be exported as a JMeter file with the extension .jmx to be imported into JMeter. The generated script will not be pretty, but it can be cleaned up and further extended within JMeter with user defined variables, CSV data config, HTTP defaults, etc. You can record the script as you use your application.
  • 9. • Use JMeter as an HTTP proxy server to record your browser actions.Firstly, set up your JMeter to act as a proxy server on an available port like say 9090 as shown below. Configure the proxy server as shown below:
  • 10. • Port: 9090 • Target Controller indicates where to record. In the above diagram indicates to capture it in the WorkBench under the proxy server itself. This allows you to later on move the captured elements one by one into the TestPlan. • You don't want to capture everything. So, filter it with include and exclude patterns. For example, Include: .*myapp.*, Exclude: .*.jpg. • "Start" the proxy server. You need to set up your browser to use this proxy server.
  • 11. Finally, start using the browser to record your actions. For example, you could use the following URL http://myhost:7001/myapp/home Note: If you use localhost instead of myapp as the host, JMeter may not record your actions. To overcome this, type ipconfig on your DOS prompt and copy the local IP address and use that instead of localhost in your URL. Q. What are Pre-Processor and Post-Processor elements? In what order does JMeter process various type of elements? A. A Pre-Processor executes some action prior to a Sampler Request being made. If a Pre-Processor is attached to a Sampler element, then it will execute just prior to that sampler element running. A Pre-Processor is most often used to modify the settings of a Sample Request just before it runs, or to update variables that aren't extracted from response text. A Post-Processor executes some action after a Sampler Request has been made. If a Post-Processor is attached to a Sampler element, then it will execute just after that sampler element runs. A Post-Processor is most often used to process the response data, often to extract values from it. A Regular Expression Extractor can be used as a Post-Processor element to extract values to be used elsewhere in subsequent requests. For example, if you are using JSF and Seam frameworks, the jsfViewState and CID values can be extracted as shown below:
  • 12. The elements are executed in the following order as per the JMeter documentation. 0. Configuration elements 1. Pre-Processors 2. Timers 3. Sampler 4. Post-Processors (unless SampleResult is null) 5. Assertions (unless SampleResult is null) 6. Listeners (unless SampleResult is null) Timers, Assertions, Pre- and Post-Processors are only processed if there is a sampler to which they apply. Logic Controllers and Samplers are processed in the order in which they appear in the tree. Other test elements are processed according to the scope in which they are found, and the type of test element. Q. What are some of the challenges you faced with JMeter? A. • If a subsequent request rely on the cookie set by the previous request, the "cookie manager" element is required.
  • 13. • When setting up the "CSV Data Set Config", don't have any spaces in the variable names. Q. Have you used any features of JMeter that gave you greater flexibility? A. Yes. The JMeter supports BeanShell scripting for greater flexibility. The BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. If you want to output all the order ids extracted out of the response messages for the response messages shown below <OrderResponse> <orderId>50013914</orderId> <responseCode>SUCCESS</responseCode> </OrderResponse> An XPath Extractor can be used to extract the "orderId" from the response message and store it in a variable named "orderId" as shown below. Now, the BeanShell PostProcessor can use the extracted "orderId" variable and write to a file (e.g. C:Temporder-processingid.txt ) as shown below.
  • 14. You could do a lot more powerful things by writing your own embedded scripting with the BeanShell. For example, You can create your own file named MyBeanShell.bshr and copy it to $JMETER_HOMEbin folder. The MyBeanShell.bshr will have functions like getReportStartDate() { import java.text.SimpleDateFormat; cal = Calendar.getInstance(); cal.add(Calendar.DATE, -10); sdf = new SimpleDateFormat("dd-MMMM-yyyy"); return sdf.format(cal.getTime()); } isTenth(int loopCounter) { returnValue = false; if (loopCounter % 10 == 0) { returnValue = true; } return returnValue; }
  • 15. You could invoke these functions from your JMeter elements like ${__BeanShell(return getReportStartDate();)} Also, note that pre-defined functions like __time can be used as shown above. There are also handy JMeter plugins from Google code at http://code.google.com/p/jmeter- plugins/ containing useful functions, listeners, samplers, etc. Just download the zip file and extract the "JMeterPlugins.jar" into $JMETER_HOMElibext folder. This plugin features are prefixed with jp@gc. Finally, instead of BeanShell or simple functions out of the box like __time, you could also write your own Java based custom functions using the org.apache.jmeter.functions.Function interface by writing your function as described here http://gabenell.blogspot.com/2010/01/custom-functions-for-jmeter.html. Q. How do you ensure re-usability in your JMeter scripts? A. • Using config elements like "CSV Data Set Config", "User Defined Variables", etc for greater data reuse. • Modularizing shared tasks and invoking them via a "Module Controller". • Writing your own BeanShell functions, and reusing them.