Thursday, 28 April 2016

Static Versus Dynamic Web Pages

Web pages could be either static or dynamic. "Static" page will have constant content, while "dynamic" page has content changing. Therefore, static Web pages contain the same content each time the page is loaded, while the content of dynamic Web pages can be generated on fly.

Example for Static web pages are HTML pages, which defines the structure and content of the Web page. Every time an HTML page is loaded, it looks the same. The only way the content of an HTML page will change is if the Web developer updates and publishes the new file.

On the other hand some of the dynamic web pages are PHP, ASP, and JSP pages, these pages contain "server-side" code, which allows the server to generate dynamic content each time the page is loaded.
For example, the server may display the current time and date on the Web page. Also, dynamic pages use server-side code to access DB, which enables the page's content to be generated dynamically from information stored in the database. 

We can easily say whether the page is dynamic or static just by looking at the page's file extension in the URL, in the Web browser. If it is ".htm" or ".html," the page is probably static. If the extension is ".php," ".asp," or ".jsp," the page is most likely dynamic. 

Java Class file format


Wednesday, 30 March 2016

Steps to write the RMI program with example program

Below are the Steps to write the RMI program

  1. Create the remote interface
  2. Implementation of the remote interface
  3. Compile the implementation class and create the stub and skeleton objects using the rmic tool
  4. Start the registry service 
  5. Create and start the server application
  6. Create and start the client application
Below are the example program with output:-

//Create the remote interface


import java.rmi.*;
public interface AdderApps extends Remote{

public int addition(int x,int y)throws RemoteException;
}


//Implementation of the remote interface


import java.rmi.*;
import java.rmi.server.*;

public class AdderRemoteobj extends UnicastRemoteObject implements AdderApps{

AdderRemoteobj()throws RemoteException{
super();
}

public int addition(int x,int y){return x+y;}

}

//Compile the implementation class and create the stub and skeleton objects using the rmic tool and start the registry service

//Create and start the server application

import java.rmi.*;
import java.rmi.registry.*;

public class MyServer{

public static void main(String args[]){
try{

AdderApps stub=new AdderRemoteobj();
Naming.rebind("rmi://localhost:5000/Sai",stub);

}catch(Exception e){System.out.println(e);}
}

}

//Create and start the client application

import java.rmi.*;

public class MyClient{

public static void main(String args[]){
try{

AdderApps stub=(AdderApps)Naming.lookup("rmi://localhost:5000/Sai");
System.out.println(stub.addition(25,50));

}catch(Exception e){System.out.println(e);}
}

}


Output:-


Monday, 29 February 2016

LoadRunner Architecture

Following are the Major components of LoadRunner
  • Vugen
  • Controller
  • Load Generator
  • Analysis

 


Vugen

Virtual User Generator (or) Vugen is the IDE (Integrated Development Environment) which  is used to record end-user business processes and it generats script known as Vuser Script. It records the traffic between client server communication and generates the script. After the script is generated enhancements were made based on the requirements. Some of the enhansements will be Correlation, parameterization, inserting transactions, thinktime, write custom code, insert validations, etc.
Controller
The Controller is one of  the component of loadrunner. Workload is designed in the controller by allocating number of users for each scenerio.It also defines the user behaviour ,the main task of the controller is to controller the users as per work load design and collect the data from LGs and give it to analasis.
Load generator
Load generators are the machines which are responsible to generate the load of multiple users on the system. We can use any number of load generators during the test. For Http protocol each user consumes 2 MB of memory to simulate single virtual user so,to run 1000 virtual users we need 2GB approxmatly.
Analysis
After the test run Analysis component creates the graphs based on the data in output.mdb file. There are different graphs which states different values; like Running Vusers, Throughput, Hits/sec, Pages/min, Tracsactions/sec, Average Transaction Response Time, etc.

Other components includes :

Remote Agent Dispatcher – Remote Agent Dispatcher(Process) enables the Controller to start applications on Load Generator(s).

LoadRunner Agent – It communicats and manages the connection between the Controller and Load Generator(s). When the scenario is run, the Controller instructs the Remote Agent Dispatcher(Process) to launch the LoadRunner agent. The agent receives the instructions from Controller to initialize, run, pause, and stop Vusers. It also send back the data of the status of the Vusers back to the Controller.




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?