Sai Matam and

Jagdeep Jain

Pro Apache JMeter

Web Application Performance Testing

Sai Matam

Pleasonton, California, USA

Jagdeep Jain

Dewas, Madhya Pradesh, India

Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-2960-6 . For more detailed information, please visit http://www.apress.com/source-code .

ISBN 978-1-4842-2960-6

e-ISBN 978-1-4842-2961-3

https://doi.org/10.1007/978-1-4842-2961-3

Library of Congress Control Number: 2017951240

© Sai Matam and Jagdeep Jain 2017

This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.

Printed on acid-free paper

Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

I dedicate this book to my wife, Jyothi, for inspiration, support, and for single-handedly running around kids and various chores while I tapped at the keyboard.

—Sai Matam

I dedicate this book to my parents, who always motivated me to do things differently, and to my sisters and my wife; without their support, I would not be able to manage a tight schedule on and off work.

—Jagdeep Jain

Introduction

This book is intended to get beginners up and running with performance testing using JMeter. This book provides step-by-step guidance and covers advanced topics for the experienced engineer. Each chapter is clearly marked with the topics it covers, thereby allowing the reader to skip chapters if appropriate.

Chapter 1 is the foundation of the book where we discuss why performance testing is needed and why we should user JMeter.

Chapter 2 is general-purpose chapter that covers the performance testing methodology.

Chapters 3 through 5 cover specific topics in JMeter (test plan, thread group, pre-processors, controller, timers, sampler, assertions, listeners, post-processors, properties, and variables). By going through these chapters, you will gain an understanding on how to user JMeter for your performance needs.

Chapters 6 through 10 deal with distributed testing, a few advance concepts of JMeter, and troubleshooting tips that will be useful in some projects.

Chapter 11 contains the case study of a sample web application called Digital Toys Inc. This chapter contains everything that a performance testing engineer needs to start performance testing a project.

Chapter 12 shows you how to generate a performance dashboard while executing test scripts.

Chapters 13 and 14 help in setting up JMeter and sample web applications to run the test scripts.

Architects, engineers, and quality assurance professionals will greatly benefit by reading this book. Project managers or other non-technical team members may want to glance through the book and read Chapter 2 , “Performance Testing Primer,” to gain some understanding on performance testing in general.

We have developed an e-commerce web application for a hypothetical company called Digital Toys Inc., for the express purpose of illustrating the example test scripts in this book. Chapter 14 explains how to set up this sample application.

Test scripts developed in this book are hosted on GitHub. Any source code or other supplementary material referenced by the authors in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-2960-6 . For more detailed information, visit http://www.apress.com/source-code .

For any quires or valuable feedback, feel free to get in touch with authors over e-mail:

Sai Matam at [email protected] .

Jagdeep Jain at [email protected] .

Acknowledgments

We want to thank the following people who have helped us make sure that the book is useful by providing timely feedback on our chapters, testing JMeter scripts, and finding bugs in our sample web application. Without them, it would have been tough to create a good quality book.

Ai Yu, Alap Shah, Amit Devgan, Anand Sinha, Anil Ramesh Malleboyina, Anil Wadghule, Beejal Vibhakar, Belal Ansari, Bhushan Gupta, Chakradhar Kommera, Charan Das Thota, David Livingstone Gangarapu, Deepa Mahendraker, Dheeraj Sah, Etender Naini, Ganesh Somaka, Gomtesh Gandhi, Govardhan Aliseri, Haridev Vengateri, Harshad Savot, Harshvardhan Vipat, Hemanth Presingu, Mangesh Lunawat, Manjula Gundugollu, Manjula Kavadi, Manohar Gone, Nikhil Agrawal, Nitish Shirsath, Pankaj Saraf, Piyush Singh, Prashanth Abbagani, Prasoon Kumar, Raj Gopal Marripalli, Rama Gangadhar Mekala, Ram Katru, Roshan Iqbal, Ruth Rajitha Gangarapu, Sanjeev Kumar, Satish Salandri, Satyapal Reddy Panyala, Sharon Annese, Shravan Goli, Shyam Palleti, Shyam Palreddy, Sridhar Throvagunta, Srikanth Ganapavarapu, Srinivas Nagandla, Srinivas Reddy Gaddam, Sudeep Tripathy, Suneeta Donepudi, Sunil Kumar, Sunil Potti, Swamy Das, Tapan Upadhyay, Tarak Joshi, Vidhut Singh, Vijay Pasupuleti, Yogesh Sharma and Yogesh Yadhav.

We are very thankful to the editorial team at Apress and the technical reviewer for having various checkpoints in place and providing us with useful feedback in a timely manner, all of which have made this book more useful for readers.

Contents

  1. Chapter 1:​ Foundation
    1. Why Performance Testing?​
    2. Why JMeter?​
  2. Chapter 2:​ Performance Testing Primer
    1. Performance Testing
      1. Response Time
      2. Throughput
      3. Utilization
      4. Robustness
      5. Scalability
      6. User Perception
      7. Cost
    2. Types of Performance Tests
      1. Stress Tests
      2. Load Tests
      3. Peak Load Tests
      4. Soak Tests or Endurance Tests
      5. Scalability Tests
      6. Capacity Tests
      7. Spike Tests and Burst Capacity
      8. Performance Smoke Tests
      9. High Availability Test/​Fail-Over Tests
    3. The Performance Test Environment
      1. The Need for Separate Performance Environment
      2. The Performance Environment Should Be Like the Production Environment
      3. The Performance Environment Should Be Isolated
      4. Performance Testing Tools
    4. The Performance Testing Strategy Document
      1. Performance Requirements
      2. Performance Goals
      3. Performance Test Suite
      4. Performance Reporting and Analysis
      5. Performance Tuning
    5. Conclusion
  3. Chapter 3:​ Your First JMeter Test
    1. Components of a JMeter Test
      1. Test Plan
      2. Thread Group
      3. Controller
      4. Sampler
      5. Listener
      6. Timer
      7. Assertions
      8. Config Element
      9. Pre-Processors
      10. Post-Processors
    2. Order of Component Execution
    3. Simple JMeter Test
    4. GUI Mode
    5. Non-GUI Mode
      1. Executing a Single Test
      2. Proxy Server Setting
      3. Start JMeter in Server Mode
      4. Stop/​Shutdown JMeter
    6. Conclusion
  4. Chapter 4:​ JMeter Test Script Recorder
    1. JMeter WorkBench
    2. JMeter Recording Controller
    3. Browser Proxy Settings
    4. Recording Example
    5. Conclusion
  5. Chapter 5:​ JMeter Test Plan Components
    1. Test Plan
      1. Configuration
      2. Serial Execution of Thread Groups
      3. Parallel Execution of Thread Groups
      4. User Defined Variables
    2. Thread Group
      1. Thread Properties
      2. Scheduler
      3. Action After Sampler Error
    3. Pre-Processors
      1. HTTP URL Re-Writing Modifier
    4. Controller
      1. Simple Controller
      2. Transaction Controller
      3. Loop Controller
      4. Runtime Controller
      5. Throughput Controller
      6. Once Only Controller
      7. Interleave Controller
      8. Random Controller
      9. Random Order Controller
      10. Switch Controller
      11. ForEach Controller
      12. If Controller
    5. Timers
      1. Constant Timer
      2. Gaussian Random Timer
      3. Uniform Random Timer
      4. Constant Throughput Timer
      5. Synchronizing Timer
    6. Sampler
      1. HTTP Request
    7. Assertions
      1. Response Assertion
    8. Listener
      1. View Results Tree
      2. View Results In Table
      3. Aggregate Report
    9. Post-Processors
      1. Regular Expression Extractor
    10. Properties and Variables
      1. Comparison of Properties and Variables
      2. User Defined Variables
      3. Using the Command Line to Initialize Properties
    11. Conclusion
  6. Chapter 6:​ Distributed Testing
    1. Distributed Testing Using JMeter
    2. Prerequisites
    3. Configuration
    4. Running the Test
    5. GUI Mode
    6. Non-GUI Mode
    7. RMI Port
    8. Sample Sender Mode
    9. Unreachable Remote Hosts
    10. Limitations
    11. Conclusion
  7. Chapter 7:​ JMeter Best Practices
    1. HTTP Request Defaults
    2. Follow Redirects
    3. Cookie Manager
    4. Cache Manager
    5. JMeter Using Maven
    6. Passing Variables Across Thread Groups
    7. Running Parallel Thread Groups
    8. Using External File for Parameterizing User Login
    9. Customizing Properties
    10. Monitor JMeter Resource Usage
    11. Standard Test Plan Templates
    12. Conclusion
  8. Chapter 8:​ Troubleshooting JMeter
    1. Ensure Permissions
    2. Log File
    3. Log Level
    4. HTTP Protocol Logs
    5. GUI Logs
    6. Clear GUI Logs
    7. Remote Host Exception
    8. Connect Exception
    9. Solving Proxy Servers Problems
    10. HTTP Basic Authentication
    11. Using HTTP Header Manager
    12. Using the HTTP Authorization Manager
    13. Debug Test Faster
    14. Out of Memory Error
    15. Conclusion
  9. Chapter 9:​ JMeter Plugins
    1. PerfMon
      1. Download the Plugin
      2. Start the PerfMon Agent
      3. Non-GUI Mode
    2. Conclusion
  10. Chapter 10:​ JMeter Recipes
    1. JDBC Performance Testing
      1. Install MySQL
      2. Install JDBC Driver
      3. JDBC Test Plan
    2. FTP Performance Testing
    3. REST/​JSON Performance Testing
    4. AJAX Performance Testing
    5. Mobile Performance Testing
      1. Simulating Mobile Devices
      2. Simulating Network Speed
      3. JMeter to Record User Actions
    6. SOAP Performance Testing
      1. Install SOAPUI
    7. Conclusion
  11. Chapter 11:​ Case Study:​ Digital Toys Inc.​
    1. The Need for Speed
    2. Addressing the Problem
      1. Performance Goals
      2. Performance Test Specification
      3. Tool Selection
      4. Test Environment
      5. Test Data Preparation
      6. User Load Pattern
      7. Application Build
    3. Using JMeter
      1. Test Script Development
      2. Validation of Test Steps
      3. Passing Variables Between Samplers
      4. Running Tests with Multiple Users
      5. Implementing Actual User Behavior
      6. Results Metrics
    4. Organizing Tests
    5. Combining Multiple Tests
    6. Questions
    7. Using Distributed Environment
    8. Performance Testing and Tuning Cycle
    9. Outcome
    10. Conclusion
  12. Chapter 12:​ Performance Dashboard
    1. APDEX
    2. Configuration
      1. JMeter Properties
      2. APDEX
      3. Global Graph Properties
      4. Specific Graph Properties
    3. Generating Graphs
    4. Performance Dashboard Graphs
    5. Conclusion
  13. Chapter 13:​ Appendix A:​ Setting Up JMeter
    1. MacOSX
      1. Download JDK
      2. Install JDK
      3. Set Up the Environment Variable
      4. Download JMeter
      5. Set Up JMeter
    2. Windows
      1. Download JDK
      2. Install JDK
      3. Set Up the Environment Variable
      4. Download JMeter
      5. Set Up JMeter
    3. Linux
      1. Install JDK
      2. Set Up the Environment Variable
      3. Download JMeter
      4. Set Up JMeter
  14. Chapter 14:​ Appendix B:​ Setting Up Digital Toys Inc.​
    1. Running Digital Toys Web Application
      1. Start the Web Application
      2. Start with URL Rewriting Enabled
      3. Clean Up
  15. Index

About the Authors and About the Technical Reviewer

About the Authors

A449582_1_En_BookFrontmatter_Figc_HTML.jpg

Sai Matam has more than 20 years of diverse experience in software development, including significant experience in performance testing and tuning. He has worked on tuning Java and web applications with many millions of page visits.

A449582_1_En_BookFrontmatter_Figb_HTML.jpg

Jagdeep Jain has more than a decade of experience in software quality assurance and testing. He holds a degree in Computer Science and Engineering. He is a firm believer and advocate of test automation, and he has used Apache JMeter extensively.

About the Technical Reviewer

A449582_1_En_BookFrontmatter_Figd_HTML.jpg

Nitesh Kumar Jain has over a decade of experience in the software testing world. He has an M.Tech in Information technology from IIITM Gwalior and a B.E. in Computer Science and Engineering. He is a keen technology learner with an “let’s automate everything” attitude. He is also an ISTQB certified test manager, technical test analyst, test analyst, and Agile test engineer and loves to make Java-Swing based tools that can help with software testing. He also spent five years on performance testing and test automation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.228.99