You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/03/20 09:19:15 UTC
qpid-broker-j git commit: NO_JIRA: [Broker-J][System Tests] Fix
failing test
ProducerFlowControlTest#testFlowControlAttributeModificationViaManagement
Repository: qpid-broker-j
Updated Branches:
refs/heads/master 330a71cdc -> 6a8f71e56
NO_JIRA: [Broker-J][System Tests] Fix failing test ProducerFlowControlTest#testFlowControlAttributeModificationViaManagement
Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/6a8f71e5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/6a8f71e5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/6a8f71e5
Branch: refs/heads/master
Commit: 6a8f71e56238c63b281682e569fa09eedd5d855f
Parents: 330a71c
Author: Alex Rudyy <or...@apache.org>
Authored: Tue Mar 20 09:19:03 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Tue Mar 20 09:19:03 2018 +0000
----------------------------------------------------------------------
.../queue/ProducerFlowControlTest.java | 52 +++++++++++++++++---
1 file changed, 45 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/6a8f71e5/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/queue/ProducerFlowControlTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/queue/ProducerFlowControlTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/queue/ProducerFlowControlTest.java
index bd86c6e..a3fe680 100644
--- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/queue/ProducerFlowControlTest.java
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/queue/ProducerFlowControlTest.java
@@ -23,7 +23,6 @@ package org.apache.qpid.systests.jms_1_1.extensions.queue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
@@ -32,6 +31,7 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Supplier;
import javax.jms.BytesMessage;
import javax.jms.Connection;
@@ -190,7 +190,7 @@ public class ProducerFlowControlTest extends JmsTestBase
assertTrue("Flow is stopped", awaitAttributeValue(queueName, "queueFlowStopped", false, 2000));
assertTrue("Second message was not sent after changing limits",
- awaitAttributeValue(queueName, "queueDepthMessages", 2, 2000));
+ awaitStatisticsValue(queueName, "queueDepthMessages", 2, 2000));
assertFalse("Queue should not be overfull", isFlowStopped(queueName));
// try to send another message to block flow
@@ -308,8 +308,13 @@ public class ProducerFlowControlTest extends JmsTestBase
private int getQueueDepthBytes(final String queueName) throws Exception
{
+ return getStatistics(queueName, "queueDepthBytes").intValue();
+ }
+
+ private Number getStatistics(final String queueName, final String statisticsName) throws Exception
+ {
Map<String, Object> arguments =
- Collections.singletonMap("statistics", Collections.singletonList("queueDepthBytes"));
+ Collections.singletonMap("statistics", Collections.singletonList(statisticsName));
Object statistics = performOperationUsingAmqpManagement(queueName,
"getStatistics",
"org.apache.qpid.Queue",
@@ -318,8 +323,8 @@ public class ProducerFlowControlTest extends JmsTestBase
assertTrue("Statistics is not map", statistics instanceof Map);
@SuppressWarnings("unchecked")
Map<String, Object> statisticsMap = (Map<String, Object>) statistics;
- assertTrue("queueDepthBytes is not present", statisticsMap.get("queueDepthBytes") instanceof Number);
- return ((Number) statisticsMap.get("queueDepthBytes")).intValue();
+ assertTrue(String.format("%s is not present", statisticsName), statisticsMap.get(statisticsName) instanceof Number);
+ return ((Number) statisticsMap.get(statisticsName));
}
private void setFlowLimits(final String queueName, final int blockValue, final int resumeValue) throws Exception
@@ -395,16 +400,49 @@ public class ProducerFlowControlTest extends JmsTestBase
return send;
}
+ private boolean awaitStatisticsValue(String queueName, String statisticsName, Number expectedValue, long timeout)
+ throws Exception
+ {
+ return await(timeout, expectedValue, () -> {
+ try
+ {
+ return getStatistics(queueName, statisticsName);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+
private boolean awaitAttributeValue(String queueName, String attributeName, Object expectedValue, long timeout)
throws Exception
{
+ return await(timeout, expectedValue, () -> {
+ try
+ {
+ Map<String, Object> attributes =
+ readEntityUsingAmqpManagement(queueName, "org.apache.qpid.Queue", false);
+ return attributes.get(attributeName);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
+ private boolean await(long timeout, Object expectedValue, final Supplier<Object> supplier)
+ throws Exception
+ {
long startTime = System.currentTimeMillis();
long endTime = startTime + timeout;
boolean found = false;
do
{
- Map<String, Object> attributes = readEntityUsingAmqpManagement(queueName, "org.apache.qpid.Queue", false);
- Object actualValue = attributes.get(attributeName);
+
+ Object actualValue = supplier.get();
if (expectedValue == null)
{
found = actualValue == null;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org