I'd like to achieve something along these lines
Is what I'm asking achievable? With Feeds?? Here is an outline of what I have but without the bit where in each iteration of the loop I can get data from another feed:
val userFeeder = csv( "users.csv" )
val randomPagesFeeder = csv( "pages.csv" ).random
object login {
val dologin = exec(
http("login page")
.get("/login")
.headers(standardHeaders)
)
.exec(
http("post login form")
.post("/loginaction")
.headers(standardHeaders)
.formParam("loginid","${loginid}")
.formParam("password", "${password}")
)
)
)
object randompages {
val visitrandom = repeat(10){
// ??? how to pull from feeder in here so that exec( http ) calls
// have data from randomPagesFeeder, i.e.:
exec(
http("randompage")
.get("${uriFromAFeeder}")
)
}
)
def myload() = {
feed( userFeeder ).exec( login.dologin, randompages.visitrandom )
}
val scn = scenario( "My scenario" ).exec( myload() )
setUp( scn.inject( rampUsers( userCount ).during( userWarmup.toInt seconds ) ) ).protocols( httpProtocol )
I suspect that this is a simple problem and the answer is in front of me. I have spent a long time with the docs and other tutorials and am hitting a wall of understanding.
The understanding that I was missing was how feeders work. When you call feed( feeder )
, you are pulling the next value(s) from the feed into the session to be used in your chain. From the docs:
Every time a virtual user reaches this step, it will pop a record out of the Feeder, which will be injected into the user’s Session, resulting in a new Session instance.
These feed( feeder )
calls can be chained alongside exec()
, pause()
, each()
, etc. This means you can pull the next value from any feed within a loop, for example. This placement of feed( feeder )
calls is harder to find in the docs and was the source of my misunderstanding.
The below code illustrates the use of loops combined with feeds (NOT a full or real test scenario, just meant to illustrate how two feeders can be used in combination):
val usersFeeder = csv( "users.csv" )
val pagesFeeder = csv( "pages.csv" ).random
// ...
feed(userFeeder) // puts the next user from the feed in session
.exec(
http("Login page")
.get("/login")
)
.exec(
http( "Do login" )
.post( "/loginaction" )
.formParam("loginid","${loginid}") // loginid from userfeeder
.formParam("password", "${password}") // password from userfeeder
)
.repeat(5) {
feed(pagesFeeder) // puts the next page from pagesFeeder into session
.exec(
http("Visit random page")
.get("${pageuri}") // pageUrifrom pagesFeeder
)
}
// ...