Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modularising scenarios to run in sequence using Gatling

Tags:

I'm trying to modularise a series of performance tests in Gatling.

Several of the tests execute the same initial path through the pages, so I thought that I could break them down into a series of scenarios, each scenario being a series of shared actions defined in its own file, and then a final Simulation definition that simply executed the specified scenarios one after the other.

What I then need is for my Simulation to run those scenarios in sequence; but I can only find how to run them either concurrently, or with a specified delay between each. Is there any Simulation setup option to run the defined scenarios one after the other without specifying an arbitrary delay?

EDIT

Currently, I have the following set of files:

homepageHeaders.scala

package advanced  object homepageHeaders {      val homepage_headers_1 = Map(         "Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8""",         "If-Modified-Since" -> """Wed, 20 Mar 2013 15:36:31 +0000""",         "If-None-Match" -> """"1363793791""""     )  } 

homepageChain.scala

package advanced import com.excilys.ebi.gatling.core.Predef._ import com.excilys.ebi.gatling.http.Predef._ import com.excilys.ebi.gatling.jdbc.Predef._ import akka.util.duration._ import homepageHeaders._   object homepageChain {      val homepageChain =          //Homepage         exec(http("homepage")                     .get("/")                     .headers(homepageHeaders.homepage_headers_1)             )  } 

pageHeaders.scala

package advanced  object pageHeaders {      val page_headers_1 = Map(             "Accept" -> """text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"""     )  } 

pageChain.scala

package advanced import com.excilys.ebi.gatling.core.Predef._ import com.excilys.ebi.gatling.http.Predef._ import com.excilys.ebi.gatling.jdbc.Predef._ import akka.util.duration._ import pageHeaders._   object pageChain {      val pageChain =          //Page Menu         exec(http("page request")                     .get("/page1")                     .headers(pageHeaders.page_headers_1)             )  } 

pageSimulation.scala

package advanced import com.excilys.ebi.gatling.core.Predef._ import com.excilys.ebi.gatling.http.Predef._ import com.excilys.ebi.gatling.jdbc.Predef._ import homepageChain._ import pageChain._  class pageSimulation extends Simulation {      val urlBase = "http://www.mytestsite.com"      val httpConf = httpConfig             .baseURL(urlBase)             .acceptHeader("image/png,image/*;q=0.8,*/*;q=0.5")             .acceptEncodingHeader("gzip, deflate")             .acceptLanguageHeader("en-gb,en;q=0.5")             .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0")      val pageScenario = scenario("Bodycare Scenario")         .exec(homepageChain.homepageChain)         .exec(pageChain.pageChain)       setUp(             homepageScenario.users(1).protocolConfig(httpConf)         ) } 

The error that I'm getting is:

14:40:50.800 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/pageChain.scala:13: not found: value exec 14:40:50.807 [ERROR] c.e.e.g.a.ZincCompiler$ -          exec(http("page request") 14:40:50.808 [ERROR] c.e.e.g.a.ZincCompiler$ -          ^ 14:40:53.988 [ERROR] c.e.e.g.a.ZincCompiler$ - /Gatling/user-files/simulations/advanced/homepageChain.scala:13: not found: value exec 14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ -          exec(http("homepage") 14:40:53.989 [ERROR] c.e.e.g.a.ZincCompiler$ -          ^ 14:41:17.274 [ERROR] c.e.e.g.a.ZincCompiler$ - two errors found Exception in thread "main" Compilation failed 

Clearly I'm missing something in my definition, but I just don't understand what it is

like image 919
Mark Baker Avatar asked Mar 22 '13 10:03

Mark Baker


People also ask

How do you run scenarios sequentially in Gatling?

As of Gatling 3.3, there's no real way to run scenarios sequentially. The only solution is to start the other scenarios after some delay, see nothingFor. Sequential scenarios will be introduced in Gatling 3.4 (released in September 2020).

How do I run multiple scripts in Gatling?

Gatling won't let you run several of them, neither at the same time, nor sequentially. You have to launch Gatling multiple times, be it launching multiple times from the command line or run multiple executions of the maven plugin.

What is exec Gatling?

Actions are usually requests (HTTP, LDAP, POP, IMAP, etc) that will be sent during the simulation. Any action that will be executed will be called with exec . For example, when using the Gatling HTTP module you would write the following line: Java Kotlin Scala. // attached to a scenario scenario("Scenario") .


1 Answers

You can compose chains, not scenarios.

For example:

val login = exec(...)... val foo = exec(...)... val bar = exec(...)... val scn1 = scenario("Scenario1").exec(login).exec(foo) val scn2 = scenario("Scenario2").exec(login).exec(bar) 

Clear?

like image 132
Stephane Landelle Avatar answered Dec 18 '22 14:12

Stephane Landelle