Skip to content

Instantly share code, notes, and snippets.

@chillenious
Last active October 22, 2015 19:56
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 chillenious/57220a17be99aeeffce4 to your computer and use it in GitHub Desktop.
Save chillenious/57220a17be99aeeffce4 to your computer and use it in GitHub Desktop.
Gatling.io test case
package api
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class AuthenticatedMediaSimulation extends Simulation {
val users = csv("users.csv").random
val httpConf = http
.baseURL("https://library-test.biblioboard.com/ext/api")
val scn = scenario("AuthenticatedMediaSimulation")
.exec(
http("Authenticate")
.post("https://auth-test.biblioboard.com/users/${account}/authentication") // different server, so hard coded
.body(StringBody("""{"password" : "${pwd}"}"""))
.asJSON
.check(status.is(200))
.check(jsonPath("$..token").find.saveAs("token"))
.check(jsonPath("$..userId").find.saveAs("userId"))
)
.exec(
http("FeaturedModules1")
.get("/users/${userId}/modules/featured?limit=4&offset=0")
.header("X-Auth-Token", "${token}")
.check(status.is(200))
)
.exec(
http("Modules1")
.get("/users/${userId}/modules/8c0e3213-cee4-464f-90d1-799cf75fcd36")
.header("X-Auth-Token", "${token}")
.check(status.is(200))
)
.exec(
http("ModuleAnthologies1")
.get("/users/${userId}/modules/8c0e3213-cee4-464f-90d1-799cf75fcd36/anthologies?limit=all&sort=name")
.header("X-Auth-Token", "${token}")
.check(status.is(200))
)
.exec(
http("Anthologies1")
.get("/users/${userId}/anthologies/979c1f8b-c5aa-42bb-8669-e825f4c24529")
.header("X-Auth-Token", "${token}")
.check(status.is(200))
)
.exec(
http("AnthologiesCollections1")
.get("/users/${userId}/anthologies/979c1f8b-c5aa-42bb-8669-e825f4c24529/collections?limit=all")
.header("X-Biblio-Audience", "www.biblioboard.com")
.header("accept", "application/json")
.header("X-Auth-Token", "${token}")
.check(status.is(200))
)
setUp(
scn.inject(
rampUsers(60) over (30 seconds)
)
).protocols(httpConf)
.throttle(jumpToRps(10) reachRps(20) in(30 seconds), holdFor(2 minutes))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment