org.apache.qpid.test.framework.distributedtesting
Class Coordinator

java.lang.Object
  extended by junit.runner.BaseTestRunner
      extended by junit.textui.TestRunner
          extended by org.apache.qpid.junit.extensions.TestRunnerImprovedErrorHandling
              extended by org.apache.qpid.junit.extensions.TKTestRunner
                  extended by org.apache.qpid.test.framework.distributedtesting.Coordinator
All Implemented Interfaces:
junit.framework.TestListener

public class Coordinator
extends org.apache.qpid.junit.extensions.TKTestRunner

Implements the coordinator client described in the interop testing specification (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). This coordinator is built on top of the JUnit testing framework.

CRC Card
Responsibilities Collaborations
Find out what test clients are available. ConversationFactory
Decorate available tests to run on all available clients. DistributedTestDecorator
Attach XML test result logger.
Terminate the interop testing framework.

Todo:
Should accumulate failures over all tests, and return with success or fail code based on all results. May need to write a special TestResult to do this properly. At the moment only the last one used will be tested for errors, as the start method creates a fresh one for each test case run.

Nested Class Summary
static class Coordinator.TestEngine
          Defines the possible distributed test engines available to run coordinated test cases with.
 
Nested classes/interfaces inherited from class org.apache.qpid.junit.extensions.TKTestRunner
org.apache.qpid.junit.extensions.TKTestRunner.TestDecoratorFactory
 
Field Summary
protected  String brokerUrl
          Holds the URL of the broker to coordinate the tests on.
protected  Connection connection
          Holds the connection that the coordinating messages are sent over.
protected  ConversationFactory conversationFactory
          Holds the conversation helper for the control conversation.
protected  Coordinator.TestEngine engine
          Holds the coordinating test engine type to run the tests through.
protected  Set<TestClientDetails> enlistedClients
          Holds the list of all clients that enlisted, when the compulsory invite was issued.
protected  String reportDir
          Holds the path of the directory to output test results too, if one is defined.
protected  boolean terminate
          Flag that indicates that all test clients should be terminated upon completion of the test cases.
protected static org.apache.qpid.junit.extensions.util.ParsedProperties testContextProperties
          Holds the test context properties that provides the default test parameters, plus command line overrides.
protected  String virtualHost
          Holds the virtual host to coordinate the tests on.
 
Fields inherited from class org.apache.qpid.junit.extensions.TKTestRunner
csvResults, currentTestClassName, decoratorFactories, delay, duration, params, repetitions, result, testCaseName, testClassName, testRunName, threads, TIME_STAMP_FORMAT, xmlResults
 
Fields inherited from class junit.textui.TestRunner
EXCEPTION_EXIT, FAILURE_EXIT, SUCCESS_EXIT
 
Fields inherited from class junit.runner.BaseTestRunner
SUITE_METHODNAME
 
Constructor Summary
Coordinator(Integer repetitions, Long duration, int[] threads, int delay, int[] params, String testCaseName, String reportDir, String runName, boolean verbose, String brokerUrl, String virtualHost, Coordinator.TestEngine engine, boolean terminate, boolean csv, boolean xml, List<org.apache.qpid.junit.extensions.TKTestRunner.TestDecoratorFactory> decoratorFactories)
          Creates an interop test coordinator on the specified broker and virtual host.
 
Method Summary
 junit.framework.TestResult doRun(junit.framework.Test test, boolean wait)
          Runs a test or suite of tests, using the super class implemenation.
static Set<TestClientDetails> extractEnlists(Collection<Message> enlists)
          For a collection of enlist messages, this method pulls out of the client details for the enlisting clients.
static void main(String[] args)
          The entry point for the interop test coordinator.
protected  DistributedTestDecorator newTestDecorator(org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator targetTest, Set<TestClientDetails> enlistedClients, ConversationFactory conversationFactory, Connection connection)
          Creates a wrapped test decorator, that is capable of inviting enlisted clients to participate in a specified test.
 junit.framework.TestResult start(String[] testClassNames)
          Starts all of the test classes to be run by this coordinator.
 
Methods inherited from class org.apache.qpid.junit.extensions.TKTestRunner
applyOptionalUserDecorators, createTestResult, decorateTests, parseDecorators, registerShutdownHook, start
 
Methods inherited from class junit.textui.TestRunner
doRun, getLoader, pause, run, run, runAndWait, runFailed, runSingleMethod, setPrinter, testEnded, testFailed, testStarted
 
Methods inherited from class junit.runner.BaseTestRunner
addError, addFailure, clearStatus, elapsedTimeAsString, endTest, extractClassName, getFilteredTrace, getFilteredTrace, getPreference, getPreference, getPreferences, getTest, inMac, inVAJava, loadSuiteClass, processArguments, savePreferences, setLoading, setPreference, setPreferences, showStackRaw, startTest, truncate, useReloadingTestSuiteLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testContextProperties

protected static org.apache.qpid.junit.extensions.util.ParsedProperties testContextProperties
Holds the test context properties that provides the default test parameters, plus command line overrides. This is initialized with the default test parameters, to which command line overrides may be applied.


brokerUrl

protected String brokerUrl
Holds the URL of the broker to coordinate the tests on.


virtualHost

protected String virtualHost
Holds the virtual host to coordinate the tests on. If null, then the default virtual host is used.


enlistedClients

protected Set<TestClientDetails> enlistedClients
Holds the list of all clients that enlisted, when the compulsory invite was issued.


conversationFactory

protected ConversationFactory conversationFactory
Holds the conversation helper for the control conversation.


connection

protected Connection connection
Holds the connection that the coordinating messages are sent over.


reportDir

protected String reportDir
Holds the path of the directory to output test results too, if one is defined.


engine

protected Coordinator.TestEngine engine
Holds the coordinating test engine type to run the tests through.


terminate

protected boolean terminate
Flag that indicates that all test clients should be terminated upon completion of the test cases.

Constructor Detail

Coordinator

public Coordinator(Integer repetitions,
                   Long duration,
                   int[] threads,
                   int delay,
                   int[] params,
                   String testCaseName,
                   String reportDir,
                   String runName,
                   boolean verbose,
                   String brokerUrl,
                   String virtualHost,
                   Coordinator.TestEngine engine,
                   boolean terminate,
                   boolean csv,
                   boolean xml,
                   List<org.apache.qpid.junit.extensions.TKTestRunner.TestDecoratorFactory> decoratorFactories)
Creates an interop test coordinator on the specified broker and virtual host.

Parameters:
repetitions - The number of times to repeat the test, or test batch size.
duration - The length of time to run the tests for. -1 means no duration has been set.
threads - The concurrency levels to ramp up to.
delay - A delay in milliseconds between test runs.
params - The sets of 'size' parameters to pass to test.
testCaseName - The name of the test case to run.
reportDir - The directory to output the test results to.
runName - The name of the test run; used to name the output file.
verbose - Whether to print comments during test run.
brokerUrl - The URL of the broker to connect to.
virtualHost - The virtual host to run all tests on. Optional, may be null.
engine - The distributed test engine type to run the tests with.
terminate - true if test client nodes should be terminated at the end of the tests.
csv - true if the CSV results listener should be attached.
xml - true if the XML results listener should be attached.
decoratorFactories - List of factories for user specified decorators.
Method Detail

main

public static void main(String[] args)
The entry point for the interop test coordinator. This client accepts the following command line arguments:

-b The broker URL. Mandatory.
-h The virtual host. Optional.
-o The directory to output test results to. Optional.
-e The type of test distribution engine to use. Optional. One of: interop, fanout.
... Free arguments. The distributed test cases to run. Mandatory. At least one must be defined.
name=value Trailing argument define name/value pairs. Added to the test contenxt properties. Optional.

Parameters:
args - The command line arguments.

start

public junit.framework.TestResult start(String[] testClassNames)
                                 throws Exception
Starts all of the test classes to be run by this coordinator.

Overrides:
start in class org.apache.qpid.junit.extensions.TestRunnerImprovedErrorHandling
Parameters:
testClassNames - An array of all the coordinating test case implementations.
Returns:
A JUnit TestResult to run the tests with.
Throws:
Exception - Any underlying exceptions are allowed to fall through, and fail the test process.

extractEnlists

public static Set<TestClientDetails> extractEnlists(Collection<Message> enlists)
                                             throws JMSException
For a collection of enlist messages, this method pulls out of the client details for the enlisting clients.

Parameters:
enlists - The enlist messages.
Returns:
A set of enlisting clients, extracted from the enlist messages.
Throws:
JMSException - Any underlying JMSException is allowed to fall through.

doRun

public junit.framework.TestResult doRun(junit.framework.Test test,
                                        boolean wait)
Runs a test or suite of tests, using the super class implemenation. This method wraps the test to be run in any test decorators needed to add in the coordinators ability to invite test clients to participate in tests.

Overrides:
doRun in class org.apache.qpid.junit.extensions.TKTestRunner
Parameters:
test - The test to run.
wait - Undocumented. Nothing in the JUnit javadocs to say what this is for.
Returns:
The results of the test run.

newTestDecorator

protected DistributedTestDecorator newTestDecorator(org.apache.qpid.junit.extensions.WrappedSuiteTestDecorator targetTest,
                                                    Set<TestClientDetails> enlistedClients,
                                                    ConversationFactory conversationFactory,
                                                    Connection connection)
Creates a wrapped test decorator, that is capable of inviting enlisted clients to participate in a specified test. This is the test engine that sets up the roles and sequences a distributed test case.

Parameters:
targetTest - The test decorator to wrap.
enlistedClients - The enlisted clients available to run the test.
conversationFactory - The conversation factory used to build conversation helper over the specified connection.
connection - The connection to talk to the enlisted clients over.
Returns:
An invititing test decorator, that invites all the enlisted clients to participate in tests, in pairs.


Licensed to the Apache Software Foundation