Giter Site home page Giter Site logo

app-perf-tests's Introduction

Performance Tests using Gatling

This repository contains the full required setup to write the performance tests for the web application using Gatling.

Gatling

Gatling is an open-source load and performance testing framework based on Scala, Akka and Netty.

Gatling is a powerful tool, you can simulate hundreds of thousands of requests per second on your web application and get high-precision metrics.

At the end of your test, Gatling automatically generates an exhaustive, dynamic and colorful report. That provides the clear and detailed analysis of running scripts.

Implement your first simulation

Step 1: Implement the requests to your pages

import performance.conf.ServicesConfiguration import io.gatling.core.Predef._ import io.gatling.http.Predef._

object HelloWorldRequests extends ServicesConfiguration {

val baseUrl = baseUrl("hello-world-frontend")

def navigateToLoginPage = http("Navigate to Login Page") .get(s"$baseUrl/login") .check(status.is(200))

def submitLogin = { http("Submit username and password") .post(s"$baseUrl/login": String) .formParam("userId", "${username}") .formParam("password", "${password}") .check(status.is(303)) .check(header("Location").is("/home")) }

def navigateToHome = http("Navigate To Home") .get(s"$baseUrl/home") .check(status.is(200))

}

Step 2: Setup the simulation

import performance.simulation.ConfigurationDrivenSimulations import HelloWorldRequests._

class HelloWorldSimulation extends ConfigurationDrivenSimulations {

setup("login", "Login") withRequests (navigateToLoginPage, submitLogin)

setup("home", "Go to the homepage") withRequests navigateToHome

runSimulation() }

Step 3. Configure the journeys journeys.conf

journeys {

hello-world-1 = { description = "Hello world journey 1" load = 9.1 feeder = data/helloworld.csv parts = [ login, home ] }

hello-world-2 = { description = "Hello world journey 2" load = 6.2 feeder = data/helloworld.csv parts = [ login ] }

}

Step 4. Configure the tests application.conf

runLocal = true

baseUrl = "http://helloworld-service.co.uk"

perftest { rampupTime = 1 constantRateTime = 5 rampdownTime = 1 loadPercentage = 100 journeysToRun = [ hello-world-1, hello-world-2 ], labels = "label-A, label-B" #optional percentageFailureThreshold = 5

}

} Step 4. Configure the user feeder helloworld.csv

username,password person1, 123 person2, 567

Local Smoke test

Make sure 'runSmokeTest = true' in application.conf. Then run this command : sbt gatling:test

Local Run of the full performance test

Make sure 'runSmokeTest = false' in application.conf. Then run this command : sbt gatling:test

More about the journey configuration.

description will be assigned to the journey in the test report

load is the number of journeys that will be started every second

feeder is the relative path to the csv feeder file. More here

parts is the list of parts that combined create your journey

You can have as many journeys as you like in journeys.conf, the simulation will start and run them all together.

More about the services configuration.

Contains the name of the service and the port when running locally. Read the services-local.conf file for more details and examples.

More about application.conf

runLocal boolean value to run test locally. Default value is true.

baseUrl is the default url for every service. Read the application.conf file for more details and examples.

rampupTime is the time in minutes for the simulation to inject the users with a linear ramp up

constantRateTime is the time in minutes for the simulation to inject users at a constant rate

rampdownTime is the time in minutes for the simulation to inject the users with a linear ramp down

loadPercentage is the percentage of the load for the journeys. Read the application.conf file for more details and examples.

journeysToRun contains the journeys that will be executed. Leave it empty if you want to run all the journeys

labels optional string containing a comma-separated list of test labels. Read the application.conf file for more details.

percentageFailureThreshold optional int. Read the application.conf file for more details.

app-perf-tests's People

Contributors

anujakhare avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.