Gatling driver for loadtest4j.
With a new or existing Maven project open in your favorite editor...
Add the library to your Maven project POM.
<dependency>
<groupId>org.loadtest4j.drivers</groupId>
<artifactId>loadtest4j-gatling</artifactId>
<scope>test</scope>
</dependency>
Use either the Factory or the Builder.
LoadTester loadTester = LoadTesterFactory.getLoadTester();
# src/test/resources/loadtest4j.properties
loadtest4j.driver.duration = 60
loadtest4j.driver.url = https://example.com
loadtest4j.driver.usersPerSecond = 1
LoadTester loadTester = GatlingBuilder.withUrl("https://example.com")
.withDuration(Duration.ofSeconds(60))
.withUsersPerSecond(1)
.build();
Write load tests with your favorite language, test framework, and assertions. See the loadtest4j documentation for further instructions.
public class PetStoreLT {
private static final LoadTester loadTester = /* see step 2 */ ;
@Test
public void shouldFindPets() {
List<Request> requests = List.of(Request.get("/pet/findByStatus")
.withHeader("Accept", "application/json")
.withQueryParam("status", "available"));
Result result = loadTester.run(requests);
assertThat(result.getResponseTime().getPercentile(90))
.isLessThanOrEqualTo(Duration.ofMillis(500));
}
}
All advanced Gatling configuration can be specified in the usual gatling.conf
format. Create src/test/resources/gatling.conf
and place configuration overrides in there.
To reduce Gatling log output, change the log threshold for its noisiest classes in your SLF4J logger configuration.
If you are using Logback (the default Gatling logger), you could configure logback.xml
like this:
<configuration>
<!-- Set up the root logger and appender, then include these lines -->
<logger name="akka.event.slf4j.Slf4jLogger" level="OFF" />
<logger name="io.netty" level="OFF" />
<logger name="io.gatling" level="OFF" />
<logger name="org.asynchttpclient.netty" level="OFF" />
</configuration>