Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Create and Run Gatling 2.0 Tests

DZone's Guide to

How to Create and Run Gatling 2.0 Tests

· Java Zone ·
Free Resource

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

Getting up and running with Gatling perf. tests as I would like so I record this for my future reference.

1.Create a project:

$ mvn archetype:generate -DarchetypeCatalog=http://repository.excilys.com/content/groups/public/archetype-catalog.xml Dfilter=io.gatling:

2.Record a simulation

  1. Run the src/test/scala/Recorder.scala (right-click – Run ‘Recorder’)
  2. Set the port it should listen on, f.ex. 8000 (maybe you also need to set port for HTTPS, f.ex. 8001), set the target app (perhaps localhost, <some port>, <some https/dummy port>)
  3. Optionally set the class name of the recorded simulation and the target package (the output goes to src/test/scala/<package>/<name>.scala)
  4. Click [Start !]
  5. Go to your browser and configure it to use the recorder as its HTTP[s] proxy
  6. Browse localhost:8000/your_app as you want for the test
  7. Click [Stop and save] in the Recorder UI

3.Modify the recorder simulation as you want

4.Run a simulation from the IDE

Modify src/test/scala/Engine.scala by adding the following:

props.runDescription("N/A") // do not ask for a descr. upon run
props.simulationClass("your_package.YourSimulation") // do not ask for a simulation to run upon run

Now run Engine as an app (right-clikc – Run ‘Engine’).

5. Make it possible to run via ‘mvn test’

Add this to your pom, adjust the includes/excludes as needed:

...
<pluginRepositories>
<pluginRepository>
<id>excilys</id>
<name>Excilys Repository</name>
<url>http://repository.excilys.com/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
...
<build>
<plugins>
<plugin>
<!-- Run all [matching] tests] on mvn test -->
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling.version}</version>
<configuration>
<simulationsFolder>src/test/scala</simulationsFolder>
<includes>
<include>**/your_package/*.scala</include>
</includes>
<!--excludes>
<exclude>**/SomeBadTest.scala</exclude>
</excludes-->
<!-- <simulationClass>foo.Bar</simulationClass> -->
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals><goal>execute</goal></goals>
</execution>
</executions>
</plugin>

Voilà, mvn test will now run the simulation(s?).

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}