You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2010/05/13 11:40:36 UTC
svn commit: r943856 - in
/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases:
TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java
TwoBrokerNetworkLoadBalanceTest.java
Author: gtully
Date: Thu May 13 09:40:36 2010
New Revision: 943856
URL: http://svn.apache.org/viewvc?rev=943856&view=rev
Log:
add little test to validate load balancing in a simple network
Added:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java (with props)
Modified:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java
Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java?rev=943856&r1=943855&r2=943856&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest.java Thu May 13 09:40:36 2010
@@ -17,26 +17,13 @@
package org.apache.activemq.usecases;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
import javax.jms.Destination;
import javax.jms.MessageConsumer;
import org.apache.activemq.JmsMultipleBrokersTestSupport;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.broker.TransportConnector;
-import org.apache.activemq.command.Command;
-import org.apache.activemq.network.DemandForwardingBridge;
-import org.apache.activemq.network.NetworkBridgeConfiguration;
-import org.apache.activemq.network.NetworkConnector;
-import org.apache.activemq.transport.TransportFactory;
import org.apache.activemq.util.MessageIdList;
-/**
- * @version $Revision: 1.1.1.1 $
- */
public class TwoBrokerMessageNotSentToRemoteWhenNoConsumerTest extends JmsMultipleBrokersTestSupport {
protected static final int MESSAGE_COUNT = 100;
Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java?rev=943856&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java Thu May 13 09:40:36 2010
@@ -0,0 +1,77 @@
+/**
+ * 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.activemq.usecases;
+
+import java.net.URI;
+
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+
+import org.apache.activemq.JmsMultipleBrokersTestSupport;
+import org.apache.activemq.util.MessageIdList;
+import org.apache.activemq.util.Wait;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class TwoBrokerNetworkLoadBalanceTest extends JmsMultipleBrokersTestSupport {
+ protected static final Log LOG = LogFactory.getLog(TwoBrokerNetworkLoadBalanceTest.class);
+ public void testLoadBalancing() throws Exception {
+ bridgeBrokers("BrokerA", "BrokerB");
+ bridgeBrokers("BrokerB", "BrokerA");
+
+ startAllBrokers();
+ waitForBridgeFormation();
+
+ // Setup destination
+ Destination dest = createDestination("TEST.FOO", false);
+
+ // Setup consumers
+ MessageConsumer clientA = createConsumer("BrokerA", dest);
+
+ // Setup consumers
+ MessageConsumer clientB = createConsumer("BrokerB", dest);
+
+ // Send messages
+ sendMessages("BrokerA", dest, 5000);
+
+ // Send messages
+ sendMessages("BrokerB", dest, 1000);
+
+ // Get message count
+ final MessageIdList msgsA = getConsumerMessages("BrokerA", clientA);
+ final MessageIdList msgsB = getConsumerMessages("BrokerB", clientB);
+
+ Wait.waitFor(new Wait.Condition() {
+ public boolean isSatisified() throws Exception {
+ return msgsA.getMessageCount() + msgsB.getMessageCount() == 6000;
+ }});
+
+ LOG.info("A got: " + msgsA.getMessageCount());
+ LOG.info("B got: " + msgsB.getMessageCount());
+
+ assertTrue("B got is fair share: " + msgsB.getMessageCount(), msgsB.getMessageCount() > 2000);
+ }
+
+ public void setUp() throws Exception {
+ super.setAutoFail(true);
+ super.setUp();
+ createBroker(new URI(
+ "broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false"));
+ createBroker(new URI(
+ "broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false"));
+ }
+}
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/TwoBrokerNetworkLoadBalanceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date