You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Robbie Gemmell (Jira)" <ji...@apache.org> on 2021/08/30 11:04:00 UTC
[jira] [Commented] (ARTEMIS-3450) StaticPoolTest and
DiscoveryPoolTest fail sporadically in CI
[ https://issues.apache.org/jira/browse/ARTEMIS-3450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17406680#comment-17406680 ]
Robbie Gemmell commented on ARTEMIS-3450:
-----------------------------------------
Diff to help show the noted issues (which again, dont necessarily explain the failures):
{noformat}
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/pools/PoolTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/pools/PoolTestBase.java
index 1f7505ebd8..4d1099953a 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/pools/PoolTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/pools/PoolTestBase.java
@@ -65,24 +65,28 @@ public abstract class PoolTestBase {
pool.start();
- Wait.assertEquals(targets, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ try {
+ Wait.assertEquals(targets, () -> pool.getTargets().size(), CHECK_TIMEOUT);
- targetFactory.getCreatedTargets().stream().limit(targets - quorumSize + 1)
- .forEach(mockTarget -> mockTarget.setReady(false));
+ targetFactory.getCreatedTargets().stream().limit(targets - quorumSize + 1)
+ .forEach(mockTarget -> mockTarget.setReady(false));
- Wait.assertEquals(0, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ Wait.assertEquals(0, () -> pool.getTargets().size(), CHECK_TIMEOUT);
- targetFactory.getCreatedTargets().get(0).setReady(true);
+ targetFactory.getCreatedTargets().get(0).setReady(true);
- Wait.assertEquals(quorumSize, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ Wait.assertEquals(quorumSize, () -> pool.getTargets().size(), CHECK_TIMEOUT);
- pool.setQuorumSize(quorumSize + 1);
+ pool.setQuorumSize(quorumSize + 1);
- Wait.assertEquals(0, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ Wait.assertEquals(0, () -> pool.getTargets().size(), CHECK_TIMEOUT);
- targetFactory.getCreatedTargets().get(1).setReady(true);
+ targetFactory.getCreatedTargets().get(1).setReady(true);
- Wait.assertEquals(quorumSize + 1, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ Wait.assertEquals(quorumSize + 1, () -> pool.getTargets().size(), CHECK_TIMEOUT);
+ } finally {
+ pool.stop();
+ }
}
@@ -96,10 +100,6 @@ public abstract class PoolTestBase {
Assert.assertEquals(0, pool.getTargets().size());
Assert.assertEquals(0, pool.getAllTargets().size());
Assert.assertEquals(0, targetFactory.getCreatedTargets().size());
- targetFactory.getCreatedTargets().forEach(mockTarget -> {
- Assert.assertFalse(pool.isTargetReady(mockTarget));
- Assert.assertEquals(0, targetProbe.getTargetExecutions(mockTarget));
- });
pool.start();
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/targets/MockTargetProbe.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/targets/MockTargetProbe.java
index d8c3aa2e48..eee0caf422 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/targets/MockTargetProbe.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/balancing/targets/MockTargetProbe.java
@@ -17,11 +17,11 @@
package org.apache.activemq.artemis.core.server.balancing.targets;
-import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
public class MockTargetProbe extends TargetProbe {
- private final Map<Target, Integer> targetExecutions = new HashMap<>();
+ private final Map<Target, Integer> targetExecutions = new ConcurrentHashMap<>();
private boolean checked;
{noformat}
> StaticPoolTest and DiscoveryPoolTest fail sporadically in CI
> ------------------------------------------------------------
>
> Key: ARTEMIS-3450
> URL: https://issues.apache.org/jira/browse/ARTEMIS-3450
> Project: ActiveMQ Artemis
> Issue Type: Test
> Components: Tests
> Affects Versions: 2.18.0
> Reporter: Robbie Gemmell
> Priority: Major
>
> The StaticPoolTest and DiscoveryPoolTest tests added in ARTEMIS-3365 fail sporadically in CI
> Some examples:
> https://github.com/apache/activemq-artemis/runs/3416448949?check_suite_focus=true#step:5:2325
> https://github.com/apache/activemq-artemis/runs/3433060966?check_suite_focus=true#step:5:2223
> Looking at the tests I do see a few small issues, though they may not explain the failures:
> - The MockTargetProbe contains a HashMap used from multiple threads (test and pool) in a manner that isnt thread safe. It actually threw ConcurrentModificationException during at least one CI run (e.g https://github.com/apache/activemq-artemis/runs/3416448949?check_suite_focus=true#step:5:2163). That may or may not be the cause of the test failure seen in the same log (note it isnt seen in the other test log, though it failed at a different assertion). It should use ConcurrentHashMap or perhaps alternatively protect use of the map more generally.
> - The PoolTestBase#testPoolQuorumWithMultipleTargets test creates and starts a pool but doesnt ensure it is stopped on assertion failure. The DiscoveryPoolTest subclass runs this test with a pool using a scheduled executor, so it should presumably be cleaned up in the same manner the other tests all use.
> - One of the tests asserts there are no 'createdTargets' entries, and then immediately iterates those [non-existent] entries to assert on the non-existent values, which seems quite strange.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)