Monday, September 30, 2013

Few file Operation used in C language

File Operations:
Below are the few file operations which we perform generally

1) Crete,Read, Write, Open and Close
Note: Other than .pdf we can create .txt, csc, .doc , .xls, .dat

Create a file and write data into that file:
Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%s","Welcome To Load Runner");-->fprintf is used to enter some text into a file
fclose(filename1);--->flose is used to close the opened fie
return 0;
}
Write Some Random Numbers into a file:
Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
int a=rand()%11+10;
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%d\n",a);
fclose(filename1);
return 0;
}

Read data from an existing file:

Read data in a file as string wise using common separator
Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
char s1[100],s2[100],s3[100],s4[100];
int d;
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 1")
filename1=fopen(file1,"r")--------->W is used to write data into file and R is used to Read.
fscanf(filename1,"%s1",&s1);
fscanf(filename1,"%s2",&s2);
fscanf(filename1,"%s3",&s3);
fscanf(filename1,"%s4",&s4);
fscanf(filename1,"%d",&d);
lr_output_message("%s %s %s %s ",&s1,&s2,&s3,&s4);
lr_output_message("%d ",&d);
fclose(filename1);
return 0;
}

Read data in a file as line wise :

Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
char temp[100];
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 1");
filename1=fopen(file1,"r")--------->W is used to write data into file and R is used to Read.
fgets(temp,200,filename1);
fclose(filename1);--->flose is used to close the opened fie
return 0;
}

To Read size of characters in file 

Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
char temp[100];
int total=0;count;
char buffer[1000];
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 1");
filename1=fopen(file1,"r")--------->W is used to write data into file and R is used to Read.
while(!feof(filename1))
{
count=fread(buffer,sizeof(char),1000,filename1);
total +=count;
}
lr_output_message("total number of  bytes=%d ",total);
fclose(filename1);--->flose is used to close the opened fie
return 0;
}

Total no.of characters of a file :

Action();
{
char *file1 = D:\\madhu\\sample.txt;
long filename1;
char temp[100];
filename1=fopen(file1,"w")--------->W is used to write data into file and R is used to Read.
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 1");
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 2");
fprintf(filename1,"%s","Welcome To Load Runner performance testing version 3");
filename1=fopen(file1,"r")--------->W is used to write data into file and R is used to Read.
while(!feof(filename1))
{
lr_output_message("%s ",temp);
fgets(temp,1000,filename1);
}
fclose(filename1);--->flose is used to close the opened fie
return 0;
}

Few string Oprations used in C language

below are various types of string functions which are used in Load Runner
1) Strlen();
2) strcpy();
3) strcat();
4) strcmp()
5) stricmp()
6) Strncmp();
7) Sprintf();
8) Strtok();
9) Conversion Functions

STRLEN();
This Function is used find the length of a given string.

Action()
{
int a,b;
char *temp ="Welcome To Load Runner";
a=strlen("Welcome To Load Runner");
b=strlen(temp);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
return 0;
}

STRCPY();
This Function used to copy the whole string into another string

1) By storing  the value in to another variable

Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;

}

with out storing  the value in to another variable

Action()
{
char temp2[100];
char *temp1 ="Welcome To Load Runner";
strcpy(temp2,temp1);
lr_output_message("%s",temp1);
lr_output_message("%s",temp2);
return 0;

}

STRCAT();
This function is used to concatenates two strings,the second string will appended to first string.

Action()
{
char temp[100];
strcpy(temp,"welcome to load runner");
strcat(temp,"performance tool");
lr_output_message("%s",temp);
return 0;

}

Action()
{
char temp3[100];
char *temp1="welcome to load runner";
char *temp2='Performance Tool';
strcat(temp3,temp1);
strcat(temp3,temp2);
lr_output_message("%s",temp3);
return 0;

}

STRTOK();
This is function is used to split the string to into no.of sub strings using a common deliminator or separator.

Action()
{
char *temp2[]="welcome to load runner";
char *token;
token=(char *)strtok(temp2," ");

while(token!=NULL)
{
lr_output_message("%s",token);
token=(char *)strtok(NULL,"");
}
return 0;
}

STRCMP();
This function is used to compare the strings,strings will be compared based on their ASCII values and
-> If both the strings are equal then it returns 0;
-> If first string is greater then the second string then it will returns 1
-> If second string is greater then the first string then it will returns -1

Action()
{
int a,b,c;
a=strcmp(Hyderabad,Bangalore);
b=strcmp(Hyderabad,Hangalore);
c=strcmp(Hyderabad,Hyderabad);
lr_output_message("%d",&a);
lr_output_message("%d",&b);
lr_output_message("%d",&c);
return 0;
}

STRICMP();
This function is used to ignore the cases and treats the upper case and lower case letters same.

Action()
{
int a;
a=stricmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;
}


STRNCMP();
This function will compare the strings and if they are not equal then it will returns ASCII code deference value between them.

Action()
{
int a;
a=strncmp(Hyderabad,HYDERBAD);
lr_output_message("%d",&a);
return 0;

}

SPRINTF(); 
This function is used to print and save any given formatted data into a string variable.

Action()
{
char a[100];
sprintf(a,"%s","welcome to load runner");
lr_output_message("%s",&a);
return 0;

}

Conversion Functions:

A To I:
This function is used to Converts a string formatted integer value into pure integer value.

I TO A
This function is used to Converts a integer formatted string value into pure string value.

A To F:
This function is used to Converts a string formatted float value into Float value.

A To F:
This function is used to Converts a string formatted Long value into Long value.

Thursday, September 26, 2013

As part of performance testing using Load runner Learn C language

-> C is a structured programming language.
-> It is closely related to Assembled language.
-> It is easy to implement and produces efficient programs

Have a glance on variables,datatypes

Simple Programs using vuser load generator on C

Sample program in C

    #include<stdio.h> //
       // All the standard input files available at stdio library
    #inculde<conio.h> 
    // All the console input out functions available at conio library
    Global declaration; //Will be accessible for all the functions  
    // single line comment //Comments cannot be executed
    void main();
   //In c every program starts and end with main fun,it is starting of the program
    {   ->Function starts here 
   int a,b,c;
    a=10;b=20;
    c=a+b;
       printf("addition of a,b =%d,a);
       //printf prints the message on the screen
          // system needs to understand so %d used in printf
     //scanf(" ......................") ; ->scanf to accept the values at run time 
        getch();               //This function is used to get the character at run time.
     clrscr();          //this function is used to clear the screen
      return 0;        //To release the allocated memory                           
     }   

Sample C program in Load runner

  Action()
   {                                
   int a,b,c;
   a=10;b=20;
     lr_output_message("the value of a=%d,a");
    // lr_output_message is predefined fun prints the message on the screen
      lr_output_message("the value of b=%d,a");    
   c=a+b;     
   lr_output_message("the Addition of a,b=%d,c");     
   c=a-b;     
   lr_output_message("the Subtraction of a,b=%d,c");     
  c=a*b;     
   lr_output_message("the Multiplication of a,b=%d,c");   
  c=a/b;     
   lr_output_message("the Division of a,b=%d,c");          
   return 0;        //To release the allocated memory     

Rand():-
       -->    To Generate a random number in between any of the given range
       -->    A=rand()%8 will generate random values from 0 To 7;
       -->   Using the above function always the values starts from '0'

To Generate Random Value from desired numbers using Random function:
  If you want generate values from 31- 51 then the below random function need to use
           I.e   is rand()%21+31
To generate random value from 31- to 51 below is the formula
        Value=max-min+1

Sample program for arithmetical operations using desired random value

 Action()
   {                              
   int a,b,c;
   a=rand()%21+31;
    b=rand()%11+21;
     lr_output_message("the value of a=%d,a");
    // lr_output_message is predefined fun prints the message on the screen
      lr_output_message("the value of b=%d,a");    
   c=a+b;   
   lr_output_message("the Addition of a,b=%d,c");    
   c=a-b;   
   lr_output_message("the Subtraction of a,b=%d,c");    
  c=a*b;   
   lr_output_message("the Multiplication of a,b=%d,c");   
  c=a/b;   
   lr_output_message("the Division of a,b=%d,c");        
   return 0;        //To release the allocated memory   

Conditional statements:
If a particular condition is true then it will execute the program other wise it will ignore the condition
 Below are various kinds of conditional statement

1) If
2) If-Else
3) Else-If
4) Nested-If
5) Switch
6) Go-to


Sample program To perform Conditional statements

Action()
   {                            
   int a,b,c;
   a=rand()%21+31;
    lr_output_message("the value of a=%d,a");
    // lr_output_message is predefined fun prints the message on the screen
      If(a>40)   
    {
     lr_output_message("the value of a is greater 40");
    else if(a<40)
      lr_output_message("the value of a is less then 40");
    else if
     lr_output_message("the value of a is = 40");
       return 0;        //To release the allocated memory   

A Program To perform Conditional statements along with & operator 

Action()
{                            
int a,b,c;
a=rand()%81+10; //10-90
lr_output_message("The value of a=%d,a");
// lr_output_message is predefined fun prints the message on the screen
If(a<=25)   
{
lr_output_message("The value of a is Less then or equal to 25");
else if(a>25 && a<50)
lr_output_message("The value of a is in between 25 and 50");
else if(a>50 && a<75)
lr_output_message("The value of a is in between 50 and 75");
else if(a>50 && a<75)
lr_output_message("The value of a is in between 50 and 75");
else if(a>=75)
lr_output_message("The value of a  is greater then or equal to 75");
return 0;        //To release the allocated memory   

Loops:
Repeats a statement or group of statements when a given condition is true. First it will check whether the given condition is true then it will enters into loop other wise it will just comes out of the loop.

There are three kind of loops which are
1) For Loop
2) While Loop
3) Do-While Loop

For loop:
->In For loop initialization ,condition and iteration(Increment/Decrements) at one place.
->If we are not initializing the value then by default the value is '0'
->Iteration can be done inside the for loop as well

Syntax:

for(initialization ;condition;iteration(Increment/Decrements)
{
Statement 1
Statement 2
-----------------
}

Sample program To perform For Loop

Action()
{                          
int a,
for(a=5;a<=10;a++)
{
lr_output_message("The value of a  =%d",a);
}
return 0;        //To release the allocated memory     
}

While loop:
->In While loop initialization ,condition and iteration(Increment/Decrements) can not placed in place.
->In While Loop It check the condition and execute the statement.


Syntax:

initialization ;
while(condition)
{
Statement 1
Statement 2
-----------------
iteration(Increment/Decrements);

}

Sample program To perform For Loop

Action()
{                          
int a=5,
while(a<=10)
{
lr_output_message("The value of a  =%d",a);
a++;
}
return 0;        //To release the allocated memory     
}

Do-While loop:
->In Do-While loop initialization ,condition and iteration(Increment/Decrements) can not placed in place.
->In Do-While Loop It will execute the statement first and later it will check the condition.


Syntax:

initialization ;
while(condition)
{
Statement 1
Statement 2
-----------------
iteration(Increment/Decrements);

}

Sample program To perform For Loop

Action()
{                          
int a=5,
do
{
lr_output_message("The value of a  =%d",a);
a++;
}while(a<=10);
return 0;        //To release the allocated memory     
}

Tuesday, September 24, 2013

Continuation of performance testing concepts

Types of Application for performance testing:
1) Web Based Application
2) Client/Server Application
3) Desktop Application.

Web Based Application:
If An Application will communicates through HTTP/HTTPS then it is called Web based application.
It can be communicated to ways
1) Using URL's
2) Using .exe file

While debugging the application need to majorly concentrate on below things.
1) Response Time.
2) Server's behavior.
3) Network behavior.
4) Vuser's Load.

Flow chat for Web Base Application.

Real User Account/Client------> Web Server---------> Application Server----------> Data Base Server

Web Server is also called as HTTP server and web based application communication will be done from public network.

Response time:
How much time time it is taking to get response from server
Response time will be measured in secs
 -> Response time (Secs)
As a performance tester we need to find how much time it is spending on each server to respond.if we get delay in the response time then we will treat it as bottle neck.

Server's Behavior:
Analyze each individual  server's behavior to identify the root cause of the performance degradation.

Network Band width:
Analyze the bandwidth utilization to identify the root cause of performance issues.

Vuser's Load:
Analyze the V-user's load running on the server whether it is accepting expected user load or not.if it is unable to accept the expected user load then it is fault with webserver.

Client/Server Application:
Client/Server communication is made between client and data base server using TCP protocol. there will be no web server and application server and there is no concept of URL's.In client/Server Communication application is accessible in Private network

                                                       Request
                                           Client--------------> Data Base Server
                                                       Response
Objectives:

Response time:
It is amount time taken to execute the End to End user action or business flow.
Response time will be measured in secs
Sending request +Got the response = one successful transction
 -> Response time (Secs)
As a performance tester we need to find how much time it is spending on each server to respond.if we get delay in the response time then we will treat it as bottle neck.

Data Base Server Behavior:
In Client/Server communication every thing will be executed through quires.

V-User's Load:
->Need to test the Client/server application with less user load as it is under private network and this will be used by less number of resources.
Here there is no point of network band width as it is directly communicating the data base server.

Desktop Based Application:
The application which runs only at client end and does not have any server and network is called Desktop/Standalone  application.
Ex:-Notepad,Ms.Office,Software Installation.

Objective:

Response time:
It is amount time taken to execute the End to End user action or business flow.
Response time will be measured in secs
 -> Response time (Secs)
As a performance tester we need to find how much time it is spending on each server to respond.if we get delay in the response time then we will treat it as bottle neck.













Monday, September 23, 2013

Performance Testing Notes

Now a days if we wants to become an expert in Performance Testing need to grab the knowledge on below concepts.

1) Performance Testing (includes the process we follow to perform the performance task and the tool which we use to automate the performance task)
2)Performance Engineering & Performance Tuning.

Why do we do Performance testing
To measuring the performance of a system and end user experiance by applying the production workload to pre deployment system.

End of the testing we should  be ready to answer the below question

Whether the application quickly enough responding for all the user who ever accessing
Whether the application able to handle the expected and beyond the expected user load
Whether the application is able to handle the no.of transactions required by th business
Under expected and unexpected user loads will the application is sustain or stable.
If it is go live whether we can assure that the user will have positive experiance.


General Software Development life cycle:

1) Requirements Gathering.
2) Analysis & Design.
3)  Coding or Development.
4) Testing.
5) Deployment.
6) Maintenance.

General Performance Testing Life Cycle:

1) Request for Proposal (RFP)
2) Statement of Work (SOW)
3) Discovery
4) Planning
5) Automation
6) Smoke Test
7) Final Test
8) Analysis and Report.
9) Retest if needed.

1) Request for proposal:
Client who needs performance testing their product will sent a request for proposal by giving a brief introduction about their company and also about their product as well. Sales team will analyze and Prepare a Statement of work based the client calls and Email communication happened during this face.

2) Statement of Work
This Document will highlights the statement of work,the tool,the User load,the kind of tests which we need to perform.and total number of scenario's (also called use case's)which we need to cover.

3) Discovery:
Once SOW is singed then it is the responsibility of the team lead to initiate the Discovery process.In this phase we will get more clarity on what is to be done and the application architecture,the exact scenario's to be automated,think times,User mix,Transaction mix and also if anything other then this specified in Service Level Agreement (SLA). In this face everything will be done/communicated through Email/Phone.
-> Once the Roles and Responsibilities are identified, it will be communicated to all the team members.
-> In this face Client side Proof of concept(POC)  will also identified.
-> Identify whether we can go with URL's or .exe
-> Identification of  Protocols.
-> Will identify the application functional behavior  by accessing  the URL's
-> Technical architecture along with development Technics.
-> Analyze the accessibility of the application(any VPN is providing to access the application or direct URL's).
-> This face will completed with in 3-4 days.
-> Once everything thing done.Lead will communicate to client about the expectations via Email.

Test Requirements of any standard performance test of any project will be always as below.

1) Application Architecture
2) V users load.
3) Business Scenario.
4) Tool.
5) LAN/VAN.
6) Test Environment.
7) Production Load.(if the application is already existing in production)
8) Production schedule(need to update it)
9) Workload

Application Architecture:
       Analyze the detailed architecture of an application to understand the supported tools along with the protocols
       Analyze the architecture along with the deployment technologies to monitor the servers during the load test execution.

V-Users Load:
Analyze the amount of maximum users load to be generated on server.
Step 1:
If Client defines expected user load to be kept on the server we will do the execution using the same.
Step 2:
If Client does not define the expected user load to be kept on the server then we will analyze whether the application is already existing on the production or it is newly developed one.

If  the application is already developed and in the production:
We need to collect the Production logs and Reports for each business scenario from production monitoring team to analyze the maximum users accessing the application in production for a total of 24 hours duration.
So that we can get an idea on what time peek load is generated and how many users' are accessing at that time.
If  the application is newly developed and it is not in the production:   
Under below methods we can analyze the V-user's load
1) Bench Mark
2) Stress Testing:

Bench Mark:
Similar kind of application tested previously 'test results' will be considered as a bench mark for the current application as well.

Stress Testing:
Test the application behavior by gradually increasing the  user load,until the application get crashed/server breaks.

Objective of Stress testing:
The objective of the stress testing is to identify the maximum capacity of the application at the given server.

Business Scenario:
-> Analyze the business scenario's which will be critical to the application.
-> Analyze the scenario's which will give more revenue.
-> Analyze the scenario's which will more frequently accessed

Step 1:
If Client defines type of the business scenario's which need to test then will do the execution using the same.

Step 2:
If Client does not define the type of the business scenario's which need to be tested,then identify the frequently accessed  scenario's and the scenarios which are critical to the application.These thinks will be identified by PFT team.

Step 2.1:
Need  to gather the information from domain expert or functional expert to identify the frequently accessed functionality.

Step 2.2:
Once  done with gathering the scenario's need to share the same by preparing a Scenario's Work flow Document to get an approval from them.

Step 2.3:
Client will  review and discuss with other project teams and finally the client will approve the list of scenario's which need to perform the test execution.

Note:-If the application is in the production then will collect the production logs and reports to identify the frequently accessed functionality in the production,based on the production analysis we will identify the performance scenario's..

Tool:-
Analyze the tool to be used for executing the business scenario's.

Step 1:
If Client decides the type of the tool  to be used then we will do the execution using the same.

Step 2:
If Client does not decide the type of the tool  to be used then we need to do the POC (Proof of concept).
For that identify the list of tools which are technically feasible for the given application.

While doing the POC need to remember the below things.

Step 1:
In order  to under stand the technical feasibility record and reply the script on multiple tools.

Step 2:
After performing recording and replying the script prepare a checklist along with the identified tools and send it to the client.

Step 3:
Now the client will analyze the commercial's of each tool and finalize which to be used for the project execution.

LAN/WAN:
Define the network behavior and to simulate the load from same network or from different netwrok

LAN Based performance testing:
If load generators and servers are configured with in the same network then it is called as LAN based performance testing. It is called private network

WAN Based performance testing:
If load generators and servers are configured in different  networks and accessed through internet then it is called as WAN based performance testing. It is called public network

Test Environment:
Analyze the type of the test environment will be using to doing a performance test execution.actually there are Development environment, QA Environment, Load Environment,Production Environment.

Step 1:-
We will do Performance testing execution on dedicated staging environment in pre-production

Step 2:-
The Client is expected to do the performance test  say an example 50% or 10% of the production users.

Production load:
Analyze the production v-users once the application go live in to environment.

Production schedule(need to update it):
Analyze the project schedule in detailed in phase wise,when to start and when to stop,with how many users we want run execution,and each scenario should have how many number of users everything should be decided here.
-> Generally everything will be shared by client.
-> Once the project is engaged we should prepare and share the performance questionnaire so that client will do walk through it.
-> Also this will be shared to all the Development team,QA team,Admin team,performance team,business team and also with client.

Workload:
Analyze the v-users load distribution across all the given scenario's.

4) Planning:
This phase Manger will prepare plan, he will calculates the no.of resources required ,and infrastructure required,once done with the plan it will be delivered to the client for each phase.

5) Automation:
what ever the scenario's which are identified in Discovery stage will be automated in this phase.

6) Smoke Test:
Once done with automating the script will be validating here,if anything goes wrong will be corrected as part of script.will also identify using script are we able to navigate each page when running the script

7) Final Test:
Here actual test(Load,Stress,Endurance,Volume,ETC..) will be conducted to know the bottle necks of the application.

8) Analysis & Report:
After Executing the script client & server side metrics will be analyzed as per the SLA(in scope) for bottle necks if any.and same thing will be communicated to client with a detailed report.

9) Re-Test
Need to do re-test if client requires.

Entry Criteria for performance testing:
The entry criteria for performance testing is the application should be functionally stable.

Introduction to performance test:

General Scenario for Banking application will look look this

Login To Application
A/C Info
Statement
Detail Statement
Logout

The above Scenario will converted into script,and all the virtual user's will be access be accessed that script across the geographical location.

By executing the above automated script with expected V-USER's(Virtual users) we can understand the Application/Server's behavior.

Learn Load runner Terminology

Vuser's:
Vuser's will simulates the real user's behavior/business logic using Vuser script with the help of load generator.

Load Generator:
Load generator is a component in any of the performance testing tool.it is useful generate the amount of Vuser's Load.

Vuser's script:
It contains the business logic/real user's action in an understandable and supported language.

Objective of Performance Testing:
The Primary Object of the performance testing is to find the response time of each user's action or page.

Types of performance test are:
1) Load Testing.
2) Stress Testing.
3) Endurance Testing
4) Spike Testing
5) Volume Testing.

Load testing:

1)  Load Testing: 
The test execution with a specified user load under given conditions. Major focus will be on system stability, response times and success and failures.

2) Stress Testing: 
The test execution where we continuously increase the load on the application until it crashes. Major focus will be on the threshold limit of users and response time is not at all considered.

3) Endurance Testing: 
The test execution where we load the application continuously for longer duration's like days or months to identify bottlenecks like memory leaks.

4) Spike Testing: The test execution where the application is loaded with varied user load suddenly (sudden increase and decrease) to check the system behavior.

5) Volume Testing: 
The test execution where we send the continuous data to the db to check whether it can handle that much volume of data at a time.