In the session I need to go from
`
val str = "7080001237547" + "1104" + "7080001237547" + "2015-02-04 12:23:55" + "SOMESITE" + "0032014142" + "2" + "hJSaGFx5M7"
`
to
`
In the session I need to go from
`
val str = "7080001237547" + "1104" + "7080001237547" + "2015-02-04 12:23:55" + "SOMESITE" + "0032014142" + "2" + "hJSaGFx5M7"
`
to
`
You want to iterate ${member} from feeder.
what you can do is start your feeder file in exec and feed it with session attribute
eg:
.feed(containsMember) .exec(session => val str =
Ok, but how will
session(member).as[String]
know how to get values from the feeder?
Shouldn’t it be more like
`
session("${member}").as[String]
`
?
Could you please help me with how to exactly implement this given this code chunck (which does not work):
`
val scn = scenario("checkXXXSimulation")
.feed(csv("data/medlemmer2.csv").random)
.exec{session =>
val md = java.security.MessageDigest.getInstance("SHA-1")
val str = "7080001237545" + "1104" + "7080001237545" + "2015-02-04 12:23:55" + "SITE" + session("${member}").as[String] + "2" + "hJSaGEx5M9"
val ha = new sun.misc.BASE64Encoder().encode(md.digest(str.getBytes))
val mac = ha.substring(0, ha.length() / 2 )
session.set("mac", mac)
}
`
First - “${member}” is interpolation for getting session variable (member) into your exec chainbuilder.
Second - You said that you want to use a feeder that will provide member information. Thats why in example i wrote
.feed(containsMember)// this csv file contains member value.
.exec…`
`
If you already have member information in “data/medlemmer2.csv”`` then following should work
Notice I removed “${ }” around member.
val str = "7080001237545" + "1104" + "7080001237545" + "2015-02-04 12:23:55" + "SITE" + session("member").as[String] + "2" + "hJSaGEx5M9"
Thanks, it works smooth now!
Cheers
Do I need to close the session, as in ‘session.close’? Or does Gatling take care of that?
just make sure either session.set or session is the last statement/expression in your session function.