val resourceGet = chain.exec(
http("getResources")
.get("/resources/1")
.headers(headers_1)
.check(header("SET-COOKIE").exists).find.saveAs("sessionToken")
)
I adapted this from the "Saving values" section here:
https://github.com/excilys/gatling/wiki/Checks-Reference
This doesn't work and i've tried other combinations like removing the
'find' but all throw errors something like:
/local/dev/gatling/user-files/simulations/20120131002614_scenario@default_scala.scala:258:
error: value find is not a member of
com.excilys.ebi.gatling.http.action.HttpRequestActionBuilder
.check(header("SET-COOKIE").exists).find.saveAs("sessionToken")
So my first question would be how can I extract a header and save it
to a session variable?
Also from looking at the code it seems like headers expect 1 value for
a specific header name. For SET-COOKIE headers in particular it is
common to have multiple with the same name. Is there any way in
Gatling to extract the one I want? I would need to find the
SET-COOKIE header with a value like
"JSESSIONID=E2F98A8757AC931AEE67AAE5E3B769DC; Path=/" and then extract
the token from that.
Any tips?
Chris
i've resolved my problem it was a rule in mod_security that doesn't like $Path="/Admin" even if it is a valid part for a cookie
sorry for the inconvenience
val chain1 = //some http call that will return multiple Set-Cookie headers
val chain2 = //a bunch of static content requests that don't require
the cookie is set
val chain3 = //another http cal that needs the cookie from chain1
val scn = scenario("...").insertChain(chain1).insertChain(chain2).insertChain(chain3)
But on the chain3 request it doesn't seem like the cookie is being set
in the request. The cookie should be set for all requests for a
particular user right? Is there any way for me to debug what gatling
is actually sending? Can I somehow config Gatling to print the full
request in the simulation.log? Or can I println session attributes
but so far I haven't been able to find what attribute the cookie is
set in.
I imagine I'm doing something wrong but I'm not sure the best way to
debug what Gatling thinks should be sent for each request.
Chris
val debugChain = chain.exec( (s: Session) => println( s.data) )
When I do this right after chain1 (that sets the JSESSIONID cookie) I see:
gatling.http.cookies -> Map(JSESSIONID -> Cookie: domain=null,
name=JSESSIONID, value=9862CA687E7D7F8885EFC4416B29CCDB, path=/,
maxAge=-1, secure=false...
But after chain2 I print it again and see:
gatling.http.cookies -> Map(JSESSIONID -> Cookie:
domain=.facebook.com, name=JSESSIONID, value=deleted, path=/,
maxAge=-1, secure=false
Is the 'value=deleted' something that Gatling is doing? Is there any
way to tell it to retain the cookies over the life of a user's
session? I figure as a workaround I can manually extract the
'gatling.http.cookies' from the session and grab the cookie value and
then use it wherever I want. Gonna give that a shot right now.
Chris
Thanks!
Chris
Thanks for the quick turn around!
Chris
Chris