Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2014 11:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e1ba8c4f508f25c8255e to your computer and use it in GitHub Desktop.
Save anonymous/e1ba8c4f508f25c8255e to your computer and use it in GitHub Desktop.
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class BasicSimulation extends Simulation {
val passwords = csv("passwords.csv")
def setPassNum = exec(session =>
session.set("passwordNumber", "3"))
val passwordsByNumber: Map[Int, String] =
passwords.records.map(record =>
record("passNum").toInt -> record("passVal")).toMap
def findPassword =
exec(session => session("passwordNumber")
.validate[Int]
.map(number =>
session.set("password", passwordsByNumber(number))))
val httpConf = http
.baseURL("http://google.com") // Here is the root for all relative URLs
val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses
.exec(http("request_1")
.get("/"))
.exec(setPassNum)
.exec(findPassword)
.exec((session: Session) => {
println(session.get("counter"))
session
})
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment