Monday, 9 March 2015

Jmeter Understanding

Continue

Thursday, 5 March 2015

JMeter interview Questions and Answers Part - 5

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.Below is the list of jmeter interview questions and answers.
What is Jmeter?
Jmeter is one of the Java tools which is used to perform load testing client/server applications. It is open source software Designed to load test functional behavior and measure performance of the application.It was originally designed for testing Web Applications but has since expanded to other test functions
What are the other applications tested by Jmeter? 
JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more)
What do you see when you open jmeter?
By defaultTest Plan & Workbench are seen

What is Test Plan in Jmeter?
Test plan describes a series of steps JMeter will execute when run.
A complete test plan will consist of one or more Thread Groups, logic conrollers, sample generating controllers, listeners, timers, assertions, and configuration elements.
What is Work bench?
The Workbench is simply an area to store test elements while you are in the process of constructing a test.
The Workbench is a sandbox for any test or portion of a test that you are working on.
When you are ready to test what you have designed in the Workbench, you can copy or move the elements into the Test Plan.
It also contains Non- Test Elements
Http mirror sever
Http Proxy server {which is not available in the thread group & Test plan }
What is Thread Group?
Thread group elements are the beginning points of any test plan.
  1. All controllers and samplers must be under a thread group.
  2. Listeners, may be placed directly under the test plan, in which case they will apply to all the thread groups.
  3. The controls for a thread group allow you to:
  • Set the number of threads
  • Set the ramp-up period
  • Set the number of times to execute the test
What are the parts of thread group?
  • Sampler :Sends various types of requests to the server
  • Listeners : Results of the Run can be viewed & saved
  • Timer : Makes th erun more realistic by inserting delays between the requests
  • Controller : responsible for controlling the flow of the thread group.If we have defined request to be executed on some logic like if-then-else or loop structure in java
  • Config Element : Info about the requests are added to work with samplers using this.
  • Assertion : To check if the responses are within given time and containing expected data.
What are Controllers and its types? 
JMeter has two types of Controllers
Samplers Controllers 
Logical Controllers
Samplers Controllers 
Samplers tell JMeter to send requests to a server.
For example, add an HTTP Request Sampler if you want JMeter to send an HTTP request. You can also customize a request by adding one or more Configuration Elements to a Sampler.
Logical Controllers 
Logical Controllers let you customize the logic that JMeter uses to decide when to send requests.
Logic Controllers can change the order of requests coming from their child elements.
For example, you can add an Interleave Logic Controller to alternate between two HTTP Request Samplers.

What is Configuration element?
A configuration element works closely with a Sampler
Configuration elements can be used to set up defaults and variables for later use by samplers.
Note that these elements are processed at the start of the scope in which they are found, i.e. before any samplers in the same scope.
Its elements:
CSV Data Set Config: Used to read lines from a file, and split them into variables.
HTTP Authorization Manager : You can specify one or more user logins for web pages that are restricted using server authentication
Java Request Defaults: You can set default values for Java testing
HTTP Cookie Manager: The Cookie Manager element has two functions:
  1. It stores and sends cookies just like a web browser.
  2. Second, you can manually add a cookie to the Cookie Manager.However, if you do this, the cookie will be shared by all JMeter threads
HTTP Request Defaults: This element lets you set default values that your HTTP Request controllers use.
HTTP Header Manager : The Header Manager lets you add or override HTTP request headers
 
What are Listeners?
A listener is a component that shows the results of the samples .The results can be shown in a tree, tables, graphs or simply written to a log file
The Graph Results listener plots the response times on a graph.
The “View Results Tree” Listener shows details of sampler requests and responses, and can display basic HTML and XML representations of the response.Other listeners provide summary or aggregation information.
Every listener in JMeter provides a field to indicate the file to store data to.They also provide means to view, save, and read saved test results.
How did you go about fixing a performance issue?
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.
What are some of your recent accomplishments?
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.
What are Pre-Processor and Post-Processor elements?  In what order does JMeter process various type of elements?
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.
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.
Regular Expression Extractor can be used as a Post-Processor element to extract values to be used elsewhere in subsequent requests.
How do you ensure re-usability  in your JMeter scripts?
  • 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.
Does Jmeter generate any scripts? How to use the Jmeter tool and also the How to analyze the results?
When you create a test in Jmeter, save the file. The file saves with the extension .jmx.
Open the .jmx file in an editor. There you can see script.
For what purpose Jmeter used?
Jmeter is a Performance Tool. It is used to test the performance of the application. Apache JMeter is a 100% pure Java desktop application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.
Can we Parametrize via Jmeter?
Yes, you can parametrize via CSV file, User define variables or XML sheet.

JMeter Interview Questions and Answers Part - 4

JMeter Interview Questions

In this post we'll see some JMeter interview questions. I will continue adding more question to this post as and when I will come across new ones.

Ques. What is distributed load testing? How can it be achieved in JMeter?

Ans. Distributed load testing is the process using which multiple systems can be used for simulating load of large number of users. The reason of using more than one system for load testing is the limitation of single system to generate large number of threads (users). In JMeter we can do distributed load testing using the master slave configuration. [For complete steps to perform distributed load testing refer to the post- Distributed load testing in JMeter]

Ques. How can we reduce the resource requirement in JMeter?

Ans. To make the best out of the available resources and in general as a practice, following practices should be incoroprated in the tests-
  • Use non-GUI mode: jmeter -n -t test.jmx -l test.jtl
  • Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
  • Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only during scripting phase to debug your scripts.
  • Rather than using lots of similar samplers, use the same sampler in a loop, and use variables (CSV Data Set) to vary the sample. Or perhaps use the Access Log Sampler. [The Include Controller does not help here, as it adds all the test elements in the file to the test plan.]
  • Don't use functional mode
  • Use CSV output rather than XML
  • Only save the data that you need
  • Use as few Assertions as possible
source: http://jmeter.apache.org/usermanual/best-practices.html] 

Ques. What is Spike testing and how can we perform it in JMeter?

Ans. Suddenly spiking or increasing the number of users at certain point of application and then monitoring the behavior at that intervals is spike testing.
In JMeter spike testing can be achieved using Synchronizing Timer. Synchronizing timer blocks the threads until a particular number of threads have been blocked, and then release them at once thus creating large instantaneous load.

Ques. What all activities are performed during performance testing of any application?

Ans. Activities performed-
1. Create user scenarios
2. User Distribution
3. Scripting
4. Dry run of the application
5. Running a load test and analyzing the result

Ques. What is 90% line in JMeter?

Ans. The aggregate report listener have 90% line as one of the metric. The Apache JMeter manual describes 90% line as- "90% of the samples took no more than this time". It is actually the 90 percentile of the response times of the samples -
90 percentile = (90/100)*N+1/2 where N is the number of samples
So, if there are 10 samples then 90%line will be 9.5 or 9. It means the 9th value in the sorted list of samples (sorted according to ascending order of their response times) will be the 90%line value.

Ques. What is BlazeMeter?

Ans. BlazeMeter is a cloud based service compatible with Apache JMeter. It generates large amount of instant load and provide very comprehensive reporting and analysis features.
In Blazemeter we can just upload the JMeter script and run the load test on cloud with predefined number of users.

Ques. What is correlation?

Ans. Correlation is the most important aspect of scripting. It generally includes fetching dynamic data from preceding requests/calls and posting it to the subsequent requests. [For more details, refer to the post- Correlation in JMeter]

Ques. Explain parameterization in JMeter?

Ans. Parameterization is process of generalizing some user input, so as to use it for multiple users or executions. [For more details, refer to the post- Parameterization in JMeter]
- See more at: http://artoftesting.com/interviewSection/interview.html#sthash.XOOBykRq.dpuf

JMeter Interview Questions and Answers Part -3

Q1: What is the use of Jmeter?
Ans: Jmeter is an open source desktop application software, 100% pure Java application, which is designed to perfom load testing of web based application.

Q2: Is it mandatory to install java first, to run jmeter?
Ans: Yes, Jmeter is an java based application. So you should install java 1.5 or later version in your system.

Q3: Can we do regression testing with Jmeter?
Ans: Yes we can, after-all it is all about java-script. :)

Q4: How we can run jmeter?
Ans: By simply clicking on Jmeter.bat, or by using commnad: C:\>Jmeter

Q5: What are the options, do you see when jmtere window opens?
Ans: 1. Test Plan     2. Workbench

Q6: Which component, do we need to add, to record script?
Ans: We need to add Http proxy server, by simply right clicking on Workbench > Non-Test elements > Http proxy server.

Also need to enable proxy, with port 8080, by going to internet settings> Connections > Lan. Name will be "localhost".
Then click on start button on jmeter http proxy server window.

Q7: Can we perform load testing of database with jmeter?
Ans: Yes we can. To see the process follow: Database load testing with jmeter link. You should be aware of sql queries.

Q8: What are listeners in Jmeter?
Ans: Listeners in jmeter are used to capture the response data of load test. We can have response data (result) in , cvs, image (graph) or in html format.

Q9: Name 4-5 listeners in jmeter, which are commonly used.
Ans: 1. View result tree 2. Summary report 3. Aggregate Graph 4. Response time vs thread 5. Composite graph

Q10: What is Response time in Jmeter report?
Ans: Response time in Jmeter report, is the time taken by web server, to answer the requested query. In simple words, it is the time taken by a web server to respond the http request.

Q11: What is median in jmeter listener?
Ans:  It is a number which divides the samples into two equal halves. Half of the samples are smaller than the median, and half are larger.

Q12: What is throughput in jmeter listener?
Ans: Throughput is relation between time and data.It shows the relation between http request and unit time. Means how many requests are processed in how much time.

Throughput = Number of requests / Time(second or millisecond)

Q13: Which Jmeter elements are used for Parameterization?
Ans: 1. User parameter 2. CSV Data Set config

Q14: Which controllers are used as an conditional controllers in jmeter?
Ans: If controller and While controller

Q15: What is heap size in jmeter?
Ans: Jmeter is work in java, and heap size is related to java. Java heap is the heap size allocated to JVM applications which takes care of the new objects being created. If the objects being created exceed the heap size, it will throw an error of java.lang.out.of.memory.
Java's default heap size limit in Jmeter is 256 MB.

Q16: Is it possible that, if we increase the heap size in Jmeter, then application(jmeter) might not work?
Ans: Yes, it is possible. Because heap size depends upon the empty space of your machine in c drive as well as your RAM. If the RAM is 1 Gb and you increased the heap 2048, it may not work.

JMeter Interview Questions and Answers Part -2

19 Performance testing interview questions and answers


Performance testing interview questions and answers - contributed by Rohit Srivastava
Why Performance Testing is performed?
What are tools of performance testing?
Explain the sub-genres of Performance testing.
What is performance tuning?
What is concurrent user hits in load testing?
What is the need for Performance testing?
What is the reason behind performing automated load testing?
What are the exiting and entering criteria in the performance testing?
How do you identify the performance bottlenecks situations?
What activities are performed during performance testing of any application?
How can we perform spike testing in JMeter?
What is distributed load testing?
Explain the basic requirements of Performance test plan.
What is throughput in Performance Testing?
What are the automated Performance testing phases?
What is Performance Testing?
What is baseline testing?
What is the testing lifecycle?
What is the difference between baseline and benchmark testing?

Q1. Why Performance Testing is performed?

Performance Testing is performed to evaluate application performance under some load and stress condition. It is generally measured in terms of response time for the user activity. It is designed to test the whole performance of the system at high load and stress condition.
Example: Customer like to withdraw money from an ATM counter, customer inserts debit or credit card and wait for the response. If system takes more than 5 min. then according to requirements system functioning is fail.
Type of Performance Testing:
  • Load: analogous to volume testing and determine how application deal with large amount of data.
  • Stress: examine application behavior under peak bursts of activity.
  • Capacity: measure overall capacity and determine at what time response time become unacceptable.

Q2. What are tools of performance testing?

Following are some popular commercial testing tools are:
  • LoadRunner(HP): this for web and other application. It provides a variety of application environments, platforms and database. Number of server monitors to evaluate the performance measurement of each component and tracking of bottlenecks.
  • QAload(Compuware): used for load testing of web, database and char-based system.
  • WebLoad(RadView): it allows comparing of running test vs. test metrics.
  • Rational Performance Tester (IBM): used to identify presence and cause of system performance bottlenecks.
  • Silk Performer (Borland): allow prediction of behavior of e-business environment before it is deployed, regardless of size and complexity.

Q3. Explain the sub-genres of Performance testing.

Following are the sub-genres of Performance Testing:
  • Load Testing: it is conducted to examine the performance of application for a specific expected load. Load can be increased by increasing the number of user performing a specific task on the application in a specific time period.
  • Stress Testing: is conducted to evaluate a system performance by increasing the number of user more than the limits of its specified requirements. It is performed to understand at which level application crash.
  • Volume Testing: test an application in order to determine how much amount of data it can handle efficiently and effectively.
  • Spike Testing: what changes happens on the application when suddenly large number of user increased or decreased.
  • Soak Testing: is performed to understand the application behavior when we apply load for a long period of time what happens on the stability and response time of application.

Q4.What is performance tuning?

To improve the system performance we follow a mechanism, known as Performance tuning. To improve the systems performance there are two types of tuning performed:
  • Hardware tuning: Optimizing, adding or replacing the hardware components of the system and changes in the infrastructure level to improve the systems performance is called hardware tuning.
  • Software tuning: Identifying the software level bottlenecks by profiling the code, database etc. Fine tuning or modifying the software to fix the bottlenecks is called software tuning.

Q5. What is concurrent user hits in load testing?

When the multiple users, without any time difference, hits on a same event of the application under the load test is called a concurrent user hit. The concurrency point is added so that multiple Virtual User can work on a single event of the application. By adding concurrency point, the virtual users will wait for the other Virtual users which are running the scripts, if they reach early. When all the users reached to the concurrency point, only then they start hitting the requests.

Q6. What is the need for Performance testing?

Performance testing is needed to verify the below:
  • Response time of application for the intended number of users
  • Maximum load resisting capacity of application.
  • Capacity of application to handling the number of transactions.
  • Stability of application under expected and unexpected user load.
  • Ensuring that users have proper response time on production

Q7. What is the reason behind performing automated load testing?

Following drawbacks of manual Load Testing that leads to Automation load testing:
  • Difficult to measure the performance of the application accurately.
  • Difficult to do synchronization between the users.
  • Number of real time users are required to involve in Performance Testing
  • Difficult to analyze and identify the results & bottlenecks.
  • Increases the infrastructure cost

Q8. What are the exiting and entering criteria in the performance testing?

We can start the performance testing of application during the design. After the execution of the performance testing, we collected the results and analyzed them to improve the performance. The performance tuning processed will be performed throughout the application development life cycle. Performance tuning is performed which is based on factors like release time of application and user requirements of application stability, reliability and scalability under load, stress and performance tolerance criteria. In some projects the end criteria is defined based on the client performance requirements defined for each section of the application. When product reaches to the expected level then that can be considered as the end criteria for performance testing.

Q9.How do you identify the performance bottlenecks situations?

Performance Bottlenecks can identify by monitoring the application against load and stress condition. To find bottleneck situation in performance testing we use Load Runner because provides different types of monitors like run-time monitor, web resource monitor, network delay monitor, firewall monitor, database server monitor, ERP server resources monitor and Java performance monitor. These monitors can help to us to determine the condition which causes increased response time of the application. The measurements of performance of the application are based on response time, throughput, hits per sec, network delay graphs, etc.

Q10. What activities are performed during performance testing of any application?

Following activities are performed during testing of application:
1. Create user scenarios
2. User Distribution
3. Scripting
4. Dry run of the application
5. Running load test and analyzing the result.,

Q11. How can we perform spike testing in JMeter?

Spike Testing is performed to understand what changes happens on the application when suddenly large number of user increased or decreased. Sudden changes in the number of user by increasing or decreasing at certain point of application and then monitoring the behavior. In JMeter spike testing can be achieved using Synchronizing Timer. The threads are blocked by synchronizing the timer until a particular number of threads have been blocked, and then release them at once thus creating large instantaneous load.

Q12. What is distributed load testing?

Distributed load testing: in this we test the application for a number of users accessing the application at a same time. In distributed load testing test cases are execute to determine the application behavior. Now application behavior is monitored, recorded and analyzed when multiple users concurrently use the system. Distributed load testing is the process using which multiple systems can be used for simulating load of large number of users. The reason for doing the distributed load testing is that to overcome the limitation single system to generate large number of threads.

Q13. Explain the basic requirements of Performance test plan.

Any Software Performance Test Plan should have the minimum contents as mentioned below:
  • Performance Test Strategy and scope definitions.
  • Test process and methodologies.
  • Test tool details.
  • Test cases details including scripting and script maintenance mechanisms.
  • Resource allocations and responsibilities for Testers.
  • Risk management definitions.
  • Test Start /Stop criteria along with Pass/Fail criteria definitions.
  • Test environment setup requirements.
  • Virtual Users, Load, Volume Load Definitions for Different Performance Test Phases.
  • Results Analysis and Reporting format definitions

Q14. What is throughput in Performance Testing?

Throughput in Performance testing is the amount of data sent by the server in responds to the client request in a given period of time or it is the number of units of work that can be handled per unit of time. The throughput is measured in terms of requests per second, calls per day, hits per second, reports per year, etc. In most of the cases, the throughput is calculated in bits per seconds. Higher the throughput value, higher the performance of the application It is includes the client side statistics.

Q15. What are the automated Performance testing phases?

The phases involved in automated performance testing are:
  • Planning/Design: This is the primary phase where team will be gathering the requirements of the performance testing. Requirements can be Business, Technical, System and Team requirements.
  • Build: This phase consists of automating the requirements collected during the design phase.
  • Execution: it is done in multiple phases. It consists of various types of testing like baseline, benchmarking testing
  • Analyzing and tuning: During the performance testing we will be capturing all the details related to the system like Response time and System Resources for identifying the major bottlenecks of the system. After the bottlenecks are identified we have to tune the system to improve the overall performance.

Q16. What is Performance Testing?

Performance Testing is performed to determine response time of the some components of the system perform under a particular workload. It is generally measured in terms of response time for the user activity. It is designed to test the overall performance of the system at high load and stress condition It identifies the drawback of the architectural design which helps to tune the application. It includes the following:
  • Increasing number of users interacting with the system.
  • Determine the Response time.
  • Repeating the load consistently.
  • Monitoring the system components under controlled load.
  • Providing robust analysis and reporting engines.

Q17. What is baseline testing?

Baseline testing is a testing which is performed on the application before coming to any conclusion. It can be either the verification or validation process which provides an idea of what the next stage has to do. It is very important testing technique, if done properly, 85% of performance problems can be identified and solved when proper baseline tests are done.

Q18. What is the testing lifecycle?

There is no standard testing life cycle, but it is consist of following phases:
  • Test Planning (Test Strategy, Test Plan, Test Bed Creation)
  • Test Development (Test Procedures, Test Scenarios, Test Cases)
  • Test Execution
  • Result Analysis (compare Expected to Actual results)
  • Defect Tracking
  • Reporting

Q19. What is the difference between baseline and benchmark testing?

The differences between baseline and benchmark testing are:
  • Baseline testing is the process of running a set of tests to capture performance information. This information can be used as a point of reference when in future changes are made to the application where as Benchmarking is the process of comparing your system performance against an industry standard that is given by some other organization.
  • Example: We can run baseline test of an application, collect and analyze results, and then modify several indexes on a SQL Server database and run the same test again, using the previous results to determine whether or not the new results were better, worse, or about the same. 

12. Discussion on Listeners and its purposes


11. Discussions on Assertions and its Purposes