-
Notifications
You must be signed in to change notification settings - Fork 0
Workload Generation
#Workload Generation
To start working with Jagger you have to define configuration, a list of tasks that will be executed one-by-one. Jagger at nutshell is an extensible tool that can execute tasks of different nature.
To be able to execute the task special object called Distributor should be defined is spring configuration. Distributor is responsible for distributes tasks across the nodes.
One of the tasks shipped with Jagger out of the box is a workload task. WorkloadTask is used to configure workload on a system under test.
Example of workload task that creates workload on http://google.com server is listed below:
<bean id="googleHomePageWorkload" class="com.griddynamics.jagger.engine.e1.scenario.WorkloadTask">
<property name="name" value="google-home-page-workload"/>
<property name="version" value="1"/>
<property name="scenarioFactory">
<bean class="com.griddynamics.jagger.invoker.QueryPoolScenarioFactory">
<property name="loadBalancer">
<bean class="com.griddynamics.jagger.invoker.SimpleLoadBalancer">
<constructor-arg index="0">
<value type="com.griddynamics.jagger.util.Nothing">INSTANCE</value>
</constructor>
<constructor-arg index="1" value="http://google.com" />
</bean>
</property>
<property name="invokerClass" value="com.griddynamics.jagger.invoker.http.HttpVisitorInvoker"/>
</bean>
</property>
<property name="collectors">
<list>
<ref bean="durationCollector"/>
<ref bean="informationCollector"/>
</list>
</property>
<property name="clockConfiguration">
<bean class="com.griddynamics.jagger.engine.e1.scenario.VirtualUsersClockConfiguration">
<property name="tickInterval" value="1000"/>
<property name="users" value="50"/>
</bean>
</property>
<property name="terminateStrategyConfiguration">
<bean class="com.griddynamics.jagger.engine.e1.scenario.TerminateByDuration">
<property name="seconds" value="30"/>
</bean>
</property>
</bean>
-
name
andversion
– Task is named asgoogle-home-page-workload
and it's version is1
.Name
andversion
are used for report generation and session comparation -
scenarioFactory
– Defines algorithm of workload. Invocation of http://google.com page via http protocol is specified. See invokers API. -
collectors
– List of collectors responsible for gathering information during workload. Duration and inforamtion collectors are specified. -
clockConfiguration
– Workload clock configuration. Jagger will simulate 50 virtual users workload. -
terminateStrategyConfiguration
– Termination strategy configuration. Workload will be terminated after 30 seconds.
Jagger has a flexible configuration of remote services invocation strategy. Invokers and Scenarios are the core concepts to work with.
Invoker
is responsible for invocation of services on SuT with specified query and endpoint. It encapsulates protocol and transport of remote service execution. Jagger allows to invoke rest, soap and hessian services out of the box.
com.griddynamics.jagger.invoker.http.HttpInvoker
and com.griddynamics.jagger.invoker.soap.SOAPInvoker
can be simply used for configuartion but
com.griddynamics.jagger.invoker.hessian.HessianInvoker
is an abstract class and you have to create your own implementation and override invokeService()
method. For example:
public class SearchProductsInvoker extends HessianInvoker<CatalogService, ProductQueryDTO, ProductIDResultSetDTO> {
@Override
protected Class<CatalogService> getClazz() {
return CatalogService.class;
}
@Override
protected ProductIDResultSetDTO invokeService(CatalogService service, ProductQueryDTO query) {
try {
return service.searchProducts(query);
} catch (DataObjectNotFoundException e) {
throw Throwables.propagate(e);
}
}
}
Scenario
is responsible for interaction with the SuT. It holds state of communicaion and is not thread safe.
ScenarioFactory
creates scenario instance for each thread during workload task execution.
QueryPoolScenarioFactory
is a default implementation of ScenarioFactory
. It allows to perform workload with multiple queries across several endpoints.
Query pool scenario requires load balancer algorithm to be defined. Two load balancers can be used:
-
RoundRobinLoadBalancer
- Encapsulates round robin algorithm. For input: endpoints [e1, e2] and queries [q1, q2, q3] returns (invoker, query) pairs in following order: (e1, q1), (e2, q2), (e1, q3), (e2, q1), (e1, q2), (e2, q3). -
OneByOneLoadBalancer
- Schedules queries across endpoints one by one. For input: endpoints [e1, e2] and queries [q1, q2, q3] executes actions in following order: (e1, q1), (e2, q1), (e1, q2), (e2, q2), (e1, q3), (e2, q3).
Tasks and scenarios in jagger are able to emit events during execution. This events are processed by special objects called Collectors. For workload tasks following collectors are available in with jagger distribution:
-
DurationCollector
- Collects duration of the invocation. -
InformationCollector
- Collects number of failures and total invocations count. -
ValidationCollector
- Allows to validate responses using custom validator
Workload generation strategy is plugable. WorkloadTask distributor uses WorkloadClock to adjust workload strategy. It can be configured using clockConfiguration property. Two clocks are available out of the box:
-
com.griddynamics.jagger.engine.e1.scenario.TpsClockConfiguration
- Maintains a certain level of total throughput controlled by feedback from kernel. Total throughput can be specified as an arbitrary function of time. -
com.griddynamics.jagger.engine.e1.scenario.VirtualUsersClockConfiguration
- Allows to specify fixed number of virtual users
Workload tasks allows to configure termination strategy. Termination strategy defines workload stop condition. There is two default termination strategies available with jagger distribution:
-
TerminateByTotalSampling
- stops when total number of invocations reached the limit -
TerminateByDuration
- performs execution in specified time interval
- Define invoker
At kernel side spring configuration file define bean that implements
com.griddynamics.jagger.invoker.Invoker
interface - Define scenario factory
In spring configuration file define bean that implements
com.griddynamics.jagger.invoker.ScenarioFactory
.QueryPoolScenarioFactory
can be used.<bean id="searchProductScenario" class="com.griddynamics.jagger.invoker.QueryPoolScenarioFactory"> <property name="loadBalancer"> <bean class="com.griddynamics.jagger.invoker.RoundRobinLoadBalancer"> <constructor-arg> <bean class="com.griddynamics.jagger.demo.macys.SearchProductsQueryPool"> </bean> </constructor-arg> <constructor-arg> <list> <value></value> </list> </constructor-arg> </bean> </property> <property name="invokerClass" ref="com.griddynamics.jagger.demo.macys.SearchProductsInvoker"/> </bean>
- Define workload task
In spring configuration define instance of class
com.griddynamics.jagger.engine.e1.scenario.WorkloadTask
. Define workload clock configuration and termination strategy.<bean id="searchProducts" class="com.griddynamics.jagger.engine.e1.scenario.WorkloadTask"> <property name="name" value="search-products"/> <property name="version" value="1" /> <property name="scenarioFactory" ref="searchProductScenario" /> <property name="clockConfiguration"> <bean class="com.griddynamics.jagger.engine.e1.scenario.VirtualUsersClockConfiguration"> <property name="tickInterval" value="1000"/> <property name="users" value="10"/> </bean> </property> <property name="terminateStrategyConfiguration"> <bean class="com.griddynamics.jagger.engine.e1.scenario.TerminateByDuration"> <property name="seconds" value="180"/> </bean> </property> </bean>
- Define configuration
In spring configuration define instance of class
com.griddynamics.jagger.master.configuration.Configuration
and specify list of tasks.com.griddynamics.jagger.master.CompositeTask
can be used to define parallel task execution.<bean id="configuration" class="com.griddynamics.jagger.master.configuration.Configuration"> <property name="tasks"> <list> <ref id="searchProducts"/> </list> </property> </bean>
TODO