-
Notifications
You must be signed in to change notification settings - Fork 15
PerfRepo Java client
This article describes PerfRepo Java client. For a description of raw REST API refer to REST API Wiki page.
For easier uploading into PerfRepo, we provide PerfRepo Java client. It's use is more than trivial. You create test execution via builder fluent API and then directly upload it into running instance of PerfRepo. Let's see step by step "tutorial" and then a complete example.
PerfRepo client is also uploaded in Maven Central to maximize easiness of the usage. To use PerfRepo Java client, add following dependency into you pom.xml
. Please, make sure that you use the came version of client as PerfRepo deployed on your application server. However, we try to keep backward compatibility in REST API, so the need for upgrade of client version should be less than rare.
<dependency>
<groupId>org.perfrepo</groupId>
<artifactId>perfrepo-client</artifactId>
<version>${version.perfrepo}</version>
</dependency>
First we have to create test execution via test execution builder, so we create the builder.
TestExecutionBuilder builder = TestExecution.builder();
And now, we add all the properties we want to the test execution. Let's start with assigning the test execution to test via test ID or string test UID.
builder.testId(1L);
//or builder.testUid("test UID");
Name the test execution appropriately for convenience.
builder.name("JDG Client server build #77");
Set date (time) of the test execution.
builder.started(new Date());
Attach as many tags as you want.
builder.tag("distributed mode");
builder.tag("tcp");
Attach as many parameters as you want.
builder.parameter("git commit message", "[PERFREPO-1] Create REST client Wiki");
builder.parameter("jenking build number", "77");
Attach values. For single-value, provide one value per metric.
builder.value("throughput", 77777);
For multi-value, provide as many values per metric as you want. For more info, you specify value parameter to identify, where the value came from.
builder.value("requests/sec", 1000, "Client load", "10");
builder.value("requests/sec", 800, "Client load" "20");
Add additional comment of the test execution.
builder.comment("This is a checkrun executed for JIRA verification");
The test execution builder is now ready to actually build the test execution.
TestExecution testExecution = builder.build();
Now it's time to start the client. The second parameter for PerfRepoClient constructor is the context path of the server on the specified host. If PerfRepo is running on the root URL, the context path is empty (in our case).
String host = "localhost";
PerfRepoClient client = new PerfRepoClient(host, "", login, password);
Everything is ready, so upload the test execution right away into PerfRepo.
client.createTestExecution(testExecution);
Let's summarize the whole example, the example is shortened to fully exploit the fluent-API.
TestExecution testExecution = TestExecution.builder()
.testId(1L)
.name("JDG Client server build #77")
.started(new Date())
.tag("distributed mode")
.tag("tcp")
.parameter("git commit message", "[PERFREPO-1] Create REST client Wiki")
.parameter("jenking build number", "77")
.value("throughput", 77777.0)
.value("requests/sec", 1000.0, "Client load", "10")
.value("requests/sec", 800.0, "Client load", "20")
.comment("This is a checkrun executed for JIRA verification")
.build();
String host = "localhost";
PerfRepoClient client = new PerfRepoClient(host, "", login, password);
client.createTestExecution(testExecution);