Last active
October 22, 2015 19:56
-
-
Save chillenious/57220a17be99aeeffce4 to your computer and use it in GitHub Desktop.
Gatling.io test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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