Gatling 2 with sbt

I’ve been trying to use sbt 0.13.1 to build and run simulations based on gatling 2.0.0-M3. I found a plugin here https://github.com/gatling/gatling-sbt but no documentation on how to actually use it to run a simulation. Any guidelines on that?

Please note that Gatling SBT plugin plugin is currently compatible with snapshots and will be compatible with the upcoming M4.

The plugin is not currently published on Sonatype, I’ll fix that this week end.
Meanwhile you can build a snapshot if you like.

You’ll need to add the SBT plugin (example here : https://github.com/gatling/gatling-sbt/blob/master/sbt-test/project/plugins.sbt) and provided the necessary configuration (example here : https://github.com/gatling/gatling-sbt/blob/master/sbt-test/project/TestBuild.scala).

Please note that you can’t use it with .sbt files currently, you’ll need .scala build files ( .configs(…) is not available in .sbt files).
This is temporary and this limitation will be dropped as soon as possible.

Basically, Gatling’s SBT plugin allows to use Gatling as a testing framework: you’ll be able to run your simulations with gatling:test, gatling:testOnly, gatling:testQuick… in the same way you would do with any other testing framework.

The plugin also offers two other tasks :

  • gatling:startRecorder, which launches the Recorder pre-configured to write recorded simulations to your tests sources folder.
  • gatling:lastReport, which opens the last generated report in your default web browser

I’ll provide a more detailed documentation this week-end, but this should allow you to start working with Gatling’s SBT plugin :slight_smile:

Cheers,

Pierre

Awesome. That’s exactly what I was looking for. With a detailed documentation if you put a tiny sbt project with a basic simulation class, it’ll be even more helpful.

This tiny sbt project already exists : it’s sbt-test, which can be found in the plugin’s repo : https://github.com/gatling/gatling-sbt/tree/master/sbt-test

You’ll need to build the plugin first but after that, you can load the sbt-test project and use the plugin right away.

Cheers,

Pierre

@Pierre: if you don’t mind, I’ll paste parts of this thread in the README file so that people can get a temporary documentation.

@Pierre Got it. Thanks.

Ok I tried to run a simulation (verified and running with gatling-maven) with gatling-sbt plugin. I got the following exception:

[error] Uncaught exception when running my.MySimulation: java.lang.NoSuchMethodError: io.gatling.app.Gatling$.runGatling([Ljava/lang/String;Lscala/Option;)I

sbt.ForkMain$ForkError: io.gatling.app.Gatling$.runGatling([Ljava/lang/String;Lscala/Option;)I

at io.gatling.sbt.GatlingTask.liftedTree1$1(GatlingTask.scala:22)

at io.gatling.sbt.GatlingTask.execute(GatlingTask.scala:21)

at sbt.ForkMain$Run.runTest(ForkMain.java:243)

at sbt.ForkMain$Run.runTestSafe(ForkMain.java:214)

at sbt.ForkMain$Run.runTests(ForkMain.java:190)

at sbt.ForkMain$Run.run(ForkMain.java:257)

at sbt.ForkMain.main(ForkMain.java:99)

[info] Simulation(s) execution ended.

Are you using the plugin with a snapshot or with 2.0.0-M3a ?
The SBT plugin required some modifications that are only present in 2.0.0-SNAPSHOT.

Yes 2.0.0-SNAPSHOT is not getting resolved at all.

You’ll need to add Sonatype’s snapshots repository to your list of resolvers : https://oss.sonatype.org/content/repositories/snapshots/ .
SBT will then be able to resolve Gatling’s snapshots.
Please note that a lot of stuff has changed since M3a, you’ll probably need to migrate your simulations.

Got it done. Luckily I haven’t hit any major incompatibilities so far except this:

not found: value ramp

[error] setUp(scen.inject(nothingFor(2 seconds), ramp(5 users) over (10 seconds))).protocols(httpConf)

[error] ^

Are these changes being documented somewhere?

I mentioned this change yesterday on this list.

Basically, we dropped the “users” and “usersPerSec” units.

So, ramp => rampUsers or rampUsersPerSec

Yeah I changed that to rampUsers and things are fine with this basic simulation. In the meantime, it’ll be great if these changes were aggregated into a small wiki page. Thanks for the plugin.

Better than that: we’re moving the doc out of Github wiki.

I’m sure it’ll turn out to be better for gatling. I’ve been enjoying every bit of using this project. It should go to masses.

Hey I was wondering if there is any update on the status of this plug, and how to get started with it.

I’ve had no luck, and the links to the example projects have moved.

Could someone post an example.sbt and/org .scala configuration with a few simulations in it?

.joe

Hi Joe,

The README on gatling-sbt’s repository includes a setup guide : https://github.com/gatling/gatling-sbt

Cheers,

Pierre

It’s not super clear. I copied and paste those lines into my .sbt configration and it complained about the .settings call.

When I removed it, the tasks didn’t show up inside of sbt.

You’ll have to forgive me I’m a bit of a noob when it comes to sbt.

.joe

A few things :

  • Do you have a build.properties in the project/ folder with sbt.version=0.13.5 in it ? Gatling’s SBT plugin is an AutoPlugin, and AutoPlugins require a fairly recent version of SBT
  • Did you add the plugin in a project/plugins.sbt file ?
  • What does SBT tells you exactly when it failed to load your configuration ?

Currently It’s failing in two places.

It appears to have some trouble finding the compiler interface jar (this is from inside intellij)

[warn] Binary version (2.10) for dependency org.scala-lang#scala-compiler;2.10.4
[warn] in api-stress-test#api-stress-test$sources_javadoc_2.11;1.0 differs from Scala binary version in project (2.11).
[warn] Binary version (2.10) for dependency org.scala-lang#scala-reflect;2.10.4
[warn] in api-stress-test#api-stress-test$sources_javadoc_2.11;1.0 differs from Scala binary version in project (2.11).
[warn] Binary version (2.10) for dependency org.scala-lang#scala-swing;2.10.4
[warn] in api-stress-test#api-stress-test$sources_javadoc_2.11;1.0 differs from Scala binary version in project (2.11).
[warn] [FAILED ] com.typesafe.sbt#compiler-interface;0.13.5!compiler-interface.jar: (0ms)
[warn] ==== local: tried
[warn] /Users/joe/.ivy2/local/com.typesafe.sbt/compiler-interface/0.13.5/jars/compiler-interface.jar
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/typesafe/sbt/compiler-interface/0.13.5/compiler-interface-0.13.5.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: FAILED DOWNLOADS ::
[warn] :: ^ see resolution messages for details ^ ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbt#compiler-interface;0.13.5!compiler-interface.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::

When I run from the console it spews the following:

=> Seq[sbt.Def.Setting[_]]

cannot be applied to (sbt.SettingKey[Seq[sbt.ModuleID]])

.settings(libraryDependencies)

^

sbt.compiler.EvalException: Type error in expression

at sbt.compiler.Eval.checkError(Eval.scala:384)

at sbt.compiler.Eval.compileAndLoad(Eval.scala:183)