简体   繁体   中英

How to pass epoch timestamp in each requests of Gatling script dynamically

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"))
  }

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()}"))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM