Skip to content
amikryukov edited this page May 6, 2013 · 10 revisions

Jagger has archetype which contains some examples how you can add new possibilities.

For get it you must to create the new project from arhetype, like in Getting Started with parameter:

 -DarchetypeArtifactId=jagger-suite-archetype-examples 

Then input groupId, artifactId, version, and root package for generated project. After that you can load this project in IDE, and enjoy the simplicity of the Jagger.


Archetype contains some tests with custom elements. Let's see on this one by one.

Here is list:

  • Calculator
  • Distributor
  • Invoker
  • Provider
  • Validator
  • Groovy

After create project from archetype you will see structure like this:

  • java
    • calculator
      • ResponseSize.java - contains custom calculator
    • distributor
      • RandomQueryDistributor.java - contains custom distributor
    • groovy
      • GroovyInvokerDelegate.java - contains delegate for groovy invoker
      • GroovyScenarioSupplier.java - contains suppler for groovy scenario
    • invoker
      • PageVisitorInvoker.java - contains custom invoker
    • provider
      • FileReaderIterable - contains custom provider
    • validator
      • ResponseFromFileValidator - contains custom validator

Also there is some resource-files

  • resources
    • profiles
      • basic
        • environment.properties - properties for run Jagger
    • suite
      • distributor
        • distributor.conf.xml - contains bean with RandomQueryDistributor
      • groovy
        • sources
          • GroovyExampleScenarioFactory.groovy - source code of ScenarioFactory on groovy
          • GroovyPageVisitorInvoker.groovy - source code of Invoker on groovy
        • groovyscenario.conf.xml - contains bean with GroovyScenarioSupplier
      • invokers
        • groovyinvoker.conf.xml - contains bean with GroovyInvokerDelegate
        • invokers.conf.xml - contains bean with PageVisitorInvoker
      • provider
        • resources
          • endpoints.txt - contains list of endpoints for FileReaderIterable
          • queries.txt - contains list of queries for FileReaderIterable
        • fileprovider.conf.xml - contains beans with FileReaderIterable
      • validator
        • resources
          • response.txt - contains response for ResponseFromFileValidator
      • collectors.conf.xml - contains beans with ValidationCollectorProvider, ResponseSize
      • defaults.config.xml - contains default collectors
      • test.suite.conf.xml - contains configuration
      • test.suite.scenario.conf.xml - contains scenarios for configuration

ResponseSize, PageVisitorInvoker - That classes from the minimal archetype (Getting Started)

Now more about added things in this archetype.

RandomQueryDistributor - this distributor randomly, with uniform distribution, gets an endpoint and a query from the provider.

endpoint = endpoints.get(Math.abs(rand.nextInt(endpointSize())));
query = queries.get(Math.abs(rand.nextInt(querySize())));
return Pair.of(query, endpoint);

GroovyInvokerDelegate - this is delegate for groovy invoker. That takes groovy source, compiles it to class, then delegates method-calls to him.

private Invoker invoker;

@Override
public Object invoke(Object query, Object endpoint) throws InvocationException {
    ...
    return invoker.invoke(query,endpoint);
}

GroovyScenarioSupplier - this is a supplier for scenario factory (when you uses zookeeper coordinator), which creates scenario from groovy code

    private transient ScenarioFactory scenario;

    public synchronized Scenario get(NodeContext nodeContext) {
        ...
        return scenario.get(nodeContext);
    }

FileReaderIterable - this is an example of provider, which reads strings from file

public Iterator<String> iterator() {
    ...
    reader=new BufferedReader(new FileReader(new File(filePath)));
    while((str=reader.readLine())!=null){
        strings.add(str);
    }
    ...
    return strings.iterator();
}

ResponseFromFileValidator - this is an example of validator, which reads file, and comparing if with result of request

StringBuilder sb = new StringBuilder();
String fs = System.getProperty("line.separator");
scanner= new Scanner(new FileInputStream(filePath));
    while (scanner.hasNextLine()){
    sb.append(scanner.nextLine() + fs);
}
expectedResponse=sb.toString();
...
@Override
public boolean validate(Q query, E endpoint, R result, long duration) {
    ...
    return expectedResponse.equals(result);
}

Let's see at configuration:

  • jaggerTestSuit - test suite
    • fileProviderJaggerPageGroup
      • fileProviderTest - test, which uses file provider (1 thread, 100 iterations)
    • groovyInvokerGroup
      • invokerTest - test, which uses groovy invoker (1 thread, 100 iterations)
    • groovyScenarioGroup
      • groovyTest - test, which uses groovy scenario factory (1 tps, max 10 threads, 40 iterations)
    • randomDistributorGroup
      • jaggerRandomDistributorTest - test, which uses random distributor (100 tps, max 1000 threads, 1000 iterations)
    • fileValidatorGroup
      • fileValidatorTest - test, which uses fila validator (1 thread, 100 iterations)
    • myFirstSearchTest

Clone this wiki locally