--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/ed19c2a0-421d-4c69-96cc-901454cce181n%40googlegroups.com.
Thanks Stephane for the quick response.
Sorry I am a bit new to Gatling and I am not sure why this will not work? I tried your suggestion and I added the import io.gatling.core.session.Expression and updated the parameter to ruleSetNumber:Expression[Int] but still received the same result.
This is the only update I made
def createRulesetUid(ruleset:String, ruleSetNumber:Expression[Int])
Is there something else I am missing?
Thanks!ActionBuilder(s) that have to be chained altogether and are only built once on startup. The result is a workflow chain of Action(s). These builders don’t do anything by themselves, they don’t trigger any side effect, they are just definitions. As a result, creating such DSL components at runtime in functions is completely meaningless. If you want conditional paths in your execution flow, use the proper DSL components (doIf, randomSwitch, etc)exec { session =>
if (someSessionBasedCondition(session)) {
// just create a builder that is immediately discarded, hence doesn't do anything
// you should be using a doIf here
http("Get Homepage").get("http://github.com/gatling/gatling")
}
session
}To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/cdf1154b-0e06-4017-8ed2-62c3d7475b56n%40googlegroups.com.
Thanks Stephane
Even when I remove the if statement it does not seem to work.
See
def createRulesetUid(ruleset:String, ruleSetNumber:Expression[Int]) =
feed(TestUtil.configValues)
.exec(getAccessToken)
.exec(_.set("auth_token",
token))
.exec(
http("POST createRuleSet - " + ruleset.dropRight(5))
.post(session => getCreateRulesetUrl(session,ruleset))
.header("Authorization",
"Bearer ${auth_token}")
.header("GW-Tenant",
"${gw_tenant}")
.header("GW-User",
"${gw_user}")
.header("Content-Type",
"application/json")
.header("GW-request-grn",
"${gw_grn}")
.headers(TestUtil.serviceCallTracingHeaders)
.body(StringBody(getResourceBody(Integer.parseInt(ruleSetNumber.toString()))))
.check(status.is(200)) // check successful update
.check(jsonPath("$.resourceUid").exists.saveAs("resourceUid"))).exitHereIfFailed
.exec {
session => {
rulesetUidArray.add(session("resourceUid").as[String])
Console.println("-------###########################-------ruleSetNumber:
" + rulesetUidArray.toString);
session
}
}
When I call it from my scenario in the Repeat it does not seem to enter the method
val
createRulesetScenario: ScenarioBuilder = scenario("Create
Ruleset scenario")
.feed(TestUtil.configValues)
.exec(TestUtil.getAccessToken)
//
.exec(TestUtil.createRulesetUid(rulesetFilePath,0))
//
.exec(TestUtil.createRulesetUid(rulesetFilePath,1))
.repeat(numberOfRulesets,"indexCount")
{
exec(session => {
exec(TestUtil.createRulesetUid(rulesetFilePath, Integer.parseInt(session.attributes("indexCount").toString))).pause(5)
session
})
}
there must be something else I am missing about this repeat?
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/f47d039b-7f4e-4281-8870-c9cbbdc57ec4n%40googlegroups.com.
Ok gotcha Thanks!
So I guess what I am trying to do is something like this..
I have a list "jurisdictionCode": [
"Hokkaido",
"Aomori",
"Iwate",
"Miyagi"
]
I would like to loop through these values and use them for my post request .. is there a way to pass in each jurisdiction as a string or something to have in my post? Something like this?:
.foreach("${jurisdictionCode}", "jurisdiction") {
exec(TestUtil.createRulesetUid2(rulesetFilePath, "${jurisdiction}"))
}
butt I cant seem to get it to work using this post. Note: I want to save the response in the session see .check(jsonPath("$.resourceUid").exists.saveAs("resourceUid"))).
def createRulesetUid2(ruleset:String, jurisdictionParam:Expression[String]) = // not sure if this is correct or how i would access this value? it is unclear how Expression[String] works?
feed(TestUtil.configValues)
.exec(getAccessToken)
.exec(_.set("auth_token",
token))
.exec(
http("POST createRuleSet - " + ruleset.dropRight(5))
.post(session => getCreateRulesetUrl(session,ruleset))
.header("Authorization",
"Bearer ${auth_token}")
.header("GW-Tenant",
"${gw_tenant}")
.header("GW-User",
"${gw_user}")
.header("Content-Type",
"application/json")
.header("GW-request-grn",
"${gw_grn}")
.headers(TestUtil.serviceCallTracingHeaders)
.body(StringBody(getResourceBodyJurisdiction("${jurisdiction}"))) //This doesnt work.. how do I get the jurisdiction value in for the body??
.check(status.is(200))
.check(jsonPath("$.resourceUid").exists.saveAs("resourceUid"))).exitHereIfFailed //
note I want to save resourceUid for use
later.
.exec {
session => {
rulesetUidArray.add(session("resourceUid").as[String]) //here I was adding each resourceUid into a
array to save
session
}
}
suggestions would be very much appreciated !
.foreach("${jurisdictionCode}", "jurisdiction") {
TestUtil.createRulesetUid2(rulesetFilePath, "${jurisdiction}")
}
thanks!