-
-
Save dragoonis/1024b1527330473b0ca2c629d185be1d to your computer and use it in GitHub Desktop.
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
# Versions | |
Using docker image: `denvazh/gatling:2.3.1` - https://hub.docker.com/r/denvazh/gatling/ | |
- This is built with Scala 2.12. | |
- ENV GATLING_VERSION 2.3.1 | |
# Error | |
``` | |
12:17:46.540 [ERROR] i.g.c.ZincCompiler$ - | |
/opt/gatling/user-files/simulations/SupervisionSimulation.scala:58: value doif is not a member | |
of io.gatling.core.structure.ChainBuilder | |
possible cause: maybe a semicolon is missing before `value doif'? | |
``` |
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
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import scala.concurrent.duration._ | |
import scala.util.Random | |
class SupervisionSimulation extends Simulation { | |
val loginUser = System.getProperty("GATLING_LOGIN_USER", "email@site.com") | |
val loginPass = System.getProperty("GATLING_LOGIN_PASS", "password") | |
val baseUrl = System.getProperty("TARGET_BASE_URL") | |
val httpConf = http | |
.disableClientSharing | |
.baseURL(baseUrl) | |
.acceptHeader("*/*") | |
.acceptEncodingHeader("gzip, deflate") | |
// Array type | |
val apiHeaders = Map("Content-Type" -> "application/json") | |
val pdfHeaders = Map("Content-Type" -> "application/pdf") | |
val scn = scenario("Supervision") | |
.exec( | |
exec( | |
http("Login Form") | |
.post("/auth") | |
.formParam("email", loginUser) | |
.formParam("password", loginPass) | |
.check(status.is(200)) | |
) | |
.exec( | |
http("GET USER ID") | |
.get("/api/user?email=" + loginUser) | |
.headers(apiHeaders) | |
.check( | |
jsonPath("$.data[0].id").exists.saveAs("siriusUserId") | |
) | |
) | |
// Client Orders | |
// localhost assignee ID = 9 | |
// Check in my DB that allocations is 10 | |
.exec( | |
http("CLIENTS ASSIGNED TO A TEAM") | |
.get("/api/v1/assignees/10/clients") | |
.headers(apiHeaders) | |
.check(status.is(200)) | |
.check(jsonPath("$.clients[*].id") | |
.ofType[String] | |
.findAll | |
.transform(s => util.Random.shuffle(s).apply(0)) | |
.saveAs("siriusRandomAssignedClientId") | |
) | |
) | |
.doif(session => session.contains("siriusRandomAssignedClientId")) { | |
exec( | |
http("ALL DOCUMENTS FOR A CLIENT") | |
.get("/api/v1/persons/${siriusRandomAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0") | |
.headers(apiHeaders) | |
.check(status.is(200)) | |
.check(jsonPath("$.documents[*].id") | |
.ofType[String] | |
.findAll | |
.transform(s => util.Random.shuffle(s).apply(0)) | |
.saveAs("siriusRandomDocumentId") | |
) | |
) | |
.exitHereIfFailed | |
.doif(session => session.contains("siriusRandomDocumentId")) { | |
exec( | |
http("GET DOCUMENT") | |
.get("/api/document/${siriusRandomDocumentId}/pdf") | |
.headers(pdfHeaders) | |
.check(status.is(200)) | |
) | |
} // /doIf | |
} // /doIf | |
// .exec( | |
// Documents | |
.exec( session => { | |
println( "LOGIN USER ID IS: " + session( "siriusUserId" ).as[String]) | |
println( "siriusRandomAssignedClientId IS: " + session( "siriusRandomAssignedClientId" ).as[String]) | |
println( "siriusRandomDocumentId IS: " + session( "siriusRandomDocumentId" ).as[String]) | |
session | |
}) | |
) | |
setUp( | |
scn.inject(atOnceUsers(System.getProperty("GATLING_NUM_USERS").toInt)) | |
.protocols(httpConf) | |
) | |
.assertions(global.responseTime.max.lt(1000)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment