Add second cookie to session.

470 views
Skip to first unread message

Marcin Charęziński

unread,
Nov 4, 2015, 4:30:07 AM11/4/15
to Gatling User Group
Hi (Gatling 2, I have read documentation)

I need too add second cookie to each header. For now I am able to add it as a static value in header.


val header_with_secondCookie = Map("Cookie" -> "firstCookie=01; secondCookie=${secondCookie}")

val postLoginAndPass = exec(
http("request_1").post(uri2 + "/json/authenticate").headers(header_with_default_cookie)
.body(ElFileBody("authBody.json")).asJSON
.check(jsonPath("$.tokenId").saveAs("secondCookie"))
)

val schouldGetWithNewSecondCookie =
exec(
http("request_2")
.get(uri2 + "/user")
.headers(header_with_secondCookie)
)

Maybe there is some way to add second cookie to session...?











Marcin Charęziński

unread,
Nov 5, 2015, 2:25:46 AM11/5/15
to Gatling User Group
After DEBUGGING session I noticed that method
exec(flushSessionCookies) works. Session cookies are dropped.

Now I need to add new cookie inside session, but method
exec(addCookie(Cookie("name", "value"))) does not work at all.

val scn = scenario("BasicSimulation")
   
.exec(http("request_1").get("/"))
   
.exec { session => println("My session before: " + session)
          session
   
}
   
.exec(addCookie(Cookie("name", "value")))
   
.exec { session => println("My session ater: " + session)
          session

   
}



So, sessions before and after are identical. No changes.
How to add cookie to session manually, when addCookie figure doesn't help.











Guillaume CORRE

unread,
Nov 5, 2015, 3:30:16 AM11/5/15
to gat...@googlegroups.com
Hi,

What version of Gatling are you using ? This was a bug in previous versions that was corrected in 2.1.6 or 2.1.7.

Also, addCookie won't work without a baseURL set on the protocol level.

Cheers.

--
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.

Marcin Charęziński

unread,
Nov 5, 2015, 4:38:31 AM11/5/15
to Gatling User Group
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<scala.version>2.11.7</scala.version>
<encoding>UTF-8</encoding>

<gatling.version>2.2.0-M3</gatling.version>

<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>
</properties>

Could you give me some tip how to set up baseURL and cookie together into the session?

My Cookie jar is sth like

gatling
.http.cookies -> CookieJar(Map(CookieKey(amlbcookie,my.domain.com,/) -> StoredCookie(amlbcookie=01; domain=my.domain.com; path=/,false,false,1446644285856))))


And I need to add second cookie (or replace old one)

myNewCookieToken=${myNewCookieTokenValue}

Stéphane LANDELLE

unread,
Nov 5, 2015, 5:14:27 AM11/5/15
to gat...@googlegroups.com
We release milestones for our customers when they need them.
You can use them, but at your own risks: they are not documented, and might contain bugs that are fixed in the master and/or the latest stable version (which is currently 2.1.7).

Stéphane Landelle
GatlingCorp CEO

Marcin Charęziński

unread,
Nov 9, 2015, 5:18:12 AM11/9/15
to Gatling User Group
Thanks for explanation.

After downgrade to 2.1.7 everything is OK.
Reply all
Reply to author
Forward
0 new messages