Tuesday, August 11, 2015

Gatling : Things to know to work with Gatling

Virtual User : Some load testing tools can’t deal with logic between requests but Gatling can deal with virtual users, each one having its own data and maybe taking a distinct browsing path.

Some tools implement those virtual users as threads but Gatling implements them as messages that scales much better and can deal easily with thousands of concurrent users.

Scenario : Gatling represents user’s behavior as scenario which is written as scripts following Scala syntax. Creation of the scenarios is very important as it is the key to meaningful results of the load test.
So it should be designed in such a way that represent true users behavior. Virtual users will follow the scenario that represents a typical user behavior.

For example, a standard search application scenario could be:

  1. Open the Browser and go to the site : http://www.bing.com/
  2. Enter the text “Gatling” at search text box
  3. Click Search button and Gatling related page with link is displayed
  4. Click on the link text “Gatling - Official Site”

Scenarios are represented as scripts in conjunction with a DSL (Domain Specific Language). This allows fast writing of scenarios and easy maintenance of existing scenarios.

If we want to write the above scenario using DSL then,

  scenario("GatlingSearch")
  .exec(http("Go to Bing Site").get("http://www.bing.com/")
  .pause(10)
  .exec(http("Search with the word 'Gatling'").get("http://www.bing.com/search?q=Gatling")
  .pause(30)
   .exec(http("Click in the link Gatling - Official Site").get("http://gatling.io/#/")
  .pause(10)

Note in this scenario, “GatlingSearch” is the scenario name, contains 3 HTTP Requests and 3 pauses.
Pauses are used to simulate user think time. HTTP requests are actually sent to the application under test when a user clicks on a button or a link.

Simulation : Simulation defines how many users will perform the scenario. There may be different types of users and their numbers are different for different scenario. It also defines on how virtual users will be injected. All the users execute the scenario at a time or ramp up in a certain time period.

For example,

val standardUser= scenario("Scenario X")
val adminUser= scenario("Scenario Y")
val advancedUser= scenario("Scenario Z")

setUp(
  standardUser.inject(atOnceUsers(2000)),
  adminUser.inject(nothingFor(60 seconds), rampUsers(5) over (400 seconds)),
  advancedUser.inject(rampUsers(500) over (200 seconds))
)

Session : Each virtual user is backed by a Session that is basically a state placeholder, where testers can inject or capture and store data.

Feeders : Feeders are API for testers to provide test data from an external source into the virtual users’ sessions since Gatling doesn’t provide any tools to generate test data.

Checks : Gatling analyze and verifies the response using Check which is a response processor that captures some part of response and verifies that it meets some given condition(s). It can also be used to capture some elements and store them into the Session so that they can be reused later.

Assertions : Assertions are used to define acceptance criteria on Gatling statistics that would make Gatling fail and return an error status code for the test as a whole.

Reports : Reports are automatically generated by default at the end of a simulation. They consist of HTML files that are portable and can be viewed on any device with a web browser.

We will discuss more on everything on our future post.

Happy Load testing using Gatling!!!

Tuesday, August 4, 2015

Gatling : What is Gatling?

Gatling is an open source performance testing tool. It is a framework based on Scala, Akka and Netty. It is a high performance tool and it provides user friendly html reports. Script is easy to maintain and customize. It has recorder and developer friendly DSL.

Gatling is a highly capable load testing tool designed for ease of use, maintainability and high performance. Gatling has excellent support of the HTTP protocol. Beside that it supports other protocol.

In Gatling, a simple scenario is recorded for load testing an http server. Scenarios are defined in code using DSL and are resource efficient, can be maintained easily and kept in version control system.

Gatling’s architecture is asynchronous. Virtual users are implemented as messages instead of dedicated threads. It makes them very resource cheap. Thus, running thousands of concurrent virtual users is not an issue in Gatling.

Four Basic steps to complete Gatling :

  • Record : You can record any activities of your web application using Gatling. It can record from any browser and any activities even the think time.
  • Edit : Recorded script can be customized and edited easily as it is easy to read and developer friendly.
  • Launch : It can be launch through windows command prompt or Linux terminal. It can run through Maven build or Jenkins.
  • Analyze : Gatling provides some clear, exhaustive, dynamic and colorful reports and they are HTML format. Report can be Zoom in and zoom out. From the report it can be easily pointed out performance issues.

Things to do using Gatling :

  • Gatling’s scenario can be distributed and reused.
  • Different virtual user’s can be configured with different ramp up time.
  • Gatling’s scenario can be data driven using CSV files.
  • It can verify response data using check feature.
  • It can repeat the same request using loop.
  • It can manage check and failure.

In our future post we will discuss more about Gatling.

Happy Load testing using Gatling!!!

Cypress: How to handle browser-based authentication pop up dialog in Cypress

Five years ago I have written a blog on how to handle browser-based authentication for selenium webdriver.   Now it is for cypress. Cypress...