Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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