Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class RecordedSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://mabaseurl")
.inferHtmlResources()
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.connectionHeader("close")
.userAgentHeader("PostmanRuntime/7.17.1")
/* randomized data information */
var feeder = Iterator.continually(Map("somedata" -> (Random.alphanumeric.take(20).mkString)))
/* ------------------------------------- */
val holder = new LinkedBlockingDeque[String]()
/* Enables to store and fetch the oauth access token */
var sharedDataFeeder= Iterator.continually(Map("variable" -> holder.takeFirst()))
/* ------------------------------------- */
val firstScenario = scenario("First Simulation")
.exec(http("first scenario")
.post("/base/url1")
.check(jsonPath("$.my_variable").find.saveAs("variable")))
.exec(session => {
holder.offerLast(session("variable").as[String])
session}
);
val secondScenario = scenario("Second Simulation")
.feed(feeder)
.feed(sharedDataFeeder)
.repeat(1){
exec(http("url1")
.post("/url1")
.headers(Map("my_header" -> "Bearer ${variable}","Content-Type" -> "application/json"))
.body(ElFileBody("recordedsimulation/anonymized_data.json")));
}
setUp(firstScenario.inject(atOnceUsers(1)),secondScenario.inject(constantConcurrentUsers(10) during (10 minutes),
rampConcurrentUsers(10) to (20) during (10 minutes))
.protocols(httpProtocol));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.