Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ public void testClusterConnectedBeforeClients() throws Exception {
protected void setUp() throws Exception {
if (brokerA == null) {
brokerA = createBrokerA(getBindAddress() + "?transport.closeAsync=false");
clientUrl = "failover://(" + brokerA.getTransportConnectors().get(0).getPublishableConnectString() + ")";
// randomize=false so clients honor the broker-provided round-robin order on
// rebalance, making the client spread across brokers deterministic
clientUrl = "failover://(" + brokerA.getTransportConnectors().get(0).getPublishableConnectString() + ")?randomize=false";
}
}

Expand Down Expand Up @@ -182,6 +184,6 @@ private static boolean waitForClientRebalance(final List<ActiveMQConnection> con
}
}
return set.size() >= minBrokerCount;
}, TimeUnit.SECONDS.toMillis(15), TimeUnit.MILLISECONDS.toMillis(500));
}, TimeUnit.SECONDS.toMillis(15), 10l);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -36,12 +35,13 @@
import org.apache.activemq.TestSupport.PersistenceAdapterChoice;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.store.MessageRecoveryListener;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.TopicMessageStore;
import org.apache.activemq.broker.region.Destination;
import org.apache.activemq.command.MessageId;
import org.apache.activemq.util.Wait;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -71,6 +71,17 @@ public PersistenceAdapter setDefaultPersistenceAdapter(BrokerService broker) thr
return super.setPersistenceAdapter(broker, PersistenceAdapterChoice.MEM);
}

@Override
public void configurePlugins(BrokerService broker) throws Exception {
// Disable the periodic expiry task so the JMX browse is the only expiry
// trigger and the expired count is deterministic
PolicyEntry policy = new PolicyEntry();
policy.setExpireMessagesPeriod(0);
PolicyMap policyMap = new PolicyMap();
policyMap.setDefaultEntry(policy);
broker.setDestinationPolicy(policyMap);
}

@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://" + getName(true));
Expand Down Expand Up @@ -148,7 +159,7 @@ public boolean isDuplicate(MessageId id) {
assertNotNull(data);

if (enableExpiration) {
assertTrue(Wait.waitFor(() -> dest.getDestinationStatistics().getExpired().getCount() == messagesToExpire.size(), 5_000, 100));
assertEquals(messagesToExpire.size(), dest.getDestinationStatistics().getExpired().getCount());
} else {
assertEquals(0L, dest.getDestinationStatistics().getExpired().getCount());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,17 @@ public void testSelectorAwareForwarding() throws Exception {
brokerA.waitUntilStopped();
deleteSelectorCacheFile("BrokerA");

assertEquals(0, destination.getConsumers().size());
// consumer close is async - wait for the broker to remove the subscription
assertTrue("consumer should be removed from BrokerB",
Wait.waitFor(() -> destination.getConsumers().isEmpty(), 5000, 10));

remoteConsumer = createConsumer("BrokerB",
createDestination("Consumer.B.VirtualTopic.tempTopic", false),
"ceposta = 'redhat'");


assertEquals(1, destination.getConsumers().size());
assertTrue("new consumer should be registered on BrokerB",
Wait.waitFor(() -> destination.getConsumers().size() == 1, 5000, 10));


// now let's start broker A back up
Expand Down