Trying using Check and capturing dynamic values in gatling 2

948 views
Skip to first unread message

vikas bajaj

unread,
Apr 2, 2014, 6:55:19 PM4/2/14
to gat...@googlegroups.com
Hi 

I am trying to capture one dynamic value which gets generated while rent/buy  business process  in my application.

body=
{"ResultInfo":{"ResultCode":"0","ActivityID":"2bfe5e94-6ce0-4fe3-98dc-f645a1334d68","MachineID":"miagrbiwebwb02v.stg.rbi.local"},"OnDemandCartPricing":{"Price":"16.99","Tax":"1.40","Total":"18.39","ConfirmationID":"602571651

I need to pass this confirmation ID to the below subsequent request to be able to  succesfully rent a movie inmy application. I am trying  different option like regex with check but everything fails. can  some one help me,

Here is the code

.pause(2)
.exec(http("request_189")
.headers(headers_16)
.queryParam("""_""", "1396459963878")
.fileBody("RecordedSimulation_request_189.txt")
.check(headerRegex("ConfirmationID :").saveAs("ConfirmatonID"))

Stéphane Landelle

unread,
Apr 2, 2014, 7:02:43 PM4/2/14
to gat...@googlegroups.com
First, you're trying to find something in the response BODY while you're trying to use a regex on the HEADERS.

Then, JsonPath is probably more suited that regex for this use case: https://github.com/excilys/gatling/wiki/Checks#json


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

vikas bajaj

unread,
Apr 3, 2014, 11:39:53 AM4/3/14
to gat...@googlegroups.com
Hi Stefnie.

Thanks for the reply. I am quite new to this tool and have been working from last few weeks to  reocrd our web application and replay back with concurrent users. we are able to reocord  the application and replay is also working  except couple of correlations needs to take care to make it more dynamic.

i have tried going to the above link posted by you but couldn't capture the value. can you please help me  writing one function  how to extract the  dynamic value   from the code   shown below and i can use that in my subsequent request and i can then go ahead and  apply my thoughts  to other correlation

body=
{"ResultInfo":{"ResultCode":"0","ActivityID":"2bfe5e94-6ce0-4fe3-98dc-f645a1334d68","MachineID":"miagrbiwebwb02v.stg.rbi.local"},"OnDemandCartPricing":{"Price":"16.99","Tax":"1.40","Total":"18.39","ConfirmationID":"602571651"

I am trying to capture the confirmation ID value ( 602571651) which is dynamic and comes out  different   for each transaction.

Stéphane Landelle

unread,
Apr 3, 2014, 11:46:36 AM4/3/14
to gat...@googlegroups.com
Yep, I already got it last time.
Still, have you read the documentation I pointed last time?

vikas bajaj

unread,
Apr 3, 2014, 12:16:01 PM4/3/14
to gat...@googlegroups.com
Yes. I am using the below check.

.check(regex(""""ConfirmationID":"([^"]*)""").saveAs("ConfirmationID")) which is not working currently and i ma getting Http 405 error.

Response:

Response DefaultHttpResponse(chunked: false)
HTTP/1.1 405 Method Not Allowed
Server: Apache/2.2.15 (Red Hat) mod_jk/1.2.28
Foglight-Request-UUID: 3b849e4e-4a23-4d04-811f-fa0ff8a2c3c7
Vary: Accept-Encoding
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS
Access-Control-Max-Age: 1728000
Access-Control-Allow-Headers: X-Requested-With,Content-Type
RealServer: miagrbiwebwa03v.stg.rbi.local
Content-Type: application/json;charset=UTF-8
Date: Thu, 03 Apr 2014 16:03:37 GMT
Connection: close
Set-Cookie: NSC_38817_208.39.104.44=ffffffff0974491c45525d5f4f58455e445a4a423660;expires=Thu, 03-Apr-2014 16:18:37 GMT;path=/;httponly
Content-Length: 514

11:03:34.714 [DEBUG] c.n.h.c.p.n.NettyAsyncHttpProvider - Closing Channel [id: 0xf0f83839, /113.128.152.218:31406 => stg.redboxinstant.net/23.73.29.57:443
11:03:34.716 [DEBUG] c.n.h.c.p.n.NettyAsyncHttpProvider - Channel Closed: [id: 0xf0f83839, /113.128.152.218:31406 :> stg.redboxinstant.net/23.73.29.57:443] with attachment com.ning.http.client.providers.netty.NettyAsyncHttpProvider$DiscardEvent@fd82f5
11:03:34.716 [DEBUG] c.n.h.c.p.n.NettyAsyncHttpProvider - Closing Channel [id: 0xf0f83839, /113.128.152.218:31406 :> stg.redboxinstant.net/23.73.29.57:443
11:03:34.718 [WARN ] c.e.e.g.h.a.GatlingAsyncHandlerActor - Request 'request_191' failed : Check 'in' failed, found 405 but expected List(200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 304)
11:03:34.724 [TRACE] c.e.e.g.h.a.GatlingAsyncHandlerActor - 
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
request_191: KO Check 'in' failed, found 405 but expected List(200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 304)
=========================



May be i am placing the .check at the wrong place.?


Thanks
Vikas bajaj

Stéphane Landelle

unread,
Apr 3, 2014, 12:40:47 PM4/3/14
to gat...@googlegroups.com
I don't know what you're doing.
405 Method Not Allowed means that you're sending a request with an inappropriate method, such as sending a POST instead of a GET.

Once you've figured this out, please post a gist of your code:https://gist.github.com

vikas bajaj

unread,
Apr 3, 2014, 1:00:55 PM4/3/14
to gat...@googlegroups.com
i am doing a POST  as it got captured  in the code also and i am very familiar with my application and i know it should be POSt as we are load testing with load runner too and it is working perfectly there.

we are just trying to see if we can replace  load runner with gatling for our application load testing.

vikas bajaj

unread,
Apr 3, 2014, 1:04:03 PM4/3/14
to gat...@googlegroups.com
i am doing the  login flow for now and let you know if  i go through that. it would be easy to mov forward once we have login working

Santosh Kulkarni

unread,
Jun 23, 2016, 3:23:58 AM6/23/16
to Gatling User Group
Have you implemented the correlation ? Please let me know.

Thanks,
Santosh

Sravan Kumar

unread,
Jul 11, 2016, 3:43:23 PM7/11/16
to Gatling User Group
Try to remove charset=UTF-8 from content type header...

KR,
Sravan
Reply all
Reply to author
Forward
0 new messages