0

I have a file with strings and I want to read from it every time X records. I have 2 questions:

  1. Which type of file should I save my records? ("records.")
  2. How can I read X records from my file and send them as json for HttpRequestBuilder as body? For example:

    val request: HttpRequestBuilder = Utils.createPostBodyRequest(
      "request",
      "localhost:8080/request",
      Map(Constants.Content_Type -> Constants.Application_Json),
      ElFileBody("records.json"))
    
    def createPostBodyRequest(reqName: String, url: String, 
                              headers: Map[String, String], body: Body): HttpRequestBuilder = {
       http(reqName)
        .post(url)
        .headers(headers)
        .body(body)
    }
    
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • If you make use of db like mongodb u can send me easily as a zip to the user and it will get downloaded to his browser – zenwraight Mar 27 '18 at 13:29
  • with file, the problem is, u will have to open it, read stuff from it, find next x records from the previous offset and then close the file read, zip the records and send it to the user. – zenwraight Mar 27 '18 at 13:30
  • @zenwraight In my case x=5 and I have only 15 records, so I can save it in csv or something like that. my question is HOW to tell him to take another attribute in every run ? its a load test so I want that will be automatically. – Lihi Golan Mar 27 '18 at 13:35
  • got it u are saying how to tell ur endpoint about the offset like in the first call u fetched 5 now in the second call fetch next 5 i.e from 5 to 10 and in the third call fetch 11 to 15. so that value u can send in ur request as offset value, like in the first call offset will be 0, in the second call offset will be 5 etc... – zenwraight Mar 27 '18 at 13:39
  • Also if possible can u share ur whole code here, then it will be easier to understand the flow – zenwraight Mar 27 '18 at 13:39

1 Answers1

0

you can use Feeders to inject data https://gatling.io/docs/2.3/session/feeder/#feeder Other ways to inject data : https://gatling.io/docs/2.3/session/session_api/#injecting-data

vkt
  • 1,401
  • 2
  • 20
  • 46