Running Gatling with Leiningen

Hello,

I have had quite a bit of trouble integrating Gatling into something I am working on. The main reason is being that I am not a huge fan of Maven and find it rather very painful to work with.

So I found that Leiningen is much easier to use, so here is the gits: https://gist.github.com/4517937

It make my life much easier, hopefully it will help others too!
Note that your project doesn’t need to be written in Clojure in order to take advantage of this.
Leiningen is very simple to install, all you need is a shell script in your path and JVM installed (see http://leiningen.org/).

You can just use this type of structure -

  1. create a subdirectory load_test
  2. copy https://gist.github.com/4517937 into load_tests/project.clj
  3. put Gatling scenarios into load_tests/scenarios/
  4. cd load_test; lein run --

Please note that Leiningen will download all the dependencies on the first run, but will not do it again :slight_smile:
You could also use lein uberjar to build one big jar of everything, but I have figured out how to include compiled simulations into it as ZincCompiler gets on my way ;(

It works nevertheless!

Cheers,

Hi Ilya,

Maybe that’s because I’m not a Clojure developer, but I fail to see what you gain using Leiningen, compared to using the gatling bundles? IDE or clojure project integration maybe?

Cheers,

Stéphane

Well, I have just had another look at the gatling-charts-highcharts-1.4.1 tarball that you guys are shipping currently via Google Drive.
I did find it quite useful when I got started with Gatling, but then I wanted to do an number of thing differently, so I’ve looked into maven plugin. The tarball is good, but it’s more suited for adding simulation on top of the boilerplate, and I’d need to modify bin/gatling.sh in order to achieve something I wanted.

Well, I just see that the kind of approach maven plugin has, would suite me better, it seemed quite a bit more automation-friendly.
Although, I wasn’t able to make good friends with maven, it’s just to painful to use from automation perspective.

Also, by the way, the bundled tarball has an incredibly awful URL to start with. To use it, I need to be able to tell which version of Gatling I’ll get from the URL I’m fetching, as it all needs to be put in scripts and Puppet manifests.

So basically the Leiningen is maven wrapper written in Clojure. It’s just so much easier to write project.clj comparing to damn pom.xml!

So I get lein to fetch all the jars and then call lein classpath which outputs just what I want to pass to java command.
Also, actually, I start JVM by means of running JRuby script and calling com.excilys.ebi.gatling.app.Gatling.runGatling from there with arguments being defined and some and some JVM properties being set by JRuby. Once runGatling exits, I want to post-process the result from the JRuby context, as that is the language I am most comfortable with.

So that’s the kind of fun I’ve been having :slight_smile:

So to summarise, the thing is that I’d fetch Gatling jars via mvn, but I prefer to type lein, which has just one extra letter but I don’t have to touch XML :wink:

Cheers,

OK, got it. The idea is interesting, so we might end up documenting this on our wiki (if you don’t mind).

I have a few questions:

Hi Stephane,

OK, got it. The idea is interesting, so we might end up documenting this on our wiki (if you don’t mind).

I have a few questions:

  • Is it possible to centralize gatling and gatling-highcharts version into a single variable, such as it’s done for min-lein-version?

Yeah, there must be a way …

  • Why not stick to gatling standard, and store the simulations in simulations, instead of scenarios?

Sure, “scenarios” directory name is something I just made up :slight_smile:
If your putting this on the wiki, sure thing - go with the standard.

  • What about other resource folders, such as data and request-bodies?

By default Leiningen puts “resources” subdirectory into the classpath.
You can do something like :resource-paths ["request-bodies", "conf"].

I have actually figured something better!

Leiningen has this feature of being able to generate projects from a template so one can do this from within their project:

lein new gatling load-test

ls -R load-test/
load-test/:
conf data project.clj request-bodies simulations

load-test/conf:
gatling.conf logback.xml

load-test/data:

load-test/request-bodies:

load-test/simulations:

cd load-test
vim simulations/tryThis.scala
lein run

So the code is here: https://github.com/errordeveloper/gatling-lein-template
and it’s already available here: https://clojars.org/gatling/lein-template

So to get started you need to get lein command: http://leiningen.org/#install
and then run lein new gatling my-first-gatling-load-test. Very easy :slight_smile:

Pull-requests are welcome :wink:

Cheers,

I mentionned you gist on our third parties page: https://github.com/excilys/gatling/wiki/Third-parties

Cheers,

Stéphane

Thanks :slight_smile:

Thanks to you.
I’ll make this page more sexy as soon as I find time…