json - Gatling request based on Webservice response -


i'm new scala.

i'm using gatling stress testing.

i'm able make gatling test makes request ws, save json response in session variable. response json array contains several links images provided backend.

specifically, first request retrieves points in map, each point has image assigned, each image must fetched accessing link provided response of first ws.

i have following code:

   class basicsimulation extends simulation     {      object points     {        val jsonfilefeeder = jsonfile("input.json").circular        val points=exec(http("r1").get("/"))                   .feed(jsonfilefeeder)                   .exec(http("r2")                         .post("/ws/getpoints")                         .check(bodystring.saveas("points"))                        )     }      object images     {      val images=exec(session=>{                                val respmap = session("points").as[string]                                val mapper = new objectmapper()                                val ra = mapper.readtree(respmap)                                for( <- 0 until (ra.size()-1))                                {                                 val lnk=ra.get(a).get("image").tostring()                                 exec(http("r3").get(lnk))                                }                                session                               }                      )      }     val httpconf = http             .baseurl("http://localhost:8000/")             .useragentheader("mozilla/5.0 (macintosh; intel mac os x 10.8;  rv:16.0) gecko/20100101 firefox/16.0")     val scn = scenario("test1").exec(points.points,images.images)    setup(scn.inject(atonceusers(2)).protocols(httpconf)) } 

a sample of json response of first ws:

[  {   "bid": 1375,   "image": "http://localhost:8000/ws/image/1375",   "position": [2.326609,48.872678]  },  {   "bid": 1375,   "image": "http://localhost:8000/ws/image/1375",   "position": [2.352725,48.87323]  } ] 

the first request works fine, don't parse response jsonpath since error:

could not extract : string matching regex [$_\p{l}][$_\-\d\p{l}]*' expected but[' found

though have veryfied jsonpath expression with

https://jsonpath.curiousconcept.com/

with

 import io.gatling.core.json.jackson 

i'm able parse response, problem when trying make second request exec(http("r3").get(lnk)), request isn't made, since i'm logging on backend size requests made, when making first request, backend logs request, when making second request, request not logged on backend side.

if put request directly depending on scenario:

scenario("test1").exec(http("r").get("http://localhost:8000/ws/image/1375")) 

the request made.

i want make request ws, parse response, iterate on json elements of response , each element make second call other webservice.

thank help.

i have parsed response :

jsonpath("$[*].image").oftype[string].findall.saveas("images") 

my problem cannot make http request each link parsed jsonpath.

val render=foreach("${images}","image"){                                          exec{                                               session=>                                               exec(http("myreques").get("${image}"))                                               session                                               }                                        } 

the request not done, since on backend side don't logs.

thank you.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -