Need help in scenario in a specific scenario scripting

Hi Team,

Out team has a requirement where we want to simulate below scenario:

  1. First we will do post request which will return us 100 signed URLs
  2. second request we have to hit PUT request concurrently these 100 URLs.
    Below snippet is helping us to make PUT call sequentially ut we want to execute those request concurrently to generate enough load on system:

val Requests = exec(
http(“Request1”)
.post(“URL”)
.body(RawFileBody(“file.json”)).asJson
.header(“BusinessNo”, “123456”)
.check(status.is(200))
.check(jsonPath(“$.summary.successCount”).ofType[Int].is(100).saveAs(“SuccessRecords”))
.check(jsonPath(“$.uploadedFiles[*].signedUrl”).findAll.saveAs(“signedUrls”))
).foreach(“#{signedUrls}”, “signedUrl”){
exec(http(“PUTRequest”)
.put(“${signedUrl}”)
.formUpload(“FileName”, “fileName”)
.check(status.is(200)))}

Hi there,

Appreciate the post, but I don’t see a question here. This is also a forum where we try to teach you how to fish, rather than writing scripts on your behalf.

You are more likely to get help if you can specify: What you’re trying to achieve, what problem you’re running into, any errors you’re receiving, etc… Then we can direct you to the correct resources to help you accomplish your goals.

All the best,
Pete

Hello,

The problem I am facing is that our requirement is to make the put request in parallel for all the signed URLs we are getting; the above code we are able to do it one by one; is there a way we can do it in parallel for all signedUrls concurrenctly?

I have tried below snippet as well but there request 2 is not getting executed:
val Requests = exec(
http(“Request1”)
.post(“URL”)
.body(RawFileBody(“file1.json”)).asJson
.header(“BusinessNo”, “123456”)
.check(status.is(200))
.check(jsonPath(“$.summary.successCount”).ofType[Int].is(1).saveAs(“SuccessRecords”))
.check(jsonPath("$.uploadedFiles[].signedUrl").findAll.saveAs(“signedUrls”))
).exec(session => {
val signedUrls: List[String] = session(“signedUrls”).as[Vector[String]].toList
val resourceCalls = signedUrls.map { signedUrl =>
http(“Request2”)
.put(signedUrl)
.formUpload(“FileName”, “filename.wav”)
.check(status.is(200))
}.toArray
exec(http(“Dummy”).get(“/dummy”).resources(resourceCalls:_
))
session
})

Currently, the only way in Gatling for a virtual user to perform concurrent requests is in a resources block. And the resources list must be known beforehand.

So I’m afraid your use case is currently not feasible.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.