I'm the Sysadmin for a small company and I'm trying to set up a first test with gatling for one of our Webapps. I know a bit of C and Java Syntax as well as Regexes, but no Scala whatsoever.
The app I'm trying to test has the jsessionid (including a jvmRoute) in the URL, not set in a cookie. According to what Stéphane Landelle wrote here, Gatling is supposed to automagically record the jsessionid per user session and replay it, but that appears to only work when the jsessionid is set as a Cookie.
I deleted the actual recorded jsessionid from the URLs in the test case, reasoning that it would not be valid on any future attempts. When i run the test, the Appserver generates a new jsessionid, which is then not included in any future calls.
Because of this, i'm trying to scrape the jsessionid from the initial redirect and include it in any future URL. There is a Location Header in the first response that looks like this:
Location https://URL/welcome.do;jsessionid=F97250BDC1576B5766CEFA56645EA3F4.node1
The code currently looks like this:
.exec(http("Open Page")
.get("""/?code=abcdef""")
.headers(headers_0)
// Test extract jsessionid from URL
.check(headerRegex("Location", "jsessionid=(.*)")).saveAs("jsess")
.exec(http("welcome.do")
.post("""/welcome.do;jsessionid=${jsess}""")
...and it doesn't compile.
12:15:14.198 [ERROR] i.g.a.ZincCompiler$ - FirstTest.scala:53: value saveAs is not a member of io.gatling.http.request.builder.HttpRequestBuilder
12:15:14.199 [ERROR] i.g.a.ZincCompiler$ - .check(headerRegex("Location", "jsessionid=(.*)")).saveAs("jsess")
12:15:14.200 [ERROR] i.g.a.ZincCompiler$ - ^
12:15:14.261 [ERROR] i.g.a.ZincCompiler$ - one error found
If i move one closing bracket to the end:
.check(headerRegex("Location", "jsessionid=(.*)").saveAs("jsess"))
it compiles but does not do what's desired:
---- Errors --------------------------------------------------------------------
> No attribute named 'jsess' is defined 11 (78.57%)
> status.in(200,304,201,202,203,204,205,206,207,208,209), but ac 2 (14.29%)
tually found 404
> headerRegex((Location,jsessionid=(.*))).exists, found nothing 1 ( 7.14%)
================================================================================
So, how do i record the jsessionid in order to reuse it? Or am I doing the completely wrong thing here? Any help is appreciated.