performance monitoring - kanwal rekhi · 6 jmeter web test plan to build a simple test plan which...

13
Performance Monitoring February 12, 2014 1

Upload: others

Post on 05-Sep-2019

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Performance Monitoring

February 12, 2014

1

Page 2: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Contents

1 Introduction 31.1 Performance Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Load Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Stress Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Core Activities of Performance Testing 32.1 Identify the test environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Identify Performance Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 Plan and Design Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.4 Configure the test environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.5 Implement the Test Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.6 Execute the test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.7 Analyze results,report and retest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Test Design 43.1 Identifying Key Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

4 Test Environment 44.1 Software Requirements: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44.2 Hardware Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

5 Installation: 45.1 Installation on Ubuntu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45.2 Installation on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

6 JMeter Web Test Plan 6

7 Creating a Web Test Plan(edXtest) 7

8 Recording Scripts 10

9 Testing Login Page 13

10 References: 13

2

Page 3: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

1 Introduction

This document provides an overview of performance testing which mainly focuses on Web applicationperformance testing. The different types of tests involved are performance testing,l oad testing andstress testing. Apache jmeter is a desktop application used to simulate heavy load on a server,groupof servers,network or object to test its strength or to analyze overall performance under different loadtypes.

1.1 Performance Testing

Performance testing is used to ascertain how the components of a system are performing,given a particularscenario. Resource usage,scalability and reliability of the product are also validated under this testing.The various activities performed during performance testing of any application include

• Creating user scenario

• User distribution

• Scripting

• Dry run of the application

• Running a load test and analyzing the result

1.2 Load Testing

Load testing is a part of performance testing.Load testing is meant to test the system by constantly andsteadily increasing the load on the system,till the time it reaches the threshhold limit.

1.3 Stress Testing

Stress testing is focussed on determining or validating performance characteristics of the system or appli-cation under test when subjected to conditions beyond those anticipated during production operations.

2 Core Activities of Performance Testing

2.1 Identify the test environment

Identify the physical test environment and the production environment as well as the tools and re-sources available to the test team. The physical environment includes hardware,software and networkconfigurations.

2.2 Identify Performance Criteria

Identfy throughput,response time and resource utilization goals and constraints.

2.3 Plan and Design Tests

Identify key scenarios,detesrmine variability among representative users and how to simulate the vari-ability.

2.4 Configure the test environment

Prepare the test environment,tools and resources necessary to execute each strategy.

2.5 Implement the Test Design

Develop the performance test in accordance with the test design.

3

Page 4: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

2.6 Execute the test

Run and monitor the test.

2.7 Analyze results,report and retest

Analyze the data both individually and as a cross functional platform.

3 Test Design

3.1 Identifying Key Scenarios

Identify all the scenarios for a specific web application.For example,consider an online test web applica-tion. The key scenarios are

• Start Test

• Submit Test

Identify the activities involved in each of the scenarios preparing script.Identify the scenarios that are most commonly executed or most resource intensive.For example,For an online test web application,the main scenario will be start test, give test and submit test.Identify work load.The work load model defines how each of the identified scenario is executed.

4 Test Environment

Preparing the test environment is the next important step.To run the load test,we need to identify andset up the machine configuration.

4.1 Software Requirements:

Operating System: Jmeter is a pure java desktop application and should run on any system that has ajava compliant version.

Java version: JMeter requires a fully compliant JVM 1.5 or higher.Load Testing Tool

4.2 Hardware Requirements

When we perform a load testing, the number of virtual users a machine can generate depends on RAMand processor.

5 Installation:

5.1 Installation on Ubuntu

To download jmeter,go to the linkhttp://jmeter.apache.org/download and download the latest version.Download either the binaries or the source.

Go to the folder where jmeter is downloaded.cd Downloads

Unzip the zip filetar xzvf apache-jmeter-2.10.tgz

4

Page 5: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

To set the folder in a specific place,move itcp -rv apache-jmeter-2.10 /usr/local/src

Modify the permissions of jmeter.sh inside the folderls -sail jmeter.shchmod u=+xrw jmeter.shls -sail jmeter.sh

Run the jmeter.sh file./jmeter.sh

5.2 Installation on Windows

Download latest jmeter version from apache jmeter.Extract the zip file.Run bin/jmeter.bat

This command open up the Jmeter interface.

By default,two elements are shown in the left frame.Test PlanWorkbench

Test Plan node is where real test plan is kept.Workbench node acts as a temporary storage to store test elements when not in use.

Test Plan consist of ThreadGroup.ThreadGroup defines the number of threads jmeter will use during the test run.

ThreadGroup property includes:Number of threads: number of users or connections to the server application.Ramp up period: property which tells jmeter to delay between starting each user.Loop count: tells jmeter how many times to repeat the test.

Jmeter has two types of controllers:Samplers: Samplers allow jmeter to send specific type of requests to a server.

5

Page 6: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 1: Test Plan

Figure 2: JMeter Test Plan

Logic controller: Logic controller controls the order of processing of samplers in a thread.They canchange the order of requests coming from any of their child elements.

Listeners:Listeners are used to view the results of samplers in the form of tables, graphs,trees or simple text

in some log files.

6 JMeter Web Test Plan

To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.shin ubuntu.The jmeter window will appear as shown

Steps to design a test plan:

1. Right click on test plan and add thread group.Mention the number of users,ramp up period and the thread count.

6

Page 7: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 3: edX Test Plan

2. Thread group → Add→ Config element → Http Request DefaultsThe main goals of using Http default request is to avoid data duplication in tests.HTTPRequestDefaults sets the default values for the HTTPdefault controllers.

Http Request defaults consist of the following fields.Name : Reflects the action to be performedServer name or IP: Here, we give the web server name.Path: Type as / which means we need to test the root page of the server

3. Thread group → Add → Sampler → Http RequestSamplers tell jmeter to send requests to server and wait for response.

4. Thread group→ Add→ Listeners → View Results treeDifferent types of listeners are available like graph results,summary report,aggregate report etc.

5. Save the test plan.

6. Run the test plan.

7. View Output

7 Creating a Web Test Plan(edXtest)

To create a test plan, right click on test plan and add a Thread Group.Here the thread group is renamedas edXTest and tested for 100 users with ramp up period 10secs.

ThreadGroup Name: edXTestIP address: 10.105.14.245Port Number: 8001Number of threads(users): 100

7

Page 8: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 4: HTTPRequest Default

In the next step, add HTTPRequest Defaults.Set the IP address of the server machine in which edX is installed and the port number.

In the next step, add HTTP Request sampler for each pages to test.Samplers tell jmeter to send request and wait for the response.Here, HTTPRequest is created for the following pages.

Home PageRegisterLoginDashboardCoursescs101ProgressEnrolmentCPU101x

The below figure shows the HTTP Request created for the login page.Since the server name andport number is already defined in the HttpRequestDefault configuration element,it is not necessary tomention in each request.The path is added in the HTTP Request.

Listeners:Listeners are used to view the results of samplers.The important listeners are Summary Report, View

Results Tree, Aggregate Report, Graph Results, View Results in Table etc. JMeter provides additionalplugins for viewing results. The performance also depends on the CPU usage,memory, etc. These pluginscan be installed to identify better performance.

Aggregate report includes:Samples: number of requests sent.Average: defines the average time taken by a set of results.Maximum: peak time(in ms) of the response.Minimum: shortest time(in ms) taken by the samples to respond.Error rate: gives the percentage of requests with errors.Throughput: provides the number of requests per second/minute/hour.KB/sec: throughput measured in kilo bytes per second.

8

Page 9: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 5: HTTPRequest for login page

Figure 6: Aggregate Graph

9

Page 10: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 7: View Results Tree(Request)

8 Recording Scripts

Recording Script with JmeterJmeter helps to record script,maintain script and run script.

• Setting Workbench and proxy server:

• In jmeter window,right click on workbench,selectAdd Non-test-elements → Http test script recorder.

• Now in http test script window,port value will be 8080 by default, otherwise set it to 8080

• In the drop down list, select recording controller as the target controller.

• In the next step,add recording controller,under http test script recorder. Recording controllerenables to record script under it,so that it will be in a structured way.

10

Page 11: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 8: View Results Tree(Response)

Figure 9: Aggregate Graph

11

Page 12: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

Figure 10: Failed Request for CPU101x

Figure 11: Failed Response for CPU101x

12

Page 13: Performance Monitoring - Kanwal Rekhi · 6 JMeter Web Test Plan To build a simple test plan which tests a webpage,open the jmeter window using the command jmeter.sh in ubuntu.The

• The workbench is now ready to record scripts.Now open web browser and go to settings.

• In settings,go to proxy server and check the check box.

• Type localhost in the address text box and in the port provide the port number which we havegiven to proxy server port ie 8080.

• Finally click ok button and close the window.

• To start recording the script, type url of the application in the browser and press enter.

• Now in recording controller under workbench,some http request will be recorded.

9 Testing Login Page

To test login page for ’n’ number of users,

Create a csv data set configuration element to the thread group with login request.

Now, go to jmeter/bin folder and create a text file with username and password separated by commas.

Save the file with filename.csv extension.

Edit the properties in the csv Data Set config in jmeter window as shown below.

Add view result tree listener to check whether it works.

This is a basic test plan created. More features can be included to test performance.Assertions, cookiemanager, timers, etc can be added while creating a test plan.

10 References:

[1] Apache Jmeter, http://jmeter.apache.org/.[2] Understanding JMeter Results by Digvijay Bisht,http://jmeterresults.blogspot.in/.[3] http://msdn.microsoft.com/en-us/library/bb924359.aspx

13