Hi All, I’m testing a paged api https//…/api/v1/service?page=1&pageSize=10 for example. I want to go up and down the pages to get fresh data returned back each time (not just the first 10 items). In the meantime I am adding data to the system while I with a concurrent test suite. The problem I have is that there is a small data set at the beginning and I want to avoid getting errors in the session variables that return the data back to the next method that needs data.
For example I have an api which creates a user using a json template. I have a requirement to test the PUT api so I’m updating the user periodically (status, email, different things, doesn’t matter). When I first start the load test on a clean environment the paged api can only return so much before it returns the same thing or fails because it has gone beyond the available number of pages
package msx.performance.com.api.scm.request
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.core.structure.ChainBuilder
import msx.performance.com.api.idm.request.MSXPlatformTenantGroups.rnd
import msx.performance.com.config._
import scala.util.Random
object PlatformSCMService extends Simulation{
val custPageIteratorFeeder: Iterator[Map[String, Int]] = Iterator.continually(Map(
"pagingStart" -> rnd.nextInt(Constants.pageIteratorEnd), //I have it set to 1 in the conf file. Also need to take randomness out of this pageStart Int
"pageSize" -> Constants.pageSize //I have it set to 5 in conf file
))
def getServiceConfigListPaged: ChainBuilder = {
feed(custPageIteratorFeeder)
.exec(http("Check if more Paged User Lists can be pulled")
.get("/api/v1/service?page=${pagingStart}&pageSize=${pageSize}") //the json returns an object and with a "hasNext" boolean attribute so if there is another page hasNext will be true
.headers(sessionHeaders)
.check(status.is(200))
.check(jsonPath("$..responseObject.hasNext").exists.saveAs("hasNextPage")))
}
}
My work is separated into a method for each api I'm testing, a separate scenario object, and a separate simulation object.
**What I want to do is check if hasNextPage == true and if it is then I can continue to next page (I would also have to make pageStart continuous in above example instead of random)**
**How can I use if statements here that will increment the pagestart under true condition or start from 1 if false?**
this is a sample of the json file which returns when calling the api: