I’m still unsure how you intend to “feed” your scenario with the requests.
Let’s say you want to test the operations of a given REST webservice, so you know beforehand the structure of the data you have to pass and are able to write the requests with the Gatling DSL.
In the upcoming 1.3.0, you’ll have a randomSwitch, so you can write something like that:
In 1.3.0, you’ll also have randomSwitch without percentages (equally distributed) and roundRobinSwitch.
So if you have several requests per type, you could write:
val putRequests = roundRobinSwitch(putRequest1, putRequest2…)
val getRequests = roundRobinSwitch(getRequest1, getRequest2…)
val postRequests = roundRobinSwitch(postRequest1, postRequest2…)
[INFO] — gatling-maven-plugin:1.3.0-SNAPSHOT:execute (default-cli) @ api-load-test —
[INFO] Exception in thread “main” java.lang.RuntimeException: Compilation failed:
[INFO] /home/ilya/gatling_work/tests/TestRandomController.scala:21: error: overloaded method value randomSwitch with alternatives:
[INFO] (possibility1: com.excilys.ebi.gatling.core.structure.ChainBuilder,possibility2: com.excilys.ebi.gatling.core.structure.ChainBuilder,possibilities: com.excilys.ebi.gatling.core.structure.ChainBuilder*)com.excilys.ebi.gatling.core.structure.ScenarioBuilder
[INFO] (possibility1: (Int, com.excilys.ebi.gatling.core.structure.ChainBuilder),possibility2: (Int, com.excilys.ebi.gatling.core.structure.ChainBuilder),possibilities: (Int, com.excilys.ebi.gatling.core.structure.ChainBuilder)*)com.excilys.ebi.gatling.core.structure.ScenarioBuilder
[INFO] cannot be applied to ((Int, com.excilys.ebi.gatling.core.structure.ChainBuilder))
[INFO] .randomSwitch {
[INFO] ^
[INFO] one error found
[INFO]
[INFO] at com.excilys.ebi.gatling.app.SimulationClassLoader$$anonfun$fromSourcesDirectory$1.apply(SimulationClassLoader.scala:63)
[INFO] at com.excilys.ebi.gatling.app.SimulationClassLoader$$anonfun$fromSourcesDirectory$1.apply(SimulationClassLoader.scala:53)
[INFO] at com.excilys.ebi.gatling.core.util.IOHelper$.use(IOHelper.scala:24)
[INFO] at com.excilys.ebi.gatling.app.SimulationClassLoader$.fromSourcesDirectory(SimulationClassLoader.scala:53)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$11$$anonfun$13.apply(Gatling.scala:79)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$11$$anonfun$13.apply(Gatling.scala:79)
[INFO] at scala.Option.getOrElse(Option.scala:108)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$11.apply(Gatling.scala:79)
[INFO] at com.excilys.ebi.gatling.app.Gatling$$anonfun$11.apply(Gatling.scala:75)
[INFO] at scala.Option.getOrElse(Option.scala:108)
[INFO] at com.excilys.ebi.gatling.app.Gatling.start(Gatling.scala:75)
[INFO] at com.excilys.ebi.gatling.app.Gatling$.fromMap(Gatling.scala:64)
[INFO] at com.excilys.ebi.gatling.app.Gatling$.main(Gatling.scala:59)
[INFO] at com.excilys.ebi.gatling.app.Gatling.main(Gatling.scala)
So I figured the changes had been made since my last checkout …
Is this a bug or I’m supposed to use it differently?
So the original example (above in this thread) wasn't quite right:
val scn = scenario("myWebservice")
.randomSwitch {
50 -> exec(myPutRequest),
35 -> exec(myGetRequest),
15 -> exec(myPostRequest)
}
Though it worked when I removed the comas (cause the error it gave
seemed like the issue is with that) and it seemed to work then
hm ... so far it looks like the syntax-related error message from
scala are rather hard to figure out ;(
I presume that Gatling DSL makes it a bit worse ... may be some sort
of basic linter would help at this stage? or users do get used to it
after a while?