Skip to content

Instantly share code, notes, and snippets.

@dy-dx
Created November 22, 2017 17:31
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dy-dx/665dc94846865f9f11e5886581c494db to your computer and use it in GitHub Desktop.
import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
class LoggedOutSimulation extends Simulation {
val httpProtocol = http
.baseURL(sys.env.getOrElse("BASE_URL", "http://localhost:8084"))
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.8,ja;q=0.6,bg;q=0.4")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
.disableCaching
val headers_0 = Map(
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Upgrade-Insecure-Requests" -> "1")
val headers_1 = Map(
"accept" -> "application/json",
"x-requested-with" -> "XMLHttpRequest")
val scn = scenario("LoggedOutSimulation")
.exec(http("Home")
.get("/")
.headers(headers_0)
.resources(http("api/index")
.get("/api/index")
.headers(headers_1)))
.pause(1)
.exec(http("Search")
.get("/Search/")
.headers(headers_0)
.resources(http("api/index")
.get("/api/index")
.headers(headers_1)))
setUp(scn.inject(rampUsersPerSec(1) to(5) during(50 seconds)))
.protocols(httpProtocol.shareConnections)
.maxDuration(120 seconds)
.assertions(
global.failedRequests.count.is(0),
global.responseTime.percentile3.lt(30000)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment