Limitations in the size of a variable?

152 views
Skip to first unread message

Magnus Jensen

unread,
Dec 9, 2014, 4:31:01 AM12/9/14
to gat...@googlegroups.com
I want to call a token service (with username and password), and get a token in return. The token consists of 900 characters and is 1 KB large.

Is this a problem using: 

call1:

 .check(jsonPath("xxxx").saveAs("token"))

and 'holding' it in memory when in session and reusing it as this:

call2:

.exec(
     http("someCall")
       .get("/site/profile")
       .header( "X-Token", "${token}" )

I mean is this to large to handle by Gatling?

I do not have the chance to test this myself yet, but I thought I would ask if someone have had the chance to test large tokens before?


M

Magnus Jensen

unread,
Dec 9, 2014, 11:45:09 AM12/9/14
to gat...@googlegroups.com
BTW: this is a JSON Web Token (JWT).

Stéphane Landelle

unread,
Dec 9, 2014, 12:00:34 PM12/9/14
to gat...@googlegroups.com
FYI, Atlassian has a JWT Gatling plugin: https://bitbucket.org/atlassianlabs/gatling-jwt


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

Magnus Jensen

unread,
Dec 9, 2014, 2:02:04 PM12/9/14
to gat...@googlegroups.com
Ok, thanks. To bad it only supports http GET. I have some POSTs in my scenario as well requiring a token in the header.


exec(
http("activateSomething")
.post("/something/activate")
.header("X-Token", "${memberID}")
.body(StringBody("""{"offerId": "${item}", "membershipId": "${memberID}", "osName": "Android", "osVersion": "4.4"}""")).asJSON
.check(jsonPath("$.resultCode").is("SUCCESS")))
Message has been deleted
Message has been deleted
Message has been deleted

Abhinav Gogna

unread,
Dec 9, 2014, 10:30:39 PM12/9/14
to gat...@googlegroups.com
It does not say that it only supports get. Did you try post? I am just wondering.

Magnus Jensen

unread,
Dec 10, 2014, 4:29:07 AM12/10/14
to gat...@googlegroups.com
from bitbucket:

gatling-jwt

An extension to Gatling 2 to help send JWT-signed requests. Early stages, currently only supports GET requests.

infomaven

unread,
Jun 19, 2015, 3:30:48 AM6/19/15
to gat...@googlegroups.com
@Magnus Were you able to find a workaround? 

I think there is indeed a limit of some sort on variable size, but am not sure of the exact cutoff point.  I suspect  it's embedded in a unit test somewhere.

Today I was working with a script and trying to inject  a  pre-fabricated  JWT token to  request header. My token was  very similar to the token you described below -- humungous. 
Code looked something like this > 
     val foo = scenario( "bar" )
        .header( "key", "${blah}")
        .post( " mypost")
        .body  // remainder of the request omitted for brevity


Original plan was to set the token in a different class and then pull that variable into my request header. 
However, when I ran my script,  every single request using this header failed. Each had an error with text like     "...attribute ${blah} not found". 

However when I hard-coded my token into the .header object, everything started working again. 
Good results, but I feel dirty. 

I'm looking now for a way to generate my own token from inside this class. It does not appear that a value this large can be safely passed between classes at runtime. 

Stéphane LANDELLE

unread,
Jun 19, 2015, 4:04:50 AM6/19/15
to gat...@googlegroups.com
No, there's no such limit from Gatling.

In Java:
  • there's a limit for String literals (= hardcoded Strings) length, which is 65535 chars. This is because Java code is text that has to be parsed.
  • there's a limit for String length, which is 2147483647 (maximum size of an array) as a String is backed by a char[]

Stéphane Landelle
Lead developer


--

nadine.w...@nike.com

unread,
Jun 21, 2015, 5:30:00 AM6/21/15
to gat...@googlegroups.com
My token is 521 chars, so it is nowhere near big enough to hit the Java limits. 


What else could cause problems when  passing string values into http header objects from a variable? 

// in another class far away....
blah = "token string ......rather long.....500+chars"

// in the Scenario definition
.header( "key", "${blah}")

error has text like "...attribute ${blah} not found". 

infomaven

unread,
Jun 21, 2015, 5:53:50 AM6/21/15
to gat...@googlegroups.com
ok, I think I stumbled across something. 
I started from scratch with this header element. The compiler injected some extra text into my code, and this time I kept the change instead of deleting it.  The "extra" text placed the char  "s" in front of my variable reference.  

this changed my .header statement to read like this> 
"key" -> s"${jwtToken}" 

This value seems to be interpreted by the request the way I was expecting. 

What is this called and what does it do? 

Stéphane LANDELLE

unread,
Jun 25, 2015, 1:26:49 PM6/25/15
to gat...@googlegroups.com

Nadine Whitfield

unread,
Jun 26, 2015, 1:50:15 AM6/26/15
to gat...@googlegroups.com
Thank you. 

I was getting a bit confused about how to use Strings in regular Scala versus  Strings in Gatling DSL.



--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/uJSwy5X1uCE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages