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 2018/08/08 15:33:39 UTC

[1/2] activemq-artemis git commit: This closes #2226

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 9109fc160 -> 7480452bd


This closes #2226


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/7480452b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/7480452b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/7480452b

Branch: refs/heads/master
Commit: 7480452bdd1f5145e69f41d767aa11eb8fce3d97
Parents: 9109fc1 c1a191c
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed Aug 8 11:33:31 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Aug 8 11:33:31 2018 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/junit/Wait.java |  6 +++++-
 .../management/QueueControlTest.java            | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[2/2] activemq-artemis git commit: ARTEMIS-2016 fix flaky test QueueControlTest#testRemoveAllWithPagingMode

Posted by cl...@apache.org.
ARTEMIS-2016 fix flaky test QueueControlTest#testRemoveAllWithPagingMode

Parameters going into Wait.waitFor were originally wrong, because
`durationMillis: 3, sleepMillis: 100` means you would test the condition
only once. This commit is changing the durationMillis from 3ms to 3s,
swapping the two numbers (duration 100ms, sleep 3ms) would also be reasonable, I think.

Next, Wait.assertEquals is here being used, instead of Assert.assertTrue.

I saw the test fail only once, and never was able to reproduce it again,
but I think this commit does improve the test and so it is worthwhile.

    java.lang.AssertionError
		at org.apache.activemq.artemis.tests.integration.management.QueueControlTest.assertMetrics(QueueControlTest.java:2651)
	    at org.apache.activemq.artemis.tests.integration.management.QueueControlTest.assertMessageMetrics(QueueControlTest.java:2615)
    	at org.apache.activemq.artemis.tests.integration.management.QueueControlTest.testRemoveAllWithPagingMode(QueueControlTest.java:1554)


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/c1a191c5
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/c1a191c5
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/c1a191c5

Branch: refs/heads/master
Commit: c1a191c547c0fb8e0bce4f17751e356b213f1ddb
Parents: 9109fc1
Author: Jiri Danek <jd...@redhat.com>
Authored: Tue Aug 7 18:22:57 2018 +0200
Committer: Clebert Suconic <cl...@apache.org>
Committed: Wed Aug 8 11:33:31 2018 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/artemis/junit/Wait.java |  6 +++++-
 .../management/QueueControlTest.java            | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c1a191c5/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/Wait.java
----------------------------------------------------------------------
diff --git a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/Wait.java b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/Wait.java
index e37539a..c0aa55d 100644
--- a/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/Wait.java
+++ b/artemis-junit/src/main/java/org/apache/activemq/artemis/junit/Wait.java
@@ -52,7 +52,11 @@ public class Wait {
    }
 
    public static void assertEquals(long size, LongCondition condition, long timeout) throws Exception {
-      boolean result = waitFor(() -> condition.getCount() == size, timeout);
+      assertEquals(size, condition, timeout, SLEEP_MILLIS);
+   }
+
+   public static void assertEquals(Long size, LongCondition condition, long timeout, long sleepMillis) throws Exception {
+      boolean result = waitFor(() -> condition.getCount() == size, timeout, sleepMillis);
 
       if (!result) {
          Assert.fail(size + " != " + condition.getCount());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/c1a191c5/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
index 0faa055..123f581 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
@@ -2632,25 +2632,25 @@ public class QueueControlTest extends ManagementTestBase {
                                 Supplier<Number> durableCount, Supplier<Number> durableSize) throws Exception {
 
       //make sure count stat equals message count
-      Assert.assertTrue(Wait.waitFor(() -> count.get().longValue() == messageCount, 3, 100));
+      Assert.assertTrue(Wait.waitFor(() -> count.get().longValue() == messageCount, 3 * 1000, 100));
 
       if (messageCount > 0) {
          //verify size stat greater than 0
-         Assert.assertTrue(Wait.waitFor(() -> size.get().longValue() > 0, 3, 100));
+         Assert.assertTrue(Wait.waitFor(() -> size.get().longValue() > 0, 3 * 1000, 100));
 
          //If durable then make sure durable count and size are correct
          if (durable) {
-            Assert.assertTrue(Wait.waitFor(() -> durableCount.get().longValue() == messageCount, 3, 100));
-            Assert.assertTrue(Wait.waitFor(() -> durableSize.get().longValue() > 0, 3, 100));
+            Wait.assertEquals(messageCount, () -> durableCount.get().longValue(), 3 * 1000, 100);
+            Assert.assertTrue(Wait.waitFor(() -> durableSize.get().longValue() > 0, 3 * 1000, 100));
          } else {
-            Assert.assertTrue(Wait.waitFor(() -> durableCount.get().longValue() == 0, 3, 100));
-            Assert.assertTrue(Wait.waitFor(() -> durableSize.get().longValue() == 0, 3, 100));
+            Wait.assertEquals(0L, () -> durableCount.get().longValue(), 3 * 1000, 100);
+            Wait.assertEquals(0L, () -> durableSize.get().longValue(), 3 * 1000, 100);
          }
       } else {
-         Assert.assertTrue(Wait.waitFor(() -> count.get().longValue() == 0, 3, 100));
-         Assert.assertTrue(Wait.waitFor(() -> durableCount.get().longValue() == 0, 3, 100));
-         Assert.assertTrue(Wait.waitFor(() -> size.get().longValue() == 0, 3, 100));
-         Assert.assertTrue(Wait.waitFor(() -> durableSize.get().longValue() == 0, 3, 100));
+         Wait.assertEquals(0L, () -> count.get().longValue(), 3 * 1000, 100);
+         Wait.assertEquals(0L, () -> durableCount.get().longValue(), 3 * 1000, 100);
+         Wait.assertEquals(0L, () -> size.get().longValue(), 3 * 1000, 100);
+         Wait.assertEquals(0L, () -> durableSize.get().longValue(), 3 * 1000, 100);
       }
    }
 }