You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2017/11/02 13:47:17 UTC
[3/3] activemq-artemis git commit: NO-JIRA Fixing intermittent test
failures
NO-JIRA Fixing intermittent test failures
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7f4a79b0
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7f4a79b0
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7f4a79b0
Branch: refs/heads/master
Commit: 7f4a79b0c6030592f3e6021a666fbbbc7e19081d
Parents: 5997e21
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Nov 1 12:16:51 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Thu Nov 2 09:37:31 2017 -0400
----------------------------------------------------------------------
.../core/server/impl/ActiveMQServerImpl.java | 17 +++++++++++------
.../amqp/AmqpPurgeOnNoConsumersTest.java | 3 ++-
.../apache/activemq/artemis/tests/util/Wait.java | 14 ++++++++++++++
3 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7f4a79b0/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 03c8010..587cff9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -576,22 +576,27 @@ public class ActiveMQServerImpl implements ActiveMQServer {
}
private void initializeCriticalAnalyzer() throws Exception {
+
+ // Some tests will play crazy frequenceistop/start
+ CriticalAnalyzer analyzer = this.getCriticalAnalyzer();
if (analyzer == null) {
if (configuration.isCriticalAnalyzer()) {
// this will have its own ScheduledPool
- this.analyzer = new CriticalAnalyzerImpl();
+ analyzer = new CriticalAnalyzerImpl();
} else {
- this.analyzer = EmptyCriticalAnalyzer.getInstance();
+ analyzer = EmptyCriticalAnalyzer.getInstance();
}
+
+ this.analyzer = analyzer;
}
/* Calling this for cases where the server was stopped and now is being restarted... failback, etc...*/
- this.analyzer.clear();
+ analyzer.clear();
- this.getCriticalAnalyzer().setCheckTime(configuration.getCriticalAnalyzerCheckPeriod(), TimeUnit.MILLISECONDS).setTimeout(configuration.getCriticalAnalyzerTimeout(), TimeUnit.MILLISECONDS);
+ analyzer.setCheckTime(configuration.getCriticalAnalyzerCheckPeriod(), TimeUnit.MILLISECONDS).setTimeout(configuration.getCriticalAnalyzerTimeout(), TimeUnit.MILLISECONDS);
if (configuration.isCriticalAnalyzer()) {
- this.getCriticalAnalyzer().start();
+ analyzer.start();
}
CriticalAction criticalAction = null;
@@ -645,7 +650,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
break;
}
- this.getCriticalAnalyzer().addAction(criticalAction);
+ analyzer.addAction(criticalAction);
}
private void sendCriticalNotification(final CriticalComponent criticalComponent) {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7f4a79b0/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPurgeOnNoConsumersTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPurgeOnNoConsumersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPurgeOnNoConsumersTest.java
index 068e1ce..9ded61c 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPurgeOnNoConsumersTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPurgeOnNoConsumersTest.java
@@ -20,6 +20,7 @@ import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.transport.amqp.client.AmqpClient;
import org.apache.activemq.transport.amqp.client.AmqpConnection;
import org.apache.activemq.transport.amqp.client.AmqpMessage;
@@ -76,7 +77,7 @@ public class AmqpPurgeOnNoConsumersTest extends AmqpClientTestSupport {
t.join(5000);
- assertEquals(0, queueView.getMessageCount());
+ Wait.assertEquals(0, queueView::getMessageCount);
connection.close();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/7f4a79b0/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/Wait.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/Wait.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/Wait.java
index 2f3772a..ceaf16a 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/Wait.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/Wait.java
@@ -18,6 +18,8 @@ package org.apache.activemq.artemis.tests.util;
import java.util.concurrent.TimeUnit;
+import org.junit.Assert;
+
/**
* Utility adapted from: org.apache.activemq.util.Wait
*/
@@ -31,10 +33,22 @@ public class Wait {
boolean isSatisfied() throws Exception;
}
+ public interface LongCondition {
+ long getCount() throws Exception;
+ }
+
public static boolean waitFor(Condition condition) throws Exception {
return waitFor(condition, MAX_WAIT_MILLIS);
}
+ public static void assertEquals(long size, LongCondition condition) throws Exception {
+ boolean result = waitFor(() -> condition.getCount() == size);
+
+ if (!result) {
+ Assert.fail(size + " != " + condition);
+ }
+ }
+
public static boolean waitFor(final Condition condition, final long duration) throws Exception {
return waitFor(condition, duration, SLEEP_MILLIS);
}