How to do parameterization and correlation...

Hi,

I am new to gatling…Here I am giving my scenario…

I have one rest api…

  1. One post method is .post(localhost:8000/users/post) and for this I am posting the data with form params…So user posts are created successfully…And that is stored into mongodb

2)Second one is get method…So to get particular post we are giving the Id of that post and call is like this…get(localhost:8000/user/post/5458725cc1db852b57bf23d4)…

3)Third one is put method…for that post…

So If I run the test for 100 users and each user will create one post so total 100 posts and that posts are storing into db with different Id’s which was supplied by mongodb…And next time in get call that last Id will change based ont that post…So how to handle that Id in gatling simulation???so In that case how to do correlation??And for some calls parameterization is required…So how to handle these type of calls???

Please explain with example code…Please help me…

Thanks

Start at the beginning and walk through it one request at a time.

First, you call POST. Inspect the response. In the response should be the ID you need. Extract that using something like

`
.check( jsonPath( “$.id” ).saveAs( “USER_ID” ) )

`

You will have to adjust the path according to the structure of the JSON you are extracting from, of course.

Then in the second call, you call GET:

`
exec( http( “PUT” ).put( “/path/to/service/${USER_ID}” ).check( . . . ) )

`

Once you understand that part, the rest should be pretty straight forward.

Thanks john…But In gatling 2 what ever may be the version it is not taking formparam and formupload…I am unable to do put operation…please give some advice…Actually my application supports only
formparams…If I am giving body(String …) it will not allow…So by taking this into consideration please give solution…And I tried to upgrade into 2.1…But I didn’t get success…

Thanks

The formParam methods are convenience methods. What they do, you can do manually. Instead of relying on the syntactic sugar to build your request body for your PUT request, build it manually. Yes, .body( StringBody( “the content” )) should work, if you put the right information in there.

If you don’t know how to do it, then you need to do some research into how your application behaves so that you can understand the interactions between the client and the server. It’ll be a good experience for you. :slight_smile:

Begin by installing Firebug, and looking at the Network tab.

Sure.

Still, formParam takes care of percent encoding for you. Quite handy for non US-ASCII people :wink:

Oh, I agree. But until he can upgrade to a version that works for him, building it manually will un-block his progress. And there is a certain amount of value to having the understanding of what is going on under the covers. Know-what-I-mean?

Absolutely :slight_smile: