Skip to content

Instantly share code, notes, and snippets.

@arikogan
Created October 21, 2013 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arikogan/7084579 to your computer and use it in GitHub Desktop.
Save arikogan/7084579 to your computer and use it in GitHub Desktop.
import io.gatling.http.Predef._
import io.gatling.core.Predef._
import scala.concurrent.forkjoin.ThreadLocalRandom
import io.gatling.core.validation.Success
import bootstrap._
class Gist extends Simulation {
val baseURL = "http://localhost:8080"
val httpConf = http
.baseURL(baseURL)
.disableFollowRedirect
val data: Array[Map[String, String]] = csv("ids.csv").data // get the underlying array
val feedIds = (session: Session) => {
val random = ThreadLocalRandom.current
val ids = (0 to (random.nextInt(10) + 1)).map(n => data(n)("id").toSet.mkString(","))
println("ids = " + ids)
new Success(session.set("ids", ids))
}
val scn = scenario("Retrieve IDs")
exec(feedIds)
.exec(http("request_1").get("?ids=${ids}").check(status.is(200)))
setUp(scn.inject(ramp(10) over 10))
.protocols(httpConf)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment