All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.snice.gatling.simulations.BasicSimulation.scala Maven / Gradle / Ivy

There is a newer version: 0.0.4
Show newest version
package io.snice.gatling.simulations

import io.gatling.core.Predef._
import io.gatling.http.Predef._

import scala.concurrent.duration._

class BasicSimulation extends Simulation {

  val httpProtocol = http
    .baseUrl("http://computer-database.gatling.io") // 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
    .disableWarmUp
    .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 scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses
    .exec(
    http("request_1")
      .get("/")
        .check(status.is(300))
  )
    .pause(7) // Note that Gatling has recorded real time pauses
    .exec(
    http("request_2")
      .get("/computers?f=macbook")
  )
    .pause(2)
    .exec(
      http("request_3")
        .get("/computers/6")
    )
    .pause(3)
    .exec(
      http("request_4")
        .get("/")
    )
    .pause(2)
    .exec(
      http("request_5")
        .get("/computers?p=1")
    )
    .pause(670.milliseconds)
    .exec(
      http("request_6")
        .get("/computers?p=2")
    )
    .pause(629.milliseconds)
    .exec(
      http("request_7")
        .get("/computers?p=3")
    )
    .pause(734.milliseconds)
    .exec(
      http("request_8")
        .get("/computers?p=4")
    )
    .pause(5)
    .exec(
      http("request_9")
        .get("/computers/new")
    )
    .pause(1)
    .exec(
      http("request_10") // Here's an example of a POST request
        .post("/computers")
        .formParam("name", "Beautiful Computer") // Note the triple double quotes: used in Scala for protecting a whole chain of characters (no need for backslash)
        .formParam("introduced", "2012-05-30")
        .formParam("discontinued", "")
        .formParam("company", "37")
    )

  setUp(scn.inject(atOnceUsers(3)).protocols(httpProtocol))

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy