HeaderRegex parsing

Hi all,

Thanks for the great tool!

I am running some tests and I have an error while running one of them:

.check(headerRegex(

“Location”, “(http://fr.blackberry.com)|(http://www.apple.com/fr)”))

Strangely it works on my Mac but not on our Jenkins server…

Thanks for your time.

Here are the details:

Request DefaultHttpRequest(chunked: false)
GET /c/474JEQ?testId=xxx HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip
Connection: keep-alive
User-Agent: Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+

Response DefaultHttpResponse(chunked: false)
HTTP/1.1 302 Found
Server: nginx
Content-Type: image/gif
Content-Length: 0
Connection: keep-alive
Location: http://www.apple.com/fr?testId=xxx
Cache-Control: no-cache
Pragma: no-cache
[ERROR] [03/07/2014 18:31:37.030] [GatlingSystem-akka.actor.default-dispatcher-11] [akka://GatlingSystem/user/$y/$d] null
java.lang.NullPointerException
	at java.lang.String.<init>(String.java:147)
	at io.gatling.core.check.extractor.regex.RegexExtractors$RichMatcher$.value$extension(RegexExtractors.scala:69)
	at io.gatling.core.check.extractor.regex.RegexExtractors$$anonfun$extract$1.apply(RegexExtractors.scala:77)
	at io.gatling.core.check.extractor.regex.RegexExtractors$$anonfun$extract$1.apply(RegexExtractors.scala:76)
	at io.gatling.core.check.extractor.regex.RegexExtractors$RichMatcher$.foldLeft$extension(RegexExtractors.scala:43)
	at io.gatling.core.check.extractor.regex.RegexExtractors$.extract(RegexExtractors.scala:76)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractors.scala:33)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractors.scala:33)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
	at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
	at scala.collection.AbstractTraversable.map(Traversable.scala:105)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$.extractHeadersValues(HttpHeaderRegexExtractors.scala:33)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$1$$anon$1.apply(HttpHeaderRegexExtractors.scala:39)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$1$$anon$1.apply(HttpHeaderRegexExtractors.scala:36)
	at io.gatling.core.check.CheckBase$$anonfun$check$3$$anonfun$apply$4.apply(Check.scala:65)
	at io.gatling.core.check.CheckBase$$anonfun$check$3$$anonfun$apply$4.apply(Check.scala:64)
	at io.gatling.core.validation.Success.flatMap(Validation.scala:28)
	at io.gatling.core.check.CheckBase$$anonfun$check$3.apply(Check.scala:64)
	at io.gatling.core.check.CheckBase$$anonfun$check$3.apply(Check.scala:63)
	at io.gatling.core.validation.Success.flatMap(Validation.scala:28)
	at io.gatling.core.check.CheckBase.check(Check.scala:63)
	at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:30)
	at io.gatling.http.check.HttpCheck.check(HttpCheck.scala:29)
	at io.gatling.core.check.Checks$$anonfun$check$1$$anonfun$apply$1.apply(Check.scala:30)
	at io.gatling.core.check.Checks$$anonfun$check$1$$anonfun$apply$1.apply(Check.scala:30)
	at io.gatling.core.validation.Success.flatMap(Validation.scala:28)
	at io.gatling.core.check.Checks$$anonfun$check$1.apply(Check.scala:30)
	at io.gatling.core.check.Checks$$anonfun$check$1.apply(Check.scala:29)
	at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
	at scala.collection.immutable.List.foldLeft(List.scala:84)
	at io.gatling.core.check.Checks$.check(Check.scala:29)
	at io.gatling.http.ahc.AsyncHandlerActor.checkAndProceed$1(AsyncHandlerActor.scala:162)
	at io.gatling.http.ahc.AsyncHandlerActor.io$gatling$http$ahc$AsyncHandlerActor$$processResponse(AsyncHandlerActor.scala:175)
	at io.gatling.http.ahc.AsyncHandlerActor$$anonfun$receive$1.applyOrElse(AsyncHandlerActor.scala:55)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425)
	at akka.actor.ActorCell.invoke(ActorCell.scala:386)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230)
	at akka.dispatch.Mailbox.run(Mailbox.scala:212)
	at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506)
	at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Hi,

Which is version is this?

2.0M3

2 things:

  • Gatling 2M3 doesn’t support having more that one capture group. Here, you have 2.
  • Master/upcoming 2M4 supports them. Still, I missed the | usage, so there’s some work left.

I opened an issue here: https://github.com/excilys/gatling/issues/1679

Thanks!

We can have different redirection for A/B testing purpose. Just to explain why.

Then, regarding your specific use case, why use capture groups, as you’re actually matching the whole string?

“Location”, “http://fr.blackberry.com|http://www.apple.com/fr”)) would work and match your needs, right?

You are right. I will try that on Monday!

Actually, the easiest way is not to use a regex but just the raw String:
header(“Location”).in(Seq(“http://fr.blackberry.com”, “http://www.apple.com/fr”))

Thanks for the tip but in fact the expression to match is “http://fr.blackberry.com?testId=xxx” so I can’t use the “in” but need a regex.

I tried without the capturing group

.check(headerRegex(

“Location”, “http://fr.blackberry.com|http://www.apple.com/fr”))

and I got the same error:

java.lang.NullPointerException
	at java.lang.String.<init>(String.java:147)
	at io.gatling.core.check.extractor.regex.RegexExtractors$RichMatcher$.value$extension(RegexExtractors.scala:69)
	at io.gatling.core.check.extractor.regex.RegexExtractors$$anonfun$extract$1.apply(RegexExtractors.scala:77)
	at io.gatling.core.check.extractor.regex.RegexExtractors$$anonfun$extract$1.apply(RegexExtractors.scala:76)
	at io.gatling.core.check.extractor.regex.RegexExtractors$RichMatcher$.foldLeft$extension(RegexExtractors.scala:43)
	at io.gatling.core.check.extractor.regex.RegexExtractors$.extract(RegexExtractors.scala:76)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractors.scala:33)
	at io.gatling.http.check.header.HttpHeaderRegexExtractors$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractors.scala:33)

My bad I forgot to change it for one of my regex ;-).

BTW, in that case the simulation never end as it is waiting for the request to complete but the actor got dead so I got this:

---- Tablet click --------------------------------------------------------------
[##################################----------------------------------------] 46%
          waiting: 0      / running: 54     / done:46   

like for ever!

Thanks again.

Regarding null capture group value, I’ve just pushed a fix: https://github.com/excilys/gatling/issues/1679
A new snasphot will be available on Sonatype in a few minutes: https://github.com/excilys/gatling/wiki/Continuous-Integration

Regarding the simulation never ending, I suspect this has been fixed on master too.

Could you give the snapshot a try, please?
Let me know if you need help migrating.

I am not very familiar with scala so I have problems replacing ramp and global (assertions).

Remove bootstrap._ and assertions._, we were able to get rid of this crap.

ramp(5 users) => rampUsers(5)

See example: https://github.com/excilys/gatling/blob/master/gatling-bundle/src/test/scala/io/gatling/bundle/test/HTTPCompileTest.scala#L208-L243

Thanks for the help, here are the results:

.check(headerRegex(

“Location”, “(http://www.ubuntu.com)|(http://fedoraproject.org)”))

==>

java.lang.NullPointerException: null

at java.lang.String.(String.java:147) ~[na:1.6.0_26]

at io.gatling.core.util.StringHelper$RichString$$anonfun$5.apply(StringHelper.scala:87) ~[gatling-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]

at io.gatling.core.util.StringHelper$RichString$$anonfun$5.apply(StringHelper.scala:87) ~[gatling-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]

at io.gatling.core.util.StringHelper$RichString$.ensureTrimmedCharsArray$extension(StringHelper.scala:125) ~[gatling-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]

at io.gatling.core.check.extractor.regex.LowPriorityGroupExtractorImplicits$$anon$1.extract(GroupExtractor.scala:30)

at io.gatling.core.check.extractor.regex.LowPriorityGroupExtractorImplicits$$anon$1.extract(GroupExtractor.scala:28)

at io.gatling.core.check.extractor.regex.package$RichMatcher$.value$extension(package.scala:46)

at io.gatling.core.check.extractor.regex.RegexExtractor$$anonfun$extractAll$1.apply(RegexExtractor.scala:38)

at io.gatling.core.check.extractor.regex.RegexExtractor$$anonfun$extractAll$1.apply(RegexExtractor.scala:37)

at io.gatling.core.check.extractor.regex.package$RichMatcher$.foldLeft$extension(package.scala:31)

at io.gatling.core.check.extractor.regex.RegexExtractor$.extractAll(RegexExtractor.scala:37)

at io.gatling.http.check.header.HttpHeaderRegexExtractor$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractor.scala:28)

at io.gatling.http.check.header.HttpHeaderRegexExtractor$$anonfun$extractHeadersValues$1.apply(HttpHeaderRegexExtractor.scala:28)

TabletDevice.scnIPadClick.inject(rampUsers(10) over (duration))

https://github.com/excilys/gatling/issues/1683

Thanks, it works now!

About the report, I had 10 requests and just 8 managed to go through (due to the previous bug) and still it was a success (look at my previous post).

Yes, I wasn’t expecting exceptions here, so it caused the request not to be logged. Should be working fine now.