Gatling fill the saveAs function with a variable

Hi,

I’ve a question about the “saveAs” function.

I would like to fill in the function with a value from a CSV file. The background is that I want to dynamically generate the variables. The variable names are in a different run-time variable.

`

Several things:

  1. saveAs("${caseid}"): you can’t pass an EL to saveAs. It has to be a static name (the key for storing the value in the session), ie “caseid”
  2. You’re trying to use the caseid attribute in queryParam(“summary”, “${caseid}”) but the check that’s supposed to capture the value to be used here is defined on the SAME request. That doesn’t make sense. Capture should happen in one of the previous requests.

Thank you, that’s what I thought.

My problem is that I am going through a CSV list and the “CaseID” is always another. I have to save “IssueID” the pair of values “CaseID” and.

An example (If 2 lines of the CSV file to be read):

AAA → 12345
BBB → 54321

`

val TC_002 = http("TC_002: Development Ticket Fields 1 (Check CFs exists)")
  .get(urlBase + pathQuickEdit)
  .basicAuth(user,pass)
  .queryParamMap(basicReqOptions)
  .queryParam("id", "${AAA}")
  .check(
    css("${field_css_path}")
      .exists
  )

`

These values are dynamic. In the first HTTP call the “IssueID” s are generated, it was to save in connection with the CaseID (From the CSV file). In the second HTTP call then I need this pair of values to the query.

With a single value, this would be no problem. But I generate many issueIds and want then over the reference CaseID on the IssueID (s) can access.

Would this be possible?

Google Trad’s German to English is not its best, it seems… :wink:

I’m not sure I get it right, but it seems that you shouldn’t be using your CSV as a feeder, but as a Map, in order to get a CaseId from an IssueId.

val issueIdsByCaseId = csv("").records.map(record => record(“CaseId”) → record(“IssueId”)).toMap

// fetch the corresponding IssueId from a CaseId
exec{ session =>
val caseId = session(“CaseId”).as[String]
session.set(“IssueId”, issueIdsByCaseId(caseId))
}

Many Thanks!

At the moment I think it can not work this way. The IssueID is generated only after the first HTTP call and does not exist previously in the CSV file.

My CSV file looks like:

`

test_id,test_description,pid,issuetype,reporter,caseId,cf1_name,cf1_value,cf2_name,cf2_value

`

There is the CaseID. The IssueID I only here:

`

// Create Issue
val tc_001 = http("TC_001: Configuration (Create Issues)")
  .get(urlBase + urlPost)
  .basicAuth(user,pass)
  .queryParamMap(basicReqOptions)
  .queryParam("pid", "${pid}")
  .queryParam("issuetype", "${issuetype}")
  .queryParam("summary", "${caseId}")
  .queryParam("reporter", "${reporter}")
  .queryParam("description", "${test_id}: ${test_description}")
  .queryParam("${cf1_name}", "${cf1_value}")
  .queryParam("${cf2_name}", "${cf2_value}")
  .check (
    jsonPath("$.issueId")
      .ofType[String]
      .exists
      .saveAs("issueId")
  )

`

Is this still as possible?

Could you please explain over (from the start)?
Your first example was messed up, so I really didn’t get it.

jsonPath("$.issueId") <-- searching for issueId
      .ofType[String]
      .exists
      .saveAs("${caseid}") <-- saving the value as caseid in a broken way

Hi,

I’ve found a solution!

Many thanks.

Regards

Great!

Another question…

It is possible to interate over all CSV entries? at the moment i use a “repeat” with number ob lines… But i wont define the lines, i will use a loop over all lines.

Thanks!

http://gatling.io/docs/2.1.3/session/feeder.html#non-shared-data