loadtest4j-wrk

Wrk driver for loadtest4j.

License

License

GroupId

GroupId

org.loadtest4j.drivers
ArtifactId

ArtifactId

loadtest4j-wrk
Last Version

Last Version

0.14.0
Release Date

Release Date

Type

Type

jar
Description

Description

loadtest4j-wrk
Wrk driver for loadtest4j.
Project URL

Project URL

https://github.com/loadtest4j/loadtest4j-wrk
Source Code Management

Source Code Management

https://github.com/loadtest4j/loadtest4j-wrk

Download loadtest4j-wrk

How to add to project

<!-- https://jarcasting.com/artifacts/org.loadtest4j.drivers/loadtest4j-wrk/ -->
<dependency>
    <groupId>org.loadtest4j.drivers</groupId>
    <artifactId>loadtest4j-wrk</artifactId>
    <version>0.14.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.loadtest4j.drivers/loadtest4j-wrk/
implementation 'org.loadtest4j.drivers:loadtest4j-wrk:0.14.0'
// https://jarcasting.com/artifacts/org.loadtest4j.drivers/loadtest4j-wrk/
implementation ("org.loadtest4j.drivers:loadtest4j-wrk:0.14.0")
'org.loadtest4j.drivers:loadtest4j-wrk:jar:0.14.0'
<dependency org="org.loadtest4j.drivers" name="loadtest4j-wrk" rev="0.14.0">
  <artifact name="loadtest4j-wrk" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.loadtest4j.drivers', module='loadtest4j-wrk', version='0.14.0')
)
libraryDependencies += "org.loadtest4j.drivers" % "loadtest4j-wrk" % "0.14.0"
[org.loadtest4j.drivers/loadtest4j-wrk "0.14.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.loadtest4j : loadtest4j jar 0.19.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.8
org.apache.tika : tika-core jar 1.20

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.assertj : assertj-core jar 3.10.0
com.xebialabs.restito : restito jar 0.9.3

Project Modules

There are no modules declared in this project.

loadtest4j-wrk

Build Status Codecov Maven Central

Wrk driver for loadtest4j.

Prerequisites

Install the wrk executable on your $PATH:

  • Homebrew: run brew install wrk.
  • Compile-from-source: check out the instructions in .travis.yml.

Usage

With a new or existing Maven project open in your favorite editor...

1. Add the library

Add the library to your Maven project POM.

<dependency>
    <groupId>org.loadtest4j.drivers</groupId>
    <artifactId>loadtest4j-wrk</artifactId>
    <scope>test</scope>
</dependency>   

2. Create the load tester

Use either the Factory or the Builder.

Factory

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

Builder

LoadTester loadTester = WrkBuilder.withUrl("https://example.com")
                                  .withConnections(1)
                                  .withDuration(Duration.ofSeconds(30))
                                  .withThreads(1)
                                  .build();

3. Write load tests

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));
    }
}

Limitations

  • 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.
org.loadtest4j.drivers
A simple load test facade for Java.

Versions

Version
0.14.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.3