Here is my code:
`
object Brownse {
val authoriedHeader = Map(“Authorization” → “Bearer ${token}”)
var idList = 1 to 10
var home = exec(http(“Access home page and wait 10s”)
.get("/home")
.headers(authoriedHeader)
.check(status.is(200)))
.pause(10)
var randomPage = repeat(10) {
exec(http(“Access 10 random pages and wait 10s”)
.get("/company-sites/${idList.random}/goods?offset=0&max=100")
.headers(authoriedHeader))
.pause(10)
}
val brownse = exec(home, randomPage)
}
`
I want to acccess 10 random pages like “/company-sites/${idList.random}/goods?offset=0&max=100”. But these code raised error: No attribute named ‘idList’ is defined
I’ve solved my question.
`
object Brownse {
val authoriedHeader = Map(“Authorization” → “Bearer ${token}”)
var randomIdFeeder = Iterator.continually(Map(“id” →
(Random.nextInt(10) + 1))) // Random choose from 1 to 10
var home = exec(http(“Access home page and wait 10s”)
.get("/home")
.headers(authoriedHeader)
.check(status.is(200)))
.pause(10)
var companies = repeat(10) {
feed(randomIdFeeder).
exec(http(“Access 10 random pages and wait 10s”)
.get("/company-sites/${id}/goods?offset=0&max=100")
.headers(authoriedHeader))
.pause(10)
}
val brownse = exec(home, companies)
}
`
在 2017年1月6日星期五 UTC+8下午3:44:47,Feng Yu写道:
You can try
.exec(http("Random") .get(session =>testServerUrl + ThreadLocalRandom.current.nextInt(0, 10000)) )