1

I have to pass current epoch timestamp in below "request_1" and "request_2" dynamically. How can I achieve this. Below are just few requests given, actually there are many requests in scripts.

Here all requests should have current timestamp only. So each requests will have different different timestamp.

Is there any function so that I can replace all timestamp directly without replacing one by one.

  val Transaction_Name_1 = group("Transaction_Name_1")
  {
      exec(http("request_1")
        .get("/abc/details1?_=1590748529401"))
      .pause(5)
      .exec(http("request_2")
        .get("/abc/details1?_=1590748535534"))
  }
Karan
  • 45
  • 9

1 Answers1

1

There's no way to magically do this everywhere. You have to replace each occurrence.

As of Gatling 3.3.1 (current version as of now), the easiest way is to do:

val Transaction_Name_1 = group("Transaction_Name_1") {
  exec(http("request_1")
    .get(session => "/abc/details1?_=" + System.currentTimeMillis()))
  .pause(5)
  .exec(http("request_2")
    .get(session => "/abc/details1?_=" + System.currentTimeMillis()))
}

In Gatling 3.4.0, we'll be introducing a new Gatling EL feature so you will be able to write:

val Transaction_Name_1 = group("Transaction_Name_1") {
  exec(http("request_1")
    .get("/abc/details1?_=${currentTimeMillis()}")
  .pause(5)
  .exec(http("request_2")
    .get("/abc/details1?_=${currentTimeMillis()}"))
}
Stéphane LANDELLE
  • 6,076
  • 2
  • 10
  • 12
  • Thanks a lot for confirmation. I was spending a lot of time to get some idea to replace all timestamps at once. – Karan May 30 '20 at 13:13
  • Thanks, I need one more help... How can I replace "details1" in "request_2" with correlated value "SynchToken" from "request_1". I am trying to replace with ${SynchToken} but it is not reflecting the correlated value. `val Transaction_Name_1 = group("Transaction_Name_1") { exec(http("request_1") .get(session => "/abc/details1?_=" + System.currentTimeMillis()) .check(regex("""name="SYNCHRONIZER_TOKEN" value="(.*?)"""").saveAs("SynchToken"))) .pause(5) .exec(http("request_2") .get(session => "/abc/details1?_=" + System.currentTimeMillis())) }` – Karan May 30 '20 at 19:39
  • That's not how things work. You must create a new question, not highjack an unrelated one. – Stéphane LANDELLE May 30 '20 at 20:05
  • Thanks, I have created new question for the same. Could you please answer that. Here is link- https://stackoverflow.com/questions/62113261/how-to-pass-correlated-value-in-next-request-in-gatling-script – Karan May 31 '20 at 08:05