Jagger
 All Classes Namespaces Files Functions Variables Groups Pages
Creating load test

Main terms

Before discussing load tests development, let's agree on the following terms. These names will be used in the whole documentation

  • System under test (SUT) - application (or group of applications) under test
  • Endpoint - where we are applying load. In case of http protocol, it can be URI
  • Endpoint provider - source of the test data (endpoints)
  • Query - what parameters we are sending
  • Query provider - source of the test data (queries)
  • Distributor - component, responsible to combine endpoints and queries in different order (one by one, round robin, unique combinations, etc)
  • Invoker - component, providing requests to SUT during load test. In case of http protocol - http client
  • Validator - component that verifies responses from SUT - decides if response is valid or not. In case of http we can verify that return codes are always 200
  • Metric - component that measures some parameter of the response (response time, throughput, success rate of requests, custom parameters)

Java test project

We consider that at this point, you have already installed the framework and learned how to execute the test

Now let's look inside the test project and review what is there. Created test project will have following components:

  • Load scenario provider(s) - component where load tests are defined
  • Test data provider(s) - endpoint and query providers. Sources of the test data
  • Config - support component, where you should register (create a bean with @Bean annotation) your scenario to make it visible for the framework

In short, test development will consist of creating test data sources, creating load scenarios, registering load scenarios in the config file

Load scenario

Load scenario describes the execution sequence of the load tests. While there are multiple scenarios in the test project, only single one can be executed at a time
Let's take a look what components does the load scenario consist of

  • Load scenario. It describes the sequence of the parallel test groups execution. This is the entity that can be executed by the framework
  • Parallel test group. It describes what load tests will be executed in parallel. Parallel test group can contain one or multiple load tests
  • Load test. It describes:
    • What load profile will be used
    • When the load test should be terminated
      see more information in the section below
  • Test definition. It describes
    • Where and how to read test data
    • What protocol to use for communication with the SUT
    • How to verify if responses from the SUT are valid
      see more information in the section below

Load scenario configuration

Create load scenario
// begin: following section is used for docu generation - Load test scenario configuration
public class ExampleSimpleJLoadScenarioProvider {
public static JLoadScenario getExampleJaggerLoadScenario() {
JTestDefinition jTestDefinition = JTestDefinition.builder(Id.of("td_example"), new ExampleEndpointsProvider()).build();
JLoadProfile jLoadProfileRps = JLoadProfileRps.builder(RequestsPerSecond.of(10)).withMaxLoadThreads(10).withWarmUpTimeInSeconds(10).build();
JTerminationCriteria jTerminationCriteria = JTerminationCriteriaIterations.of(IterationsNumber.of(500), MaxDurationInSeconds.of(30));
JLoadTest jLoadTest = JLoadTest.builder(Id.of("lt_example"), jTestDefinition, jLoadProfileRps, jTerminationCriteria).build();
JParallelTestsGroup jParallelTestsGroup = JParallelTestsGroup.builder(Id.of("ptg_example"), jLoadTest).build();
// To launch your load scenario, set 'jagger.load.scenario.id.to.execute' property's value equal to the load scenario id
// You can do it via system properties or in the 'environment.properties' file
return JLoadScenario.builder(Id.of("ls_example"), jParallelTestsGroup).build();
}
}
// end: following section is used for docu generation - Load test scenario configuration
Register load scenario in the framework
// begin: following section is used for docu generation - Load test scenario registering
@Bean
public JLoadScenario exampleSimpleJaggerLoadScenario() {
return ExampleSimpleJLoadScenarioProvider.getExampleJaggerLoadScenario();
}
// end: following section is used for docu generation - Load test scenario registering

Load test

Below is the list of available load profiles and termination criteria:


Test definition

Test definition components
writing_test_test_definition.png
Test definition components

On the image above you can see relation of the different components of the test definition. Test data, provided
by endpoint and query providers, is combined by the distributor to the set of the requests. During the load test
this set of the requests is passed to the invoker. Invoker is providing communication with the SUT and returning responses.
Responses are verified by validators to take pass/fail decision and processed by metrics to collect some measurements.
During the run time every virtual user is working with it's own invoker, thus allowing to generate load.
TODO: links to jagger components for providers, invokers, etc

Test definition for HTTP configuration

Support of Http
Out of the box Jagger support http load tests. To make work with http easier, we have prepared set of classes to describe Test definition for HTTP
  • DefaultHttpInvoker - Http invoker. Used by default for all test definitions
  • JHttpEndpoint - Http endpoint.
  • JHttpQuery - Http query.
  • JHttpResponse - Http response. Represents response from the SUT
  • JHttpValidator - TODO in development
To create your first load test using http, you need to create an endpoint provider, like in the example below.
Query provider is optional
Examples of the endpoint provider for Test definition configuration
// begin: following section is used for docu generation - Endpoint provider
public class ExampleEndpointsProvider implements Iterable {
private List<JHttpEndpoint> endpoints = new ArrayList<>();
// Simple example of endpoint provider
// Constructor will be triggered during spring bean creation at Jagger startup
// Later distributor will invoke iterator method to get endpoints
public ExampleEndpointsProvider() {
// Put custom code here to get endpoints
// In our case they will be hardcoded
JHttpEndpoint httpEndpoint = new JHttpEndpoint(URI.create("https://jagger.griddynamics.net:443"));
endpoints.add(httpEndpoint);
}
@Override
public Iterator<JHttpEndpoint> iterator() {
return endpoints.iterator();
}
}
// end: following section is used for docu generation - Endpoint provider
Examples of the query provider for Test definition configuration
// begin: following section is used for docu generation - Query provider
public class ExampleQueriesProvider implements Iterable {
@Override
public Iterator iterator() {
List<JHttpQuery> queries = new ArrayList<>();
queries.add(new JHttpQuery()
.get()
.path("index.html"));
queries.add(new JHttpQuery()
.get()
.responseBodyType(String.class)
.path("screenshots.html"));
queries.add(new JHttpQuery()
.get()
.responseBodyType(String.class)
.path("download.html"));
return queries.iterator();
}
}
// end: following section is used for docu generation - Query provider