Performance testing with Gatling. Intro/Agenda Performance testing overview Gatling overview Gatling test structure Gatling API Gatling Recorder Gatling.

Slides:



Advertisements
Similar presentations
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Advertisements

Kit Chan ATS Lua Plugin Kit Chan Hi, My name is kit.
An End-User Perspective On Using NatQuery Extraction From two Files T
Snejina Lazarova Senior QA Engineer, Team Lead CRM Team Dimo Mitev Senior QA Engineer, Team Lead SI Team Telerik QA Academy.
Overview. SUMMARY Introduction What is Jmeter ? Why ? Preparing tests Step 1 Proxy server Step 2 Organization Step 3 Genericity Step 4 Assertions Running.
JMeter Workshop Friday 1 December 2006 Anthony Colebourne IT Services The University of Manchester.
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
23 October 2002Emmanuel Ormancey1 Spam Filtering at CERN Emmanuel Ormancey - 23 October 2002.
Simple Web SQLite Manager/Form/Report
Scala Actors -Terrance Dsilva.  Thankfully, Scala offers a reasonable, flexible approach to concurrency  Actors aren’t a concept unique to Scala.
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
Intro To JMeter Christian Desserich Testing a Web-Based Application.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
An Introduction to the Java ME Project Jens A Andersson.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
1 Lab Session-III CSIT-120 Fall 2000 Revising Previous session Data input and output While loop Exercise Limits and Bounds Session III-B (starts on slide.
Copyright ®xSpring Pte Ltd, All rights reserved Versions DateVersionDescriptionAuthor May First version. Modified from Enterprise edition.NBL.
1 Dr Alexiei Dingli Web Science Stream Advanced ROR.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
Introduction to JMeter Anton Nesterov. User profile  Anton Nesterov  QA Engineer at Sitecore  3+ years of experience in testing automation  Skype:
Chapter 8 Cookies And Security JavaScript, Third Edition.
By: Saurabh Dixit.  Groovy server pages  Taglibs  Validators in grails.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Server to Server Communication Redis as an enabler Orion Free
Online Music Store. MSE Project Presentation III
Apache JMeter By Lamiya Qasim. Apache JMeter Tool for load test functional behavior and measure performance. Questions: Does JMeter offers support for.
6 th Annual Focus Users’ Conference 6 th Annual Focus Users’ Conference Import Testing Data Presented by: Adrian Ruiz Presented by: Adrian Ruiz.
Copyright © 2012 UNICOM Systems, Inc. Confidential Information z/Ware Product Overview illustro Systems International A Division of UNICOM Global.
Session 7 Methods Strings Constructors this Inheritance.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1 Looping Dale/Weems/Headington. 2 KA/JS/P Warning l Save your work often! l In the Khan Academy, JavaScript environment, infinite loops will lock up.
CSCI 156: Lab 11 Paging. Our Simple Architecture Logical memory space for a process consists of 16 pages of 4k bytes each. Your program thinks it has.
Mobile Service with.NET By – Sharad Varshney. Agenda What is it supposed to do? Goals Applications System Design Future Work / Enhancements.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
NMD202 Web Scripting Week2. Web site
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Telerik Software Academy Software Quality Assurance.
Performance Testing - LR. 6/18/20162 Contents Why Load Test Your Web Application ? Functional vs. Load Web Testing Web-Based, Multi-Tiered Architecture.
Esri UC 2014 | Technical Workshop | Administering ArcGIS for Server with Python Jon Bodamer.
USING ANDROID WITH THE INTERNET. Slide 2 Lecture Summary Getting network permissions Working with the HTTP protocol Sending HTTP requests Getting results.
What’s Really Happening
Application program interface (API)
Simulating back-end services
Selenium HP Web Test Tool Training
CS 330 Class 7 Comments on Exam Programming plan for today:
How to link a test to a launcher (in this case a shell launcher)
Node.js Express Web Applications
z/Ware 2.0 Technical Overview
Understanding SOAP and REST calls The types of web service requests
1) CB plugin for Jenkins 2) Requirements Mapping
Node.js Express Web Services
In-situ Visualization using VisIt
Functions CIS 40 – Introduction to Programming in Python
Course Name: QTP Trainer: Laxmi Duration: 25 Hrs Session: Daily 1 Hr.
Testing REST IPA using POSTMAN
Customizing the Social Workload
12 Asynchronous Programming
Optimize Your Java Code By Tools
Abel Sanchez, John R. Williams
Testing RESTful Web APIs
EE 122: HyperText Transfer Protocol (HTTP)
Chengyu Sun California State University, Los Angeles
Chapter 5: Control Structures II (Repetition)
Introduction to Computer Science
TN19-TCI: Integration and API management using TIBCO Cloud™ Integration
Performance/Load/Stress Testing
Presentation transcript:

Performance testing with Gatling

Intro/Agenda Performance testing overview Gatling overview Gatling test structure Gatling API Gatling Recorder Gatling DSL Gatling reports

Performance testing

Measure response time under workload Load, Stress, Soak, Spike testing Find bottlenecks Satisfy impatient customers Increase conversion rate Sustain company reputation

Approach 1.Set proper goals 2.Choose tools 3.Try the tools 4.Implement scenarios 5.Prepare environments 6.Run and measure

Gatling overview

Firepower Gatling

Thousands of concurrent users Users are not threads, but actors Asynchronous concurrency Scala Akka Netty Recorder (HTTP Proxy and HAR) Extensions (Maven, Gradle, Jenkins)

1 thread = 1 user * *

Blocking I/O * *

Actors Model Mathematical model used in parallel computing Actor is autonomous computational unit No shared resources, no shared state Asynchronous message passing Mailbox to buffer incoming messages React on received messages

Gatling test structure

Building blocks

Gatling API

val myHttpGetRequest = http("Open home page").get("/home") HTTP GET Request Define constant variable Variable name Create HTTP Request object Request name Method of HTTP Request object Request URI

val myHttpProtocol = http.baseURL(" HTTP Protocol Create HTTP Protocol object URL is prepended to any HTTP request Application URL

val myScenario = scenario("Browse Home").exec(myHttpGetRequest).pause(2).exec(myReq2) Scenario Create Scenario object Scenario name Execute HTTP Request Already created HTTP Request object Pause time in seconds Pause between requests Execute more HTTP Requests

setUp(myScenario.inject(atOnceUsers(10))).protocols(myHttpProtocol) setUp Gatling Simulation base method Scenario object method Number of users Already created HTTP Protocol object Already created Scenario object Injection profile Configure protocol

import io.gatling.core.Predef._ import io.gatling.http.Predef._ class MySimulation extends Simulation { } Simulation class Gatling base simulation class Import Gatling API classes Simulation class name

Gatling simulation import io.gatling.core.Predef._ import io.gatling.http.Predef._ class MySimulation extends Simulation { val myHttpProtocol = http.baseURL(" val myHttpGetRequest = http("Open home page").get("/home") val myLoginRequest = http("Open login page").get("/login") val myScenario = scenario("Browse Home").exec(myHttpGetRequest).pause(2).exec(myLoginRequest) setUp(myScenario.inject(atOnceUsers(10))).protocols(myHttpProtocol) }

Gatling Recorder

Recorded simulation import io.gatling.core.Predef._ import io.gatling.http.Predef._ class RecordedSimulation extends Simulation { val httpProtocol = http.baseURL(" val scn = scenario("RecordedSimulation").exec(http("request_0").get("/products")).pause(5).exec(http("request_1").get("/products?q=SearchString")) setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol) }

Gatling DSL Domain Specific Language

Gatling DSL Feeders csv, ssv, tsv, jsonFile, jsonUrl, jdbcFeeder queue, random, circular Checks responseTimeInMillis, latencyInMillis, status, currentLocation header, headerRegex bodyString, bodyBytes, regex, xpath, jsonPath, css Check actions find, findAll, count, saveAs is, not, exits, notExists, in, optional

Gatling DSL (2) Execution control doIf, doIfOrElse, doSwitch, doSwitchOrElse, randomSwitch repeat, foreach, during, asLongAs, forever tryMax, exitBlockOnFail, exitHereIfFailed Assertions responseTime, allRequests, requestsPerSec min, max, mean, stdDev, percentile1, percentile2 lessThan, greaterThan, between, is, in, assert Injection profiles nothingFor, atOnceUsers, rampUsers over, rampUsers during

Session A virtual user’s state stores all simulation user’s data Map[String, Any] Write data using Feeders extract and save from response programmatically with Session API Read data using Gatling Expression Language programmatically with Session API

Gatling reports

STIONS ? ANY

Thank you! Lyudmil Latinov Senior Automation QA Xoomworks Bulgaria Blog: AutomationRhapsody.comAutomationRhapsody.com

Bonus slides Offline bonus slides

private val csvFeeder = csv("search_terms.csv").circular.random CSV Feeder Access modifier Read CSV file CSV file name Start over once file is read CSV file content First line is header, used as session variable name search_term prod product1 hello searchTerm1 hello hellosearch_terms.csv Access in random order

val scn = scenario("Search products").feed(csvFeeder).forever() { exec(http("Search product").get("/products?q=${search_term}")) } Use CSV Feeder Add Feeder to Scenario object Already created CSV Feeder object Iterate scenario forever Execute HTTP Requests in body HTTP GET Request Access CSV data by header with Gatling EL

val reqSavePerson = http("Save Person").post("/person/save").body(ElFileBody("person.json")).header("Content-Type", "application/json") HTTP POST Request Create HTTP Post Request object Request URI { "id": "${id}", "firstName": "${first_name}", "lastName": "${last_name}", " ": "${ }" }person.json Add header field Add body to HTTP Post request Read body file and parse with Gatling EL File name Gatling EL parser replaces session variables

val myProtocol = http.baseURL(" val myRequest = http("Home").get("/home").check(regex("Hello, (*.?) (*.?)!")) Checks Checks can be defined on HTTP Protocol level Add check to HTTP Protocol object Response code is 200 OK Usually check are defined on HTTP Request level Add check to HTTP Request object Response body matches regular expression

val reqSearch = http("Search product").get("/products?q=${search_term}").check(regex("Found ([\\d]{1,4}) products:").saveAs("numberOfProducts")) Save to Session HTTP GET Request Access session data with Gatling EL Check response body matches specific regex Save regular expression matched group Name of session variable to save to

val reqOpenProduct = exec(session => { var prds = session("numberOfProducts").as[String].toInt var productId = Random.nextInt(prds) + 1 session.set("productId", productId) }).exec(http("Open").get("/products?id=${productId}")) Manage Session variables Access Session objectinside exec block with lambda Some test logic Execute HTTP Get request Variable is accessible only on second exec block Create and return new Session object with variable saved in it Read variable from Session object as String and convert to Integer

val scnLogoutOrHome = scenario("Logout Or Home").doIfEqualsOrElse("${action}", "Logout") { exec(http("Do logout").get("/logout")) } { exec(http("Home page").get("/home")) } Conditional execution Conditions are calculated on Scenario object If Session variable equals given value Execute Requests chain in case of FALSE Execute Requests chain in case of TRUE

setUp(scnSearch.inject(rampUsers(10) over 10.seconds), scnOpenProduct.inject(atOnceUsers(10))).protocols(myProtocol).maxDuration(10.minutes).assertions( global.responseTime.max.lessThan(800), global.successfulRequests.percent.greaterThan(99) ) Advanced setUp Maximum duration in case of forever() Assert each response time is bellow 800ms Different scenarios with different injection profiles Assert 99% success responses for the Simulation