Wednesday 26 February 2014

Prepare Jmeter Reports using excel macros | Jmeter report automation using excel macros

To create an Excel macro that reads a JMeter JTL file and prepares reports in the Excel sheet, you can follow these general steps:
  • Open Microsoft Excel and create a new workbook.
  • Press ALT + F11 to open the Visual Basic Editor.
  • In the Visual Basic Editor, insert a new module by right-clicking on the project and selecting "Insert > Module."
  • In the new module, create a new sub-routine that will read the JMeter JTL file. You can use the following code to read the file:
Sub GenerateJMeterReportWithColor()
    
    ' Set the path to the JTL file
    Dim jtlFilePath As String
    jtlFilePath = "C:\Path\To\JMeter.jtl"
    
    ' Open the JTL file
    Dim jtlFile As Object
    Set jtlFile = CreateObject("Scripting.FileSystemObject").OpenTextFile(jtlFilePath, 1)
    
    ' Set up the Excel worksheet
    Dim reportSheet As Worksheet
    Set reportSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
    reportSheet.Name = "JMeter Report"
    
    ' Write the report header
    reportSheet.Range("A1:D1").Merge
    reportSheet.Range("A1:D1").Value = "JMeter Report"
    reportSheet.Range("A2:D2").Merge
    reportSheet.Range("A2:D2").Value = "Generated on " & Now()
    reportSheet.Range("A1:D2").HorizontalAlignment = xlCenter
    reportSheet.Range("A1:D2").Font.Bold = True
    reportSheet.Range("A1:D2").Font.Size = 14
    
    ' Write the column headers
    reportSheet.Range("A4").Value = "Sample Name"
    reportSheet.Range("B4").Value = "Samples"
    reportSheet.Range("C4").Value = "Average Response Time (ms)"
    reportSheet.Range("D4").Value = "Error %"
    reportSheet.Range("A4:D4").Font.Bold = True
    
    ' Read the JTL file and populate the report
    Dim line As String
    Dim rowIndex As Integer
    rowIndex = 5
    Do Until jtlFile.AtEndOfStream
        line = jtlFile.ReadLine
        Dim values As Variant
        values = Split(line, ",")
        reportSheet.Cells(rowIndex, 1).Value = values(2)
        reportSheet.Cells(rowIndex, 2).Value = values(1)
        reportSheet.Cells(rowIndex, 3).Value = values(7)
        reportSheet.Cells(rowIndex, 4).Value = values(9)
        If values(9) = "0" Then ' If there are no errors
            reportSheet.Cells(rowIndex, 4).Interior.Color = RGB(198, 239, 206) ' Light green color
        Else
            reportSheet.Cells(rowIndex, 4).Interior.Color = RGB(255, 199, 206) ' Light red color
        End If
        rowIndex = rowIndex + 1
    Loop
    
    ' Format the report
    reportSheet.Columns("A:D").AutoFit
    reportSheet.Range("A5:D" & rowIndex - 1).Borders.LineStyle = xlContinuous
    
    ' Close the JTL file
    jtlFile.Close
    
End Sub

Thats it. Now it can read the JTL file and prepare the reports.

Mobile Performance Testing Checklist


Smartphones & tablets are the reality and a large mass of people are moving to use it for business applications, entertainment, social networking, healthcare applications etc. It’s mandatory for businesses to assess performance of mobile apps before releasing it to public. Responsiveness of mobile apps is one of the big factor for organization to capture the market.

Below are list of things to consider specific to mobile performance testing.
  • Client side considerations 
  • Application performance against different mobile phones in the market? 
  • CPU utilization 
  • Memory utilization 
  • I/O 
  • Cache size availability 
  • Rendering (2D / 3D) 
  • Application performance against different mobile phones & browsers in the market? 
  • JS Engine processing 
  • Number of threads executing the requests 
  • Memory leakage by the application? 
  • Battery consumption by the application? 
  • Internet data usage by the application? 
  • Offline data usage by the application? 
  • Different sizes of images for different mobile phones? 
  • Analyzing waterfall chart for the mobile traffic? 
  • Compressed data 
  • Caching (HTML5 Web Storage) 
  • Less number of round trips 
  • Image size 
  • Consolidating resources? Server side considerations 
  • Analyzing impact on server resources (cpu, memory, i/o) due to slow data transfer rate from server to mobile devices? 
  • Simulating scenarios, when user moving from Wi-fi to 3G, 4G etc? 
  • Simulating scenarios where connections are getting dropped? 
  • Simulating slow sessions and always connected? 
  • Simulating large number of active sessions for a longer time? 
  • Simulating unidirectional server updates? 
  • Simulating large data transfer between server and client? 
  • Static resources being served from CDNs or proxies? 
  • Simulating traffic from different regions / cities? 
  • Simulating different network characteristics? 
  • Latency 
  • Packet Loss 
  • Jitter 
  • Bandwidth (2G, 3G, Wifi, etc.) 
  • Simulating web based application’s scenarios? 
  • Simulating native application’s scenarios? 
  • Simulating hybrid application’s scenarios? 
  • Simulating secure web based application? 
  • Simulating secure native application?

Apache JMeter Tool

The Apache JMeter™ desktop application is open source software, a 100% pure Java 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.

What can I do with it? 

Apache JMeter may be used to test performance both on static and dynamic resources (Files, Web dynamic languages - PHP, Java, ASP.NET, etc. -, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load.
What does it do?

Apache JMeter features include:
  • Ability to load and performance test many different server/protocol types:
  • Web - HTTP, HTTPS
  • SOAP
  • FTP
  • Database via JDBC
  • LDAP
  • Message-oriented middleware (MOM) via JMS
  • Mail - SMTP(S), POP3(S) and IMAP(S)
  • MongoDB (NoSQL)
  • Native commands or shell scripts
  • TCP
  • Complete portability and 100% Java purity .
Full multithreading framework allows concurrent sampling by many threads and simultaneous sampling of different functions by separate thread groups.Careful GUI design allows faster Test Plan building and debugging.
Caching and offline analysis/replaying of test results.

Highly Extensible core:
Pluggable Samplers allow unlimited testing capabilities.Several load statistics may be choosen with pluggable timers .
Data analysis and visualization plugins allow great extensibility as well as personalization.Functions can be used to provide dynamic input to a test or provide data manipulation.Scriptable Samplers (BeanShell, BSF-compatible languages and JSR223-compatible languages)

LOAD DISTRIBUTION IN JMETER TEST PLAN

Distribute concurrent users using following Thread Groups
  1. Ultimate Thread Group
  2. Stepping Thread Group
  3. Throughput Controller
1.) Ultimate Thread Group



infinite number of schedule records
separate ramp-up time, shutdown time, flight time for each schedule record

Let’s configure Ultimate Thread Group as following:



2.) Stepping Thread Group:


preview graph showing estimated load (see example screen below)
initial thread group delay to combine several thread group activities
increase load by portions of threads (users) with ramp-up period
configurable hold time after all threads started
decrease load by portions

Following screenshot shows Stepping Thread Group set to generate load increasing by 10 users each 2 minutes:



3.) Throughput Controller:




The Throughput Controller allows the user to control how often it is executed. There are two modes – percent execution and total executions. Percent executions cause the controller to execute a certain percentage of the iterations through the test plan. Total executions cause the controller to stop executing after a certain number of executions have occurred. Like the Once Only Controller, this setting is reset when a parent Loop Controller restarts.

Load Distribution (Transaction-1)


Load Distribution (Transaction -2)


Load Distribution (Transaction -3)


Load Distribution (Transaction -4)


Load Distribution (Transaction -5)


Sample out

Apache Tomcat Server

Tomcat is an HTTP server. Tomcat is also a servlet container that can execute Java Servlet, and converting JavaServer Pages (JSP) and JavaServerFaces (JSF) to Java Servlet. Tomcat employs a hierarchical and modular architecture as illustrated in the diagram below,

Apache Tomcat is a Java-capable HTTP server, which could execute special Java programs known as Java Servlet and Java Server Pages (JSP). It is the official Reference Implementation (RI) for Java Servlets and JavaServer Pages (JSP) technologies. Tomcat is an open-source project, under the ”Apache Software Foundation” (which also provides the most use, open-source, industrial-strength Apache HTTP Server). The mother site for Tomcat is http://tomcat.apache.org. Alternatively, you can find tomcat via the Apache mother site @ http://www.apache.org.

Tomcat was originally written by James Duncan Davison (then working in Sun), in 1998, based on an earlier Sun’s server called Java Web Server (JWS). It began at version 3.0 after JSWDK 2.1 it replaced. Sun subsequently made Tomcat open-source and gave it to Apache.

Tomcat is an HTTP application runs over TCP/IP. In other words, the Tomcat server runs on a specific TCP port in a specific IP address. The default TCP port number for HTTP protocol is 80, which is used for the productionHTTP server. For test HTTP server, you can choose any unused port number between 1024 and 65535.

Architecture:

Serialization methods used in FLEX Protocol in LoadRunner 11.52

Recording settings

A. Use only a single protocol - FLEX
B. In the recording settings ensure the following options:

1. Use URL based recording mode
2. Under Flex Configuration check the box
– Do not serialize externalizable objects.
3. Set Port mapping as WinInet level.
C. Disable Flex RTMP node (Used during video streaming)

Serialization in Flex scripts
A. UseGraniteDS configuration:

Defines the server side Data Service configuration. If you select this option, do not select Use Flex LCDS/BlazeDS jars to serialize the messages. Ensure that the granit-config.xml file matches the one deployed on the server.

B. Using External Java Serializer:

You can use the Java classes from the Flex server to serialize AMF messages in your script. This process has been simplified

so that you need to include the application JAR files only if the AMF objects implement an externalizable interface.

1. In the Recording Options > Flex > Externalizable Objects node, select Serialize objects using and select Custom Java Classes from the menu.

2. Add the relevant files by using the Add all classes in folder or Add JAR or Zip file buttons. Add the following files:

1. For Adobe BlazeDS or Adobe LCDS, add the following JAR files:

flex-messaging-common.jar

flex-messaging-core.jar

2. Regenerate the script and note any errors. Open the recording options dialog box using the Generation

Options button and add the necessary application JAR files.


3. Ensure that the added files exist in the same location both on the VuGen machine and on all load generators. The Limitations for

the Java Serializer are it Supports JDK versions 1.6 and earlier, Supported servers are Adobe BlazeDS and Adobe Livecycle DS,

Microsoft .NET classesare not supported. During code generation VuGen performs a validity test of the request buffers by

verifying that the buffer can be read and written using the provided jars. Failure in this validity test indicates that

the classes are incompatible with LoadRunner.

C. LoadRunner Serializer:

You can attempt to serialize externalizable objects using the LoadRunner serializer. Ensure that you

have saved all open scripts because this option may result in unexpected errors or invalid steps.