简体   繁体   English

Gatling 脚本-如何在以下请求中使用不同的纪元时间提供 eventdatetime

[英]Gatling Scripts- how can I feed the eventdatetime in the below request with different epoch time

Gatling Scripts- How can I feed the eventDateTime in the below request with different epoch time as a feeder too. Gatling 脚本 - 如何在以下请求中以不同的纪元时间作为馈送器馈送 eventDateTime。 The Id is feed through the feeder in a circular way. Id 以循环方式通过馈送器馈送。 the Below request is in a file which is fed using a ELFileBody.下面的请求位于使用 ELFileBody 提供的文件中。 The event-new.json looks like event-new.json 看起来像

{
  "events": [
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271042436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271043436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271044436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271045436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271046436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271047436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "ON",
        "eventDateTime": 1598271048436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    },
    {
      "eventDataModel": {
        "eventStatus": "OFF",
        "eventDateTime": 1598271049436
      },
      "transactionModel": {
        "id": "${ID}"
      }
    }
  ]
}

above is the event-new.json which is been posted using the gatling script snippet from gatling script上面是使用 gatling 脚本中的 gatling 脚本片段发布的 event-new.json

val idFeeder = csv("Id.csv").circular
val trip_dte2 = scenario("Event")
                    .feed(idFeeder)
                    .exec(http("event")
                    .post( event_url)
                    .headers(headers)
                    .body(ElFileBody("event-new.json")).asJSON
                    .check(status.is(201)))

As of Gatling 3.3:从加特林 3.3 开始:

.exec { session =>
  session.set("timestamp", System.currentTimeMillis())
}

and then replace 1598271049436 with ${timestamp} .然后用${timestamp}替换1598271049436

Or, coming in Gatling 3.4 : directly replace 1598271049436 with ${currentTimeMillis()} if it's fine for you to have different values for each occurrence in your JSON payload.或者,在 Gatling 3.4 中:直接用${currentTimeMillis()}替换1598271049436 ,如果您可以为 JSON 负载中的每次出现使用不同的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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