package carms
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class BasicSimulation extends Simulation {
val users = csv("users.csv").random
val httpConf = http
.baseURL("
http://carms") // 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("Login and book") // A scenario is a chain of requests and pauses
.exec( http("getlogin").get("/login") )
.pause(3)
.feed(users)
.exec(
http("postlogin")
.post("/login_check")
.headers(headers_10)
.formParam("_username","${email}")
.formParam("_password","${password}")
.check(regex("""<h1>Interview Booking</h1>"""))
)
.exec( http("get interview times").get("/booking/interview-times") )
.pause(1)
.exec(
http("post interview times") // Here's an example of a POST request
.post("/booking/interview-times")
.headers(headers_10)
.formParam("slot_booking[attendingCarmSocial]", 0) // Note the triple double quotes: used in Scala for protecting a whole chain of characters (no need for backslash)
.formParam("slot_booking[block]", 12)
)
setUp(scn.inject(atOnceUsers(9)).protocols(httpConf))
}