我在标头中使用了1000个令牌的CSV,每种情况下都可以使用任何随机令牌。对于该场景中的所有获取和发布请求,该随机令牌应保持相同。以下是CSV文件的示例数据。
令牌
令牌token1tewq
令牌token2cbvj
依此类推,直到1000行
我要执行的方案如下。
我尝试使用以下代码进行操作,但是无法正常工作。
val tokencsv = csv("test.csv").random
val httpConf = http.baseURL("http://myApiUrl")
.acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
.doNotTrackHeader("1")
.acceptLanguageHeader("en-US,en;q=0.5")
.acceptEncodingHeader("gzip, deflate")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")
val userFeed = feed(tokencsv)
.exec(http("Get all feeds")
.get("url1")
.headers(Map("Content-Type" -> "application/json","Authorization" -> "${token}")))
.pause(2)
.exec(http("Post a feed")
.post("url2")
.body(StringBody("""{"type":2, "images":["http://imageurl.jpg"],"text":"lorem ipsum", "data_id":12}""")).asJSON
.headers(Map("Content-Type" -> "application/json","Authorization" -> "${token}")))
.pause(1)
.exec(http("Reloading page after posting the feed").get("url1")
.headers(Map("Content-Type" -> "application/json","Authorization" -> "${token}")))
val socialFeedGetAll = scenario("social feed").exec(userFeed)
setUp(socialFeedGetAll.inject(constantUsersPerSec(10) during(60 seconds)).protocols(httpConf))