I'm trying to test a single API that internally does different things based on inputs:
- country
- customer
- amount of items
The following simulation is what I came up with:
val countries = List("US", "CAN")
val customerTypes = List("TYPE1", "TYPE2")
val basketSizes = List(1, 10, 50)
val scenarioGenerator: Seq[(String, String, Int)] = for {
country <- countries
customerType <- customerTypes
basketSize <- basketSizes
} yield (country, customerType, basketSize)
def scenarios(): Seq[PopulationBuilder] = {
var scenarioList = new ArraySeq[PopulationBuilder](countries.size * customerTypes.size * basketSizes.size)
var i = 0;
for ((country: String, customerType: String, basketSize: Int) <- scenarioGenerator) {
// fetch customer data for scenario
val customers = DataFetcher.customerRequest(country, customerType)
// fetch product data for scenario
val products = DataFetcher.productRequest(country)
// generate a scenario with given data and parameters
val scen = scenario(s"Pricing-(${country},${customerType},${basketSize})")
// feeder that creates the request object for the gatling user
.feed(new PricingFeeder(country, customers, products, basketSize))
.repeat(10) {
exec(Pricing.price)
.pause(500 milliseconds)
}
.inject(
rampUsers(10) over (10 seconds)
)
scenarioList(i) = scen
i = i + 1
}
scenarioList
}
setUp(scenarios: _*).protocols(httpProto)
This is run with the maven plugin (and with tracking in jenkins using the gatling plugin), but this results in a single tracked case: Pricing
. This is useless as even the item amount will be close to a linear increase in response time.
The simulation.log
has the data for each scenario type, but out of the box reporting handles it as a single type of query, and merges all the results in a single graph, which means that it's impossible to see if a certain combination causes a spike due to a calculation or data bug.
I'd like to get separate metrics for each of the combinations, so it would be really easy to see for example that a code or data change in the API caused a latency spike in the Pricing-(US,TYPE1,50)
scenario.
What is the idiomatic way of achieving this with gatling? I don't want to create simulations for each case, as this would be a nightmare to manage (and getting rid of manually managed data and jenkins jobs with jmeter is what we are trying to achieve).