Author: rupertlssmith
Date: Fri Jan 11 08:03:05 2008
New Revision: 611214
URL: http://svn.apache.org/viewvc?rev=611214&view=rev
Log:
QPID-733. More fail over tests.
Added:
incubator/qpid/branches/M2.1/java/perftests/etc/jndi/failovertest.properties
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
Modified:
incubator/qpid/branches/M2.1/java/perftests/pom.xml
incubator/qpid/branches/M2.1/java/systests/pom.xml
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
Added:
incubator/qpid/branches/M2.1/java/perftests/etc/jndi/failovertest.properties
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/perftests/etc/jndi/failovertest.properties?rev=611214&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/perftests/etc/jndi/failovertest.properties
(added)
+++
incubator/qpid/branches/M2.1/java/perftests/etc/jndi/failovertest.properties
Fri Jan 11 08:03:05 2008
@@ -0,0 +1,2 @@
+java.naming.factory.initial =
org.apache.qpid.jndi.PropertiesFileInitialContextFactory
+connectionfactory.local = amqp://guest:[EMAIL
PROTECTED]/test?brokerlist='tcp://localhost:5001;tcp://localhost:5002'
Modified: incubator/qpid/branches/M2.1/java/perftests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/perftests/pom.xml?rev=611214&r1=611213&r2=611214&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/perftests/pom.xml (original)
+++ incubator/qpid/branches/M2.1/java/perftests/pom.xml Fri Jan 11 08:03:05 2008
@@ -617,16 +617,16 @@
-->
<!-- Failover Tests. -->
- <FT-Qpid-01>-n FT-Qpid-01 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=10000
transacted=true broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002"
failBeforeSend=true -o $QPID_WORK/results</FT-Qpid-01>
- <FT-Qpid-02>-n FT-Qpid-02 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=10000
transacted=true broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002"
failAfterSend=true -o $QPID_WORK/results</FT-Qpid-02>
- <FT-Qpid-03>-n FT-Qpid-03 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
transacted=true broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002"
failAfterCommit=true -o $QPID_WORK/results</FT-Qpid-03>
- <FT-Qpid-04>-n FT-Qpid-04 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" transacted=false
failBeforeSend=true -o $QPID_WORK/results</FT-Qpid-04>
- <FT-Qpid-05>-n FT-Qpid-05 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" transacted=false
failAfterSend=true -o $QPID_WORK/results</FT-Qpid-05>
- <FT-Qpid-01-P>-n FT-Qpid-01-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" failBeforeSend=true -o
$QPID_WORK/results</FT-Qpid-01-P>
- <FT-Qpid-02-P>-n FT-Qpid-02-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" failAfterSend=true -o
$QPID_WORK/results</FT-Qpid-02-P>
- <FT-Qpid-03-P>-n FT-Qpid-03-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" failAfterCommit=true -o
$QPID_WORK/results</FT-Qpid-03-P>
- <FT-Qpid-04-P>-n FT-Qpid-04-P -s[250] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" transacted=false
failBeforeSend=true -o $QPID_WORK/results</FT-Qpid-04-P>
- <FT-Qpid-05-P>-n FT-Qpid-05-P -s[250] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000
broker="tcp://127.0.0.1:5001;tcp://127.0.0.1:5002" transacted=false
failAfterSend=true -o $QPID_WORK/results</FT-Qpid-05-P>
+ <FT-Qpid-01>-n FT-Qpid-01 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=10000
transacted=true properties=failovertest.properties failBeforeSend=true -o
$QPID_WORK/results</FT-Qpid-01>
+ <FT-Qpid-02>-n FT-Qpid-02 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=10000
transacted=true properties=failovertest.properties failAfterSend=true -o
$QPID_WORK/results</FT-Qpid-02>
+ <FT-Qpid-03>-n FT-Qpid-03 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
transacted=true properties=failovertest.properties failAfterCommit=true -o
$QPID_WORK/results</FT-Qpid-03>
+ <FT-Qpid-04>-n FT-Qpid-04 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
properties=failovertest.properties transacted=false failBeforeSend=true -o
$QPID_WORK/results</FT-Qpid-04>
+ <FT-Qpid-05>-n FT-Qpid-05 -s[2500] -t testAsyncPingOk
org.apache.qpid.ping.PingAsyncTestPerf messageSize=256 batchSize=1000
properties=failovertest.properties transacted=false failAfterSend=true -o
$QPID_WORK/results</FT-Qpid-05>
+ <FT-Qpid-01-P>-n FT-Qpid-01-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
properties=failovertest.properties failBeforeSend=true -o
$QPID_WORK/results</FT-Qpid-01-P>
+ <FT-Qpid-02-P>-n FT-Qpid-02-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
properties=failovertest.properties failAfterSend=true -o
$QPID_WORK/results</FT-Qpid-02-P>
+ <FT-Qpid-03-P>-n FT-Qpid-03-P -s[2500] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 transacted=true
properties=failovertest.properties failAfterCommit=true -o
$QPID_WORK/results</FT-Qpid-03-P>
+ <FT-Qpid-04-P>-n FT-Qpid-04-P -s[250] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 properties=failovertest.properties
transacted=false failBeforeSend=true -o $QPID_WORK/results</FT-Qpid-04-P>
+ <FT-Qpid-05-P>-n FT-Qpid-05-P -s[250] -t
testAsyncPingOk org.apache.qpid.ping.PingAsyncTestPerf persistent=true
messageSize=256 batchSize=1000 properties=failovertest.properties
transacted=false failAfterSend=true -o $QPID_WORK/results</FT-Qpid-05-P>
</commands>
</configuration>
Modified: incubator/qpid/branches/M2.1/java/systests/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/pom.xml?rev=611214&r1=611213&r2=611214&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/pom.xml (original)
+++ incubator/qpid/branches/M2.1/java/systests/pom.xml Fri Jan 11 08:03:05 2008
@@ -1,20 +1,20 @@
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
@@ -84,16 +84,18 @@
</includes>
<systemProperties>
- <property>
- <name>example.plugin.target</name>
-
<value>${basedir}/${topDirectoryLocation}/plugins/target</value>
- </property>
+ <property>
+ <name>example.plugin.target</name>
+
<value>${basedir}/${topDirectoryLocation}/plugins/target</value>
+ </property>
</systemProperties>
<excludes>
<exclude>**/testcases/ImmediateMessageTest.class</exclude>
<exclude>**/testcases/MandatoryMessageTest.class</exclude>
- <exclude>**/testcases/RollbackTest.class</exclude>
+ <exclude>**/testcases/RollbackTest.class</exclude>
+ <exclude>**/testcases/TTLTest.class</exclude>
+ <exclude>**/testcases/FailoverTest.class</exclude>
</excludes>
</configuration>
</plugin>
@@ -115,6 +117,7 @@
<testrunneroptions>
<option>-X:decorators
"org.apache.qpid.test.framework.qpid.InVMBrokerDecorator:org.apache.qpid.test.framework.qpid.AMQPFeatureDecorator"</option>
+ <!--<option>-d30S</option>-->
<option>-o ${basedir}/target/surefire-reports</option>
<option>--xml</option>
</testrunneroptions>
@@ -127,9 +130,28 @@
</testrunnerproperties>
<commands>
- <Immediate-Message-Test>-n Immediate-Test -s[1]
org.apache.qpid.test.testcases.ImmediateMessageTest</Immediate-Message-Test>
- <Mandatory-Message-Test>-n Mandatory-Test -s[1]
org.apache.qpid.test.testcases.MandatoryMessageTest</Mandatory-Message-Test>
- <Rollback-Test>-n Rollback-Test -s[1]
org.apache.qpid.test.testcases.RollbackTest</Rollback-Test>
+ <AMQBrokerManagerMBeanTest>-n
AMQBrokerManagerMBeanTest org.apache.qpid.server.AMQBrokerManagerMBeanTest
</AMQBrokerManagerMBeanTest>
+ <TxAckTest>-n TxAckTest
org.apache.qpid.server.ack.TxAckTest </TxAckTest>
+ <!--<HeadersExchangeTest>-n HeadersExchangeTest
org.apache.qpid.server.exchange.HeadersExchangeTest </HeadersExchangeTest>-->
+ <ReturnUnroutableMandatoryMessageTest>-n
ReturnUnroutableMandatoryMessageTest
org.apache.qpid.server.exchange.ReturnUnroutableMandatoryMessageTest
</ReturnUnroutableMandatoryMessageTest>
+ <!--<FailoverMethodTest>-n FailoverMethodTest
org.apache.qpid.server.failover.FailoverMethodTest </FailoverMethodTest>-->
+ <DeadlockTest>-n DeadlockTest
org.apache.qpid.server.failure.DeadlockTest </DeadlockTest>
+ <!--<PluginTest>-n PluginTest
org.apache.qpid.server.plugins.PluginTest </PluginTest>-->
+ <AMQProtocolSessionMBeanTest>-n
AMQProtocolSessionMBeanTest
org.apache.qpid.server.protocol.AMQProtocolSessionMBeanTest
</AMQProtocolSessionMBeanTest>
+ <MaxChannelsTest>-n MaxChannelsTest
org.apache.qpid.server.protocol.MaxChannelsTest </MaxChannelsTest>
+ <AckTest>-n AckTest
org.apache.qpid.server.queue.AckTest </AckTest>
+ <MessageReturnTest>-n MessageReturnTest
org.apache.qpid.server.queue.MessageReturnTest </MessageReturnTest>
+ <QueueDepthWithSelectorTest>-n
QueueDepthWithSelectorTest
org.apache.qpid.server.queue.QueueDepthWithSelectorTest
</QueueDepthWithSelectorTest>
+ <!--<SubscriptionManagerTest>-n
SubscriptionManagerTest org.apache.qpid.server.queue.SubscriptionManagerTest
</SubscriptionManagerTest>-->
+ <SubscriptionSetTest>-n SubscriptionSetTest
org.apache.qpid.server.queue.SubscriptionSetTest </SubscriptionSetTest>
+ <TimeToLiveTest>-n TimeToLiveTest
org.apache.qpid.server.queue.TimeToLiveTest </TimeToLiveTest>
+ <TxnBufferTest>-n TxnBufferTest
org.apache.qpid.server.txn.TxnBufferTest </TxnBufferTest>
+ <!--<TxnTest>-n TxnTest
org.apache.qpid.server.txn.TxnTest </TxnTest>-->
+ <QueueBrowserTest>-n QueueBrowserTest
org.apache.qpid.test.client.QueueBrowserTest </QueueBrowserTest>
+
+ <!--<Immediate-Message-Test>-n Immediate-Test -s[1]
org.apache.qpid.test.testcases.ImmediateMessageTest</Immediate-Message-Test>-->
+ <!--<Mandatory-Message-Test>-n Mandatory-Test -s[1]
org.apache.qpid.test.testcases.MandatoryMessageTest</Mandatory-Message-Test>-->
+ <!--<Rollback-Test>-n Rollback-Test -s[1]
org.apache.qpid.test.testcases.RollbackTest</Rollback-Test>-->
</commands>
</configuration>
Modified:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java?rev=611214&r1=611213&r2=611214&view=diff
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
(original)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
Fri Jan 11 08:03:05 2008
@@ -21,27 +21,34 @@
package org.apache.qpid.server.protocol;
import junit.framework.TestCase;
+
+import org.apache.log4j.Logger;
+
import org.apache.mina.common.IoSession;
+
+import org.apache.qpid.AMQException;
import org.apache.qpid.codec.AMQCodecFactory;
+import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.AMQChannel;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.server.registry.IApplicationRegistry;
-import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.exchange.ExchangeRegistry;
-import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.QueueRegistry;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.IApplicationRegistry;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.SkeletonMessageStore;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.virtualhost.VirtualHost;
import javax.management.JMException;
/**
* Test class to test MBean operations for AMQMinaProtocolSession.
*/
-public class AMQProtocolSessionMBeanTest extends TestCase
+public class AMQProtocolSessionMBeanTest extends TestCase
{
+ /** Used for debugging. */
+ private static final Logger log =
Logger.getLogger(AMQProtocolSessionMBeanTest.class);
+
private MessageStore _messageStore = new SkeletonMessageStore();
private AMQMinaProtocolSession _protocolSession;
private AMQChannel _channel;
@@ -52,12 +59,10 @@
// check the channel count is correct
int channelCount = _mbean.channels().size();
assertTrue(channelCount == 1);
- AMQQueue queue = new org.apache.qpid.server.queue.AMQQueue(new
AMQShortString("testQueue_" + System.currentTimeMillis()),
- false,
- new
AMQShortString("test"),
- true,
-
_protocolSession.getVirtualHost());
- AMQChannel channel = new AMQChannel(_protocolSession,2, _messageStore,
null);
+ AMQQueue queue =
+ new org.apache.qpid.server.queue.AMQQueue(new
AMQShortString("testQueue_" + System.currentTimeMillis()), false,
+ new AMQShortString("test"), true,
_protocolSession.getVirtualHost());
+ AMQChannel channel = new AMQChannel(_protocolSession, 2,
_messageStore, null);
channel.setDefaultQueue(queue);
_protocolSession.addChannel(channel);
channelCount = _mbean.channels().size();
@@ -68,7 +73,7 @@
assertTrue(_mbean.getMaximumNumberOfChannels() == 1000L);
// check APIs
- AMQChannel channel3 = new AMQChannel(_protocolSession,3,
_messageStore, null);
+ AMQChannel channel3 = new AMQChannel(_protocolSession, 3,
_messageStore, null);
channel3.setLocalTransactional();
_protocolSession.addChannel(channel3);
_mbean.rollbackTransactions(2);
@@ -84,39 +89,38 @@
}
catch (JMException ex)
{
- System.out.println("expected exception is thrown :" +
ex.getMessage());
+ log.debug("expected exception is thrown :" + ex.getMessage());
}
// check if closing of session works
- _protocolSession.addChannel(new AMQChannel(_protocolSession,5,
_messageStore, null));
+ _protocolSession.addChannel(new AMQChannel(_protocolSession, 5,
_messageStore, null));
_mbean.closeConnection();
try
{
channelCount = _mbean.channels().size();
assertTrue(channelCount == 0);
// session is now closed so adding another channel should throw an
exception
- _protocolSession.addChannel(new AMQChannel(_protocolSession,6,
_messageStore, null));
+ _protocolSession.addChannel(new AMQChannel(_protocolSession, 6,
_messageStore, null));
fail();
}
- catch(AMQException ex)
+ catch (AMQException ex)
{
- System.out.println("expected exception is thrown :" +
ex.getMessage());
+ log.debug("expected exception is thrown :" + ex.getMessage());
}
}
-
+
@Override
protected void setUp() throws Exception
{
super.setUp();
IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
- _protocolSession = new AMQMinaProtocolSession(new MockIoSession(),
-
appRegistry.getVirtualHostRegistry(),
- new
AMQCodecFactory(true),
- null);
+ _protocolSession =
+ new AMQMinaProtocolSession(new MockIoSession(),
appRegistry.getVirtualHostRegistry(), new AMQCodecFactory(true),
+ null);
_protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
- _channel = new AMQChannel(_protocolSession,1, _messageStore, null);
+ _channel = new AMQChannel(_protocolSession, 1, _messageStore, null);
_protocolSession.addChannel(_channel);
- _mbean = (AMQProtocolSessionMBean)_protocolSession.getManagedObject();
+ _mbean = (AMQProtocolSessionMBean) _protocolSession.getManagedObject();
}
}
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java?rev=611214&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
(added)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/FailoverTest.java
Fri Jan 11 08:03:05 2008
@@ -0,0 +1,119 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.testcases;
+
+import org.apache.qpid.test.framework.*;
+import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
+import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+/**
+ * FailoverTest provides testing of fail-over over a local-circuit
implementation. The circuit being tested may be
+ * against an in-vm broker or against an external broker, with the failure
mechanism abstracted out of the test case.
+ * Automatic failures can be simulated against an in-vm broker. Currently the
test must interact with the user to
+ * simulate failures on an external broker.
+ *
+ * Things to test:
+ * In tx, failure duing tx causes tx to error on subsequent sends/receives or
commits/rollbacks.
+ * Outside of tx, reconnection allows msg flow to continue but there may be
loss.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td>
+ * </table>
+ *
+ * @todo This test is designed to be run over a local circuit only. For in-vm
using automatic failures, for external
+ * brokers by prompting the user (or maybe using a script). Enforce the
local-circuit only nature of the tests as
+ * well as thinking about how other local-circuit tests might be
implemented. For example, could add a method
+ * to the framework base case for local only tests to call, that allows
them access to the local-circuit
+ * implementation and so on.
+ *
+ * @todo More. Need to really expand the set of fail-over tests.
+ */
+public class FailoverTest extends FrameworkBaseCase
+{
+ /* Used for debugging purposes. */
+ // private static final Logger log = Logger.getLogger(FailoverTest.class);
+
+ /**
+ * Creates a new test case with the specified name.
+ *
+ * @param name The test case name.
+ */
+ public FailoverTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Checks that all messages sent within a transaction are receieved
despite a fail-over occuring outside of
+ * the transaction.
+ *
+ * @throws JMSException Allowed to fall through and fail test.
+ */
+ public void testTxP2PFailover() throws JMSException
+ {
+ // Set up the test properties to match the test cases requirements.
+ testProps.setProperty(TRANSACTED_PUBLISHER_PROPNAME, true);
+ testProps.setProperty(ACK_MODE_PROPNAME, Session.AUTO_ACKNOWLEDGE);
+ testProps.setProperty(PUBSUB_PROPNAME, false);
+
+ // MessagingTestConfigProperties props = this.getTestParameters();
+
+ // Create the test circuit from the test configuration parameters.
+ CircuitFactory circuitFactory = getCircuitFactory();
+ Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+ // Create an assertion that all messages are received.
+ Assertion allMessagesReceived =
testCircuit.getReceiver().allMessagesReceivedAssertion(testProps);
+
+ // This test case assumes it is using a local circuit.
+ LocalCircuitImpl localCircuit = (LocalCircuitImpl) testCircuit;
+
+ Session producerSession =
localCircuit.getLocalPublisherCircuitEnd().getSession();
+ MessageProducer producer =
localCircuit.getLocalPublisherCircuitEnd().getProducer();
+ // MessageConsumer consumer =
localCircuit.getLocalReceiverCircuitEnd().getConsumer();
+
+ // Send some test messages.
+ for (int i = 0; i < 100; i++)
+ {
+ producer.send(TestUtils.createTestMessageOfSize(producerSession,
10));
+ producerSession.commit();
+
+ // Cause a failover.
+ if (i == 50)
+ {
+ failureMechanism.causeFailure();
+ }
+
+ // Wait for the reconnection to complete.
+ }
+
+ // Check that trying to send within the original transaction fails.
+
+ // Check that all messages sent were received.
+ assertTrue("All messages sent were not received back again.",
allMessagesReceived.apply());
+ }
+}
Added:
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java?rev=611214&view=auto
==============================================================================
---
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
(added)
+++
incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/testcases/TTLTest.java
Fri Jan 11 08:03:05 2008
@@ -0,0 +1,151 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.test.testcases;
+
+import org.apache.qpid.test.framework.Circuit;
+import org.apache.qpid.test.framework.FrameworkBaseCase;
+import static
org.apache.qpid.test.framework.MessagingTestConfigProperties.ACK_MODE_PROPNAME;
+import static
org.apache.qpid.test.framework.MessagingTestConfigProperties.PUBSUB_PROPNAME;
+import org.apache.qpid.test.framework.TestUtils;
+import org.apache.qpid.test.framework.localcircuit.LocalCircuitImpl;
+import org.apache.qpid.test.framework.sequencers.CircuitFactory;
+
+import javax.jms.*;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+/**
+ * TTLTest checks that time-to-live is applied to messages. The test sends
messages with a variety of TTL stamps on them
+ * then after a pause attempts to receive those messages. Only messages with a
large enough TTL to have survived the pause
+ * should be receiveable. This test case also applies an additional assertion
against the broker, that the message store
+ * is empty at the end of the test.
+ *
+ * <p/>This test is designed to run over local circuits only, as it must
control a timed pause between sending and receiving
+ * messages to that TTL can be applied to purge some of the messages.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td>
+ * </table>
+ *
+ * @todo Use an interface or other method to mark this test as local only.
+ *
+ * @todo Implement the message store assertion for in-vm broker. Could also be
done for external broker, for example
+ * by using diagnostic exchange.
+ *
+ * @todo Implement and add a queue depth assertion too. This might already be
in another test to copy from.
+ *
+ * @todo Create variations on test theme, for different ack mode and tx and
message sizes etc.
+ *
+ * @todo Add an allowable margin of error to the test, as ttl may not be
precise.
+ */
+public class TTLTest extends FrameworkBaseCase
+{
+ /**
+ * Creates a new test case with the specified name.
+ *
+ * @param name The test case name.
+ */
+ public TTLTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Checks that all messages sent with a TTL shorter than a pause between
sending them and attempting to receive them
+ * will fail to arrive. Once all messages have been purged by TTL or
received, check that they no longer exist on
+ * the broker.
+ *
+ * @throws javax.jms.JMSException Allowed to fall through and fail test.
+ */
+ public void testTTLP2P() throws JMSException
+ {
+ String errorMessages = "";
+ Random r = new Random();
+
+ // Used to accumulate correctly received messages in.
+ List<Message> receivedMessages = new LinkedList<Message>();
+
+ // Set up the test properties to match the test case requirements.
+ testProps.setProperty(ACK_MODE_PROPNAME, Session.AUTO_ACKNOWLEDGE);
+ testProps.setProperty(PUBSUB_PROPNAME, false);
+
+ // Create the test circuit from the test configuration parameters.
+ CircuitFactory circuitFactory = getCircuitFactory();
+ Circuit testCircuit = circuitFactory.createCircuit(testProps);
+
+ // This test case assumes it is using a local circuit.
+ LocalCircuitImpl localCircuit = (LocalCircuitImpl) testCircuit;
+
+ Session producerSession =
localCircuit.getLocalPublisherCircuitEnd().getSession();
+ MessageProducer producer =
localCircuit.getLocalPublisherCircuitEnd().getProducer();
+ MessageConsumer consumer =
localCircuit.getLocalReceiverCircuitEnd().getConsumer();
+
+ // Send some tests messages, with random TTLs, some shorter and some
longer than the pause time.
+ for (int i = 0; i < 100; i++)
+ {
+ Message testMessage =
TestUtils.createTestMessageOfSize(producerSession, 10);
+
+ // Set the TTL on the message and record its value in the message
headers.
+ long ttl = 500 + r.nextInt(1500);
+ producer.setTimeToLive(ttl);
+ testMessage.setLongProperty("testTTL", ttl);
+
+ producer.send(testMessage);
+ // producerSession.commit();
+ }
+
+ // Inject a pause to allow some messages to be purged by TTL.
+ TestUtils.pause(1000);
+
+ // Attempt to receive back all of the messages, confirming by the
message time stamps and TTLs that only
+ // those received should have avoided being purged by the TTL.
+ boolean timedOut = false;
+
+ while (!timedOut)
+ {
+ Message testMessage = consumer.receive(1000);
+
+ long ttl = testMessage.getLongProperty("testTTL");
+ long timeStamp = testMessage.getJMSTimestamp();
+ long now = System.currentTimeMillis();
+
+ if ((timeStamp + ttl) < now)
+ {
+ errorMessages +=
+ "Received message [sent: " + timeStamp + ", ttl: " + ttl +
", received: " + now
+ + "] which should have been purged by its TTL.\n";
+ }
+ /*else
+ {
+ receivedMessages.add(testMessage);
+ }*/
+ }
+
+ // Check that the queue and message store on the broker are empty.
+ // assertTrue("Message store is not empty.",
messageStoreEmpty.apply());
+ // assertTrue("Queue is not empty.", queueEmpty.apply());
+
+ assertTrue(errorMessages, "".equals(errorMessages));
+ }
+}