Thursday, 7 January 2016

Performance Testing Phases


Planning/Design Phase:-

This is the most important phase where a performance test engineer has to understand the application in terms of both business and technical prospective.

In terms of Business perspective one should understand the end user usage like business process flow (step by step usage of the application), most frequently executed business transactions, Number of users in production (under normal and unexpected load), the rate at which the transactions will be executed, workload criteria (It comes under both technical and business)….e.t.c.

In terms of technical perspective one should understand the system architecture and environment, Types of performance tests with the objectives, effort required to conduct the performance tests, entry criteria and exit criteria, Tools used to conduct the performance test …..e.t.c.

Build Phase:-

It includes
  1. Scripting: Record/develop the scripts based on the business processes gathered in the design phase. Script should be prepared with enough test data. All the business transactions should be embedded in the script with proper parameterization. 
  2. Scenarios with workload: once the script is prepared with zero errors, then distribute the number of users appropriately for each scenario to simulate real world production environment.
  3. Monitors: Decide which servers need to be monitored.
We may need help from different teams like systems, DBA, Operations and Business Teams in order to execute successful performance test execution.

Execute:-

Execution will be done in multiple phases. It consists of various types of testing.
Baseline Testing
Base line testing is done to ensure that the correctness of the application’s functionality, script & environment setup. This will be done with 1 user.
Benchmark Tests
Benchmark testing is done with 15 to 20 % of the target load. These are designed to measure and compare the performance of each build of the application in ideal situation.
Also, we may need to conduct different types of performance test based on the requirements.

Analysis and Tuning


Once the performance testing is done ,we analyze performance test result and identify the bottleneck of the system. Once the bottleneck is identified  and fixed, we run bottleneck isolation testing and conform system to improve the overall performance.


Report:-
We prepare performance test report with below metrics (I am including only few metrics):-
  • Transaction response times
  • Resource utilizations
  • Volumes, capacities, and rates
    • Bandwidth consumed
    • Throughput
    • Transactions per second
    • Hits per second
We also add recommendation in the report and publish to stakeholders and close the project for the current release.

Wednesday, 6 January 2016

First JSP example

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2>Hello JSP</h2>
</body>
</html>

Output:-

Tuesday, 5 January 2016

Java HttpSession Example

First.java

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class First
 */
@WebServlet("/First")
public class First extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n = request.getParameter("userName");
out.println("Welcome" +n);
HttpSession session = request.getSession();
session.setAttribute("uname", n);
out.println("<a href='servlet2'>Visit</a>");
out.close();

    }
}


Second.java


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class Second
 */
@WebServlet("/Second")
public class Second extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(false);
String n = (String) session.getAttribute("uname");
out.print("Hello "+n);
   out.close();
}

}


OutPut:-



Saturday, 2 January 2016

Java servlet program forward() and include() methods

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class First
 */
//@WebServlet("/First")
public class First extends HttpServlet {
//private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
   PrintWriter out = response.getWriter();
       
   String n=request.getParameter("userName");
   String p=request.getParameter("userPass");
       
  out.println("First Servlet");
   if(p.equals("servlet")){
       RequestDispatcher rd=request.getRequestDispatcher("/servlet2");
       rd.forward(request, response);
   }
   else{
       out.print("Sorry UserName or Password Error!");
       RequestDispatcher rd=request.getRequestDispatcher("/First.html");
       rd.include(request, response);
                   
       }
 
}

}



import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Sec
 */
//@WebServlet("/Sec")
public class Sec extends HttpServlet {
//private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub






   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
       
   String n=request.getParameter("userName");
   out.print("Welcome "+n);
   }


}



Output:-




Friday, 1 January 2016

Basic Performance Testing Concepts

What is performance testing?
Software performance testing is a part of QA task,which involves testing software applications to ensure that software should perform well under expected workload.

Performance testing is subset of performance engineering.Performance Engineering helps in building software with an aim to meet the performance requirements right from the requirements phase.

The objective of the functional testing is to verify and validate the functional requirements whereas the objective of performance testing is to
verify and validate the non-functional requirements (NFR) of the system related to performance.

Performance testing:-
Performance testing is done to determine the Speed,Stability and scalability under load.

Objective :-
To determine or validate speed, scalability , and/or stability.

Load Testing:-
Load testing is done to determine the application behavior (Non-functional requirements) were meeting the under expected load.

Objective:-
To verify application behavior under normal conditions.

Endurance test is a type of performance test focused on determining
application behavior when the test is conducted for long period.During endurance tests, memory consumption is observed to determine potential failures. It is also called as soak testing.
Endurance testing may be used to calculate Mean Time Between Failure (MTBF), Mean Time To Failure (MTTF), and similar metrics.

Objective:-
To verify the memory leaks

Stress Testing:-
To identify the application’s Break Point, also to measures whether the application’s environment is configured to handle the expected or unexpected load.

Objective:-
To determine the break point.

Spike testing:-A spike test is a type of performance test focused on determining or validating the  application performance when there is sudden increase in load for short periods of time.

Objective:-
To determine the application behavior when there is sudden increase in load for short time.

Why Performance Testing is important??

It is so important because once the application goes to production to generate revnivew,It should not fail (or) Crash. Failures in the prod will leads to wast or time and money.

Performance Testing helps to answer the following questions:-

a.Response time of the system under expected load?
b.System behavior under unexpected load?
c.will the system scales to a specific user load?
d.What hardware is required to the system for better performance?
e.Will the system handles spikes?