Hi All,
I am trying to include scripts into my suite of tests that will use .andThen with a parent and child script. The parent script creates all the dependancies such as users and tenants and the child will create the assets which will belong to the tenants and users. My framework has the code, scenarios and simulations separated out. I am not sure how to integrate andThen into my scripts.
Scenario.scala :
package msx.performance.com.api.manageddevice.scenario
import io.gatling.core.Predef._
import io.gatling.core.structure.{ChainBuilder, ScenarioBuilder}
import msx.performance.com.api.consume.request.MSXPlatformConsume
import msx.performance.com.config._
import msx.performance.com.api.manageddevice.request._
import msx.performance.com.api.idm.request._
object Scenario extends BaseSimulation {
def createScenario(name: String, chains: ChainBuilder*): ScenarioBuilder = {
scenario(name)
.exec(chains)
.pause(Constants.pause)
.exec { session =>
println(session(“deviceId”).as[String])
session
}
}
val scnCreateNewTenantSite: ScenarioBuilder = createScenario(
“SCN_MSX_CREATE_TENANT_SITE”,
MSXPlatformLogin.getTokenFromAuthorize,
MSXPlatformLogin.getIsTokenValid,
MSXPlatformTenant.createNewTenant
)
val scnCreateDeviceSite: ScenarioBuilder = createScenario(
“SCN_MSX_CREATE_DEVICE_SITE”,
MSXPlatformLogin.getTokenFromAuthorize,
MSXPlatformLogin.getIsTokenValid,
MSXPlatformManagedDeviceSites.findSite,
MSXPlatformManagedDeviceSites.addDevice,
MSXPlatformManagedDeviceSites.addDeviceToSite
)
}
Simulation.scala :
package msx.performance.com.api.manageddevice.simulation
import io.gatling.http.Predef._
import io.gatling.core.Predef.{nothingFor, }
import msx.performance.com.api.manageddevice.scenario.Scenario
import msx.performance.com.config.
import scala.concurrent.duration.DurationInt
class Simulation extends BaseSimulation {
val httpScenarios = Map (
“setUpTestEnvironment” → List(
Scenario.scnCreateNewTenantSite.inject(atOnceUsers(1))
),
“createDevicesAttachtoSite” → List(
Scenario.scnCreateDeviceSite.inject(nothingFor(5 seconds), rampUsers(Constants.userCount) during(Constants.rampDuration seconds))
)
)
setUp(httpScenarios(Constants.testScenarios):_*)
.protocols(httpConf)
.maxDuration(Constants.testDuration seconds)
.assertions(global.responseTime.percentile4.lte(Constants.responseTimeLTE),
global.successfulRequests.percent.gte(Constants.successRateGTE))
}
The above works great with concurrent scripts running, but I need to write it in a way where setUpTestEnvironment runs once and then createDevicesAttachtoSite runs several times after first script finishes. Any help will be great!!
-GK