Friday, October 14, 2016

gatling stress tests

http://gatling.io/

Download Url  bundle Gatling :
https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.2.2/gatling-charts-highcharts-bundle-2.2.2-bundle.zip

Scala IDE for Eclipse:
http://scala-ide.org/download/sdk.html


Typical class (where title column in the csv is "Keyword"):

package com.toto.backend.scenarios.ww

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import io.gatling.http.protocol.HttpProtocolBuilder.toHttpProtocol
import io.gatling.http.request.builder.HttpRequestBuilder.toActionBuilder

class WWBasicScenario extends Simulation {
  val ts = csv("ww/kw_utf_1M.csv").random

  val httpConf = http
    .baseURL("http://bench.preprod.toto.com:8080") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .doNotTrackHeader("1")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val headers_10 = Map("Content-Type" -> "application/x-www-form-urlencoded") // Note the headers specific to a given request

    val scn = scenario("Serve random kw")
    .feed(ts)
    .exec(
      http("...")
        .get("/ww/api/1.0/offer/search/lang/fr/site-id/1?words=${Keyword}&rows=5&fac_cat=true")
        .check(status.is(200)))

     setUp(scn.inject(constantUsersPerSec(50) during(6 hours)).protocols(httpConf))}

No comments: