How to bundle my Maven based gatling loadtest into one JAR?

[Also posted on http://stackoverflow.com/questions/27847999/how-to-bundle-my-maven-based-gatling-loadtest-into-one-jar]

I created a Gatling load test using the highcharts archetype. I decided against just downloading the latest Gatling ZIP file and creating a simulation within the extracted folder since I rely on a number of dependencies in public and private Maven repositories.

I want to

  1. bundle my simulation and all its dependencies into a single JAR,
  2. distribute the JAR to multiple load generators in EC2/GCE, and
  3. start the test on all remote load generators.

Maven’s assembly plugin looks like an obvious candidate to solve #1. So I added the following to my pom.xml:

<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <configuration>
    <archive>
      <manifest>
        <mainClass>io.gatling.app.Gatling</mainClass>
      </manifest>
    </archive>
    <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
  </configuration>
</plugin>

With this configuration, running a JAR file created with mvn clean package assembly:single results in the following NoSuchFileException:

$ java -jar target/myapp-0.1-SNAPSHOT-jar-with-dependencies.jar
Exception in thread "main" java.nio.file.NoSuchFileException: ./target/test-classes
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:407)
at java.nio.file.Files.newDirectoryStream(Files.java:457)
at io.gatling.core.util.PathHelper$RichPath$.deepListAux$1(PathHelper.scala:99)
at io.gatling.core.util.PathHelper$RichPath$.deepList$extension(PathHelper.scala:105)
at io.gatling.core.util.PathHelper$RichPath$.deepFiles$extension(PathHelper.scala)
at io.gatling.app.classloader.SimulationClassLoader.simulationClasses(SimulationClassLoader.scala:55)
at io.gatling.app.Gatling.loadSimulations(Gatling.scala:92)
at io.gatling.app.Gatling.start(Gatling.scala:70)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:59)
at io.gatling.app.Gatling$.main(Gatling.scala:44)
at io.gatling.app.Gatling.main(Gatling.scala)

  • Is this how I should bundle up my Maven based Gatling project?
  • Have I misconfigured Gatling’s Maven plugin at the time the JAR file is created?
    Thanks,
    Ingo

Hi,

We don’t support this set up.
You can pre-compile your simulations are ship them altogether with their resources (bodies, feeders) and their specific dependencies in a single jar.
But you can’t repackage Gatling.

Hey Stéphane,

thank you very much!

Can you clarify if you are suggesting the following:

  1. Use the maven assembly plugin to create a single JAR with all dependencies - This part already works.

  2. Precompile the simulations - How can I do that? Are you suggesting to precompile them with scalac directly or do I need to invoke zinc (which would normally be invoked by Gatling)?

  3. Run the precompiled simulation and add the single JAR to the class path. Do you mind outlining the details on that? E.g. would I customize the gatling.sh script out of the Gatling’s ZIP distribution to specify the precompiled simulations and the modified classpath?

Thanks,
Ingo

  1. Not exactly. It seems you ship all Gatling deps, which you shouldn’t. Only ship non Gatling libs.

  2. Use the scala-maven-plugin

  3. Just deploy in the lib folder.

  1. Not exactly. It seems you ship all Gatling deps, which you shouldn’t. Only ship non Gatling libs.

  2. Use the scala-maven-plugin

  3. Just deploy in the lib folder.