Wrk driver for loadtest4j.
Install the wrk
executable on your $PATH
:
- Homebrew: run
brew install wrk
. - Compile-from-source: check out the instructions in
.travis.yml
.
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-wrk</artifactId>
<scope>test</scope>
</dependency>
Use either the Factory or the Builder.
LoadTester loadTester = LoadTesterFactory.getLoadTester();
# src/test/resources/loadtest4j.properties
loadtest4j.driver.connections = 1
loadtest4j.driver.duration = 30
loadtest4j.driver.threads = 1
loadtest4j.driver.url = https://example.com
LoadTester loadTester = WrkBuilder.withUrl("https://example.com")
.withConnections(1)
.withDuration(Duration.ofSeconds(30))
.withThreads(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));
}
}
- The percentile distribution is accurate to 3 decimal places. For example, it can resolve a difference between the 99.998th percentile and the 99.999th percentile, but not a smaller step size.
- Wrk's design means it has to read files into memory for file uploads. Wrk will therefore break if you give it a large file.