Gatling Test 1
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 computerdatabase | |
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import scala.concurrent.duration._ | |
import io.gatling.jsonpath._ | |
class Test1 extends Simulation { | |
val httpConf = http | |
.baseURL("http://demo1263864.mockable.io/") // Here is the root for all relative URLs | |
.acceptHeader("application/json") // Here are the common headers | |
.doNotTrackHeader("1") | |
.acceptLanguageHeader("en-US,en;q=0.5") | |
.acceptEncodingHeader("gzip, deflate") | |
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0") | |
val headers_10 = Map("Content-Type" -> "application/json") // Note the headers specific to a given request | |
val scn = scenario("Scenario Name") // A scenario is a chain of requests and pauses | |
.exec(http("Request_10") | |
.get("gatling1") | |
.headers(headers_10) | |
.check(jsonPath("$.result").is("SUCCESS") | |
,jsonPath("$.data[*]").findAll.saveAs("pList"))) | |
.foreach("${pList}", "player") { | |
exec(session => { | |
val playerId = JsonPath.query("$.playerId", "${player}") | |
session.set("playerId", playerId) | |
}) | |
.exec(http("Request_10") | |
.post("endPoint") | |
.headers(headers_10) | |
.body(StringBody("""{"playerId":"${playerId}"}""")).asJSON | |
.check(jsonPath("$.result").is("SUCCESS"))) | |
} | |
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment