org.apache.qpid.test.framework.distributedcircuit
Class DistributedCircuitImpl

java.lang.Object
  extended by org.apache.qpid.test.framework.distributedcircuit.DistributedCircuitImpl
All Implemented Interfaces:
org.apache.qpid.junit.extensions.TimingControllerAware, Circuit

public class DistributedCircuitImpl
extends Object
implements Circuit, org.apache.qpid.junit.extensions.TimingControllerAware

DistributedCircuitImpl is a distributed implementation of the test Circuit. Many publishers and receivers accross multiple machines may be combined to form a single test circuit. The test circuit extracts reports from all of its publishers and receivers, and applies its assertions to these reports.

CRC Card
Responsibilities Collaborations
Supply the publishing and receiving ends of a test messaging circuit.
Start the circuit running.
Close the circuit down.
Take a reading of the circuits state.
Apply assertions against the circuits state.
Send test messages over the circuit.
Perform the default test procedue on the circuit.

Todo:
There is a short pause after receiving sender reports before asking for receiver reports, because receivers may not have finished receiving all their test messages before the report request arrives. This is going to be a problem for taking test timings and needs to be eliminiated. Suggested solution: have receiver send back reports asynchronously, on test batch size boundaries, and do so automatically rather than having to have the report request sent to them. Number each test run, or otherwise uniquely identify it, when a receiver does not get any more messages on a test run for more than a timeout, it can assume the test is complete and send a final report. On the coordinator end a future will need to be created to wait for all final reports to come in, and to register results and timings for the test. This must work in such a way that a new test cycle can be started without waiting for the results of the old one to come in., Add in setting of timing controller, from timing aware test cases.

Field Summary
protected  Session controlSession
          Holds the controlSession over which to hold the control conversation.
protected  ConversationFactory conversationFactory
          Holds the conversation factory over which to coordinate the test.
protected  int numMessages
          Holds the number of messages to send per test run.
protected  Destination[] receiverControlTopic
          Holds the control topics for the receivers in the test circuit.
protected  ConversationFactory.Conversation[] receiverConversation
          Holds the receiver control conversations.
protected  List<TestClientDetails> receivers
          Holds the receiver nodes in the test circuit.
protected  Destination[] senderControlTopic
          Holds the control topics for the senders in the test circuit.
protected  ConversationFactory.Conversation[] senderConversation
          Holds the sender control conversations.
protected  List<TestClientDetails> senders
          Holds the sender nodes in the test circuit.
(package private)  org.apache.qpid.junit.extensions.TimingController timingController
          Holds the timing controller for the circuit.
 
Constructor Summary
protected DistributedCircuitImpl(Session session, List<TestClientDetails> senders, List<TestClientDetails> receivers, ConversationFactory.Conversation[] senderConversation, ConversationFactory.Conversation[] receiverConversation, Destination[] senderControlTopic, Destination[] receiverControlTopic)
          Creates a distributed test circuit on the specified senders and receivers.
 
Method Summary
 List<Assertion> applyAssertions(List<Assertion> assertions)
          Applies a list of assertions against the test circuit.
 void check()
          Checks the test circuit.
 void close()
          Closes the circuit.
static Circuit createCircuit(org.apache.qpid.junit.extensions.util.ParsedProperties testProps, List<TestClientDetails> senders, List<TestClientDetails> receivers, ConversationFactory conversationFactory)
          Creates a distributed test circuit from the specified test parameters, on the senders and receivers given.
 Publisher getPublisher()
          Gets the interface on the publishing end of the circuit.
 Receiver getReceiver()
          Gets the interface on the receiving end of the circuit.
 void setTimingController(org.apache.qpid.junit.extensions.TimingController controller)
          Used by tests cases that can supply a TimingController to set the controller on an aware test.
 void start()
          Connects and starts the circuit.
 List<Assertion> test(int numMessages, List<Assertion> assertions)
          Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conversationFactory

protected ConversationFactory conversationFactory
Holds the conversation factory over which to coordinate the test.


controlSession

protected Session controlSession
Holds the controlSession over which to hold the control conversation.


senders

protected List<TestClientDetails> senders
Holds the sender nodes in the test circuit.


receivers

protected List<TestClientDetails> receivers
Holds the receiver nodes in the test circuit.


senderConversation

protected ConversationFactory.Conversation[] senderConversation
Holds the sender control conversations.


receiverConversation

protected ConversationFactory.Conversation[] receiverConversation
Holds the receiver control conversations.


senderControlTopic

protected Destination[] senderControlTopic
Holds the control topics for the senders in the test circuit.


receiverControlTopic

protected Destination[] receiverControlTopic
Holds the control topics for the receivers in the test circuit.


numMessages

protected int numMessages
Holds the number of messages to send per test run.


timingController

org.apache.qpid.junit.extensions.TimingController timingController
Holds the timing controller for the circuit. This is used to log test times asynchronously, when reciever nodes return their reports after senders have completed a test case.

Constructor Detail

DistributedCircuitImpl

protected DistributedCircuitImpl(Session session,
                                 List<TestClientDetails> senders,
                                 List<TestClientDetails> receivers,
                                 ConversationFactory.Conversation[] senderConversation,
                                 ConversationFactory.Conversation[] receiverConversation,
                                 Destination[] senderControlTopic,
                                 Destination[] receiverControlTopic)
Creates a distributed test circuit on the specified senders and receivers.

Parameters:
session - The controlSession for all control conversations.
senders - The senders.
receivers - The receivers.
senderConversation - A control conversation with the senders.
receiverConversation - A control conversation with the receivers.
senderControlTopic - The senders control topic.
receiverControlTopic - The receivers control topic.
Method Detail

createCircuit

public static Circuit createCircuit(org.apache.qpid.junit.extensions.util.ParsedProperties testProps,
                                    List<TestClientDetails> senders,
                                    List<TestClientDetails> receivers,
                                    ConversationFactory conversationFactory)
Creates a distributed test circuit from the specified test parameters, on the senders and receivers given.

Parameters:
testProps - The test parameters.
senders - The sender ends in the test circuit.
receivers - The receiver ends in the test circuit.
conversationFactory - A conversation factory for creating the control conversations with senders and receivers.
Returns:
A connected and ready to start, test circuit.

setTimingController

public void setTimingController(org.apache.qpid.junit.extensions.TimingController controller)
Used by tests cases that can supply a TimingController to set the controller on an aware test.

Specified by:
setTimingController in interface org.apache.qpid.junit.extensions.TimingControllerAware
Parameters:
controller - The timing controller.

getPublisher

public Publisher getPublisher()
Gets the interface on the publishing end of the circuit.

Specified by:
getPublisher in interface Circuit
Returns:
The publishing end of the circuit.

getReceiver

public Receiver getReceiver()
Gets the interface on the receiving end of the circuit.

Specified by:
getReceiver in interface Circuit
Returns:
The receiving end of the circuit.

start

public void start()
Connects and starts the circuit. After this method is called the circuit is ready to send messages.

Specified by:
start in interface Circuit

check

public void check()
Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit, into a report, against which assertions may be checked.

Specified by:
check in interface Circuit
Todo:
Replace the asynch receiver report thread with a choice of direct or asynch executor, so that asynch or synch logging of test timings is optional. Also need to provide an onMessage method that is capable of receiving timing reports that receivers will generate during an ongoing test, on the test sample size boundaries. The message timing logging code should be factored out as a common method that can be called in response to the final report responses, or the onMessage method. Another alternative is to abandon the final report request altogether and just use the onMessage method? I think the two differ though, as the final report is used to apply assertions, and the ongoing report is just for periodic timing results... In which case, maybe there needs to be a way for the onMessage method to process just some of the incoming messages, and forward the rest on to the conversion helper, as a sort of pre-conversation helper filter? Make conversation expose its onMessage method (it should already) and allow another delivery thread to filter the incoming messages to the conversation.

close

public void close()
Closes the circuit. All associated resources are closed.

Specified by:
close in interface Circuit

applyAssertions

public List<Assertion> applyAssertions(List<Assertion> assertions)
Applies a list of assertions against the test circuit. The check() method should be called before doing this, to ensure that the circuit has gathered its state into a report to assert against.

Specified by:
applyAssertions in interface Circuit
Parameters:
assertions - The list of assertions to apply.
Returns:
Any assertions that failed.

test

public List<Assertion> test(int numMessages,
                            List<Assertion> assertions)
Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.

Specified by:
test in interface Circuit
Parameters:
numMessages - The number of messages to send using the default test procedure.
assertions - The list of assertions to apply.
Returns:
Any assertions that failed.
Todo:
From check onwards needs to be handled as a future. The future must call back onto the test case to report results asynchronously.


Licensed to the Apache Software Foundation