--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
def pushFlowWithIPv4Match(switch: String, requests: Int) = repeat(requests, "counter") {
exec(session =>
session.set("FlowBody", JSON_RESTCONF_Body_Push_Flow.createFlowBodyWithIPv4(session("counter").validate[Int].map(i => i + 1).get, IPGenerator.generate(), null,true))
.set("number", session("counter").validate[Int].map(i => i + 1).get).set("switch", switch))
.exec(http("""Add Flow ${number} on ${switch}""")
.put("""/restconf/config/opendaylight-inventory:nodes/node/${switch}/table/0/flow/${number}""")
//.headers(headers)
.body(StringBody("${FlowBody}")))
}
This is how my code looks like so far and I need change ${number} in every request and it should be unique over the different users I am injecting.
Is it possible to generate numbers in the range from 1 to 20 for 2 users, where each user gets different numbers? User 1 gets the numbers 1 to 10 and User 2 gets the numbers 11-20.
--
.exec(http("createProfile").post("""/s/c-bt.shitapi/MemberProfile.svc""").body(ELFileBody("RecordedSimulation_request_0000.txt")).check(status.is(200)))
<ns0:CreateProfileRequest xmlns:ns0="http://www.shit.com/cache/memberprofile/schemas/1.0"> <ns0:Firstname>Jan</ns0:Firstname> <ns0:Lastname>Much</ns0:Lastname> <ns0:MobileNumber>99939911</ns0:MobileNumber> <ns0:EmailAddress>jm...@start.com</ns0:EmailAddress> <ns0:Street>Street 12</ns0:Street> <ns0:Postcode>1359</ns0:Postcode> <ns0:Country>NO</ns0:Country> <ns0:EmailConsent>true</ns0:EmailConsent> <ns0:SMSConsent>true</ns0:SMSConsent> <ns0:Password>Pass123</ns0:Password></ns0:CreateProfileRequest>
Thanks, but how do I get to put it into my request body as a parameter? Can I refer it as a regular parameter within the request body as I do when using a feeder?And,Can I combine a static value with the atomic integer value. I just need unique email addresses and I want to say combine thisadress with ${theAtomicValue} @ myemail.com
as thisadress${theAtom...@myemail.com within the request body? What would be the syntax then?
class openModelSimulation extends Simulation {
val counter = new java.util.concurrent.atomic.AtomicInteger(1)
def unique_email() : Map[String, String] = {
var base_email = "email @ mail.com"
var unique_id = counter.getAndIncrement.toString
var transaction_id = unique_id + base_email
var unique_email = Map("tid" -> transaction_id)
return unique_email
}
val httpConf = http
.baseURL("https://cdcapp.site.com")
.acceptEncodingHeader("gzip,deflate")
.headers(Map("Content-Type" -> "application/json", "charset" -> "UTF-8", "User-Agent" -> "Android(4.4)/Coop(0.4)/0.1"))
.disableUrlEncoding
val scn = scenario("Scenario")
.exec(session => {
println((session(unique_email()).as[String]))
session})
setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))
}
println((session(unique_email()).as[String]))
package com.site
import java.util.concurrent.atomic.AtomicInteger
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class testSimulation extends Simulation {
val httpConf = http
.baseURL("https://site.com")
.acceptEncodingHeader("gzip,deflate")
.headers(Map("Content-Type" -> "application/json", "charset" -> "UTF-8", "User-Agent" -> "Android(4.4)/Coop(0.4)/0.1"))
.
disableUrlEncoding
val myGlobalVar = new java.util.concurrent.atomic.AtomicInteger(0)
val scn = scenario("Scenario")
.exec(session => session.set("my_var", myGlobalVar.getAndIncrement))
.exec(session => {
println((session("my_var").as[String]))
session})
.exec(
http("getToken")
.post("https://site.com/ids/connect/token")
.body(ELFileBody("my_request_refering_a_value_in_session.txt"))
)
setUp(scn.inject(atOnceUsers(5)).protocols(httpConf))
}