Trying using Check and capturing dynamic values in gatling 2

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”)
.post(“https://stg.redboxinstant.net:443/rbproxy/api/GetOnDemandCartPricing”)
.headers(headers_16)
.queryParam("""_""", “1396459963878”)
.fileBody(“RecordedSimulation_request_189.txt”)
.check(headerRegex(“ConfirmationID :”).saveAs(“ConfirmatonID”))

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

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.

Yep, I already got it last time.
Still, have you read the documentation I pointed last time?

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

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

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.

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

Have you implemented the correlation ? Please let me know.

Thanks,
Santosh

Try to remove charset=UTF-8 from content type header…

KR,
Sravan