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/05/05 02:47:10 UTC
[1/3] activemq-artemis git commit: NO-JIRA More Strict settings for
test thread leaks
Repository: activemq-artemis
Updated Branches:
refs/heads/master 950698960 -> 25f8820c5
NO-JIRA More Strict settings for test thread leaks
I'm investigating thread leakages and previous change on this class here is biting me.
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/bc09a801
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/bc09a801
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/bc09a801
Branch: refs/heads/master
Commit: bc09a8011d245cc853ffc32916aa4e6a922cc162
Parents: 61d2cc5
Author: Clebert Suconic <cl...@apache.org>
Authored: Thu May 3 21:36:40 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri May 4 22:43:56 2018 -0400
----------------------------------------------------------------------
.../activemq/artemis/utils/ThreadLeakCheckRule.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/bc09a801/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
index 1401180..d9dafac 100644
--- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
+++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
@@ -44,6 +44,10 @@ public class ThreadLeakCheckRule extends TestWatcher {
protected boolean testFailed = false;
+ protected Description testDescription = null;
+
+ protected Throwable failure = null;
+
protected Map<Thread, StackTraceElement[]> previousThreads;
/**
@@ -65,7 +69,9 @@ public class ThreadLeakCheckRule extends TestWatcher {
@Override
protected void failed(Throwable e, Description description) {
+ this.failure = e;
this.testFailed = true;
+ this.testDescription = description;
}
@Override
@@ -86,7 +92,7 @@ public class ThreadLeakCheckRule extends TestWatcher {
boolean failedOnce = false;
// if the test failed.. there's no point on waiting a full minute.. we will report it once and go
- long timeout = System.currentTimeMillis() + (testFailed ? 1000 : 60000);
+ long timeout = System.currentTimeMillis() + (testFailed ? 30000 : 60000);
while (failed && timeout > System.currentTimeMillis()) {
failed = checkThread();
@@ -108,6 +114,8 @@ public class ThreadLeakCheckRule extends TestWatcher {
System.out.println("***********************************************************************");
System.out.println(" The test failed and there is a leak");
System.out.println("***********************************************************************");
+ failure.printStackTrace();
+ Assert.fail("Test " + testDescription + " Failed with a leak - " + failure.getMessage());
}
} else if (failedOnce) {
System.out.println("******************** Threads cleared after retries ********************");
[3/3] activemq-artemis git commit: This closes #2069
Posted by cl...@apache.org.
This closes #2069
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/25f8820c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/25f8820c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/25f8820c
Branch: refs/heads/master
Commit: 25f8820c5873ccceb865f581276bf8ce324a0e69
Parents: 9506989 bc09a80
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri May 4 22:47:07 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri May 4 22:47:07 2018 -0400
----------------------------------------------------------------------
.../artemis/utils/ThreadLeakCheckRule.java | 10 ++-
.../client/IncompatibleVersionTest.java | 34 ++++++---
.../integration/client/JournalCrashTest.java | 4 +-
.../integration/client/SendAckFailTest.java | 4 +-
.../integration/clientcrash/ClientTestBase.java | 4 +-
.../integration/cluster/NodeManagerTest.java | 4 +-
.../integration/critical/CriticalCrashTest.java | 4 +-
.../integration/journal/CrashOnCompactTest.java | 4 +-
.../journal/ValidateTransactionHealthTest.java | 4 +-
.../paging/PageCountSyncOnNonTXTest.java | 4 +-
.../security/NettySecurityClientTest.java | 4 +-
.../artemis/tests/util/SpawnedTestBase.java | 26 +++++++
.../amqpJMS/JoramAMQPAggregationTest.java | 6 ++
.../artemis/jms/JoramCoreAggregationTest.java | 5 ++
.../core/util/RandomUtilDistributionTest.java | 5 ++
.../artemis/tests/util/SpawnedVMCheck.java | 29 ++++++++
.../artemis/tests/util/SpawnedVMSupport.java | 74 ++++++++++++++++++--
17 files changed, 192 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
[2/3] activemq-artemis git commit: NO-JIRA Adding checks for spawned
servers on the testsuite
Posted by cl...@apache.org.
NO-JIRA Adding checks for spawned servers on the testsuite
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/61d2cc5b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/61d2cc5b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/61d2cc5b
Branch: refs/heads/master
Commit: 61d2cc5bb0f3a3842a4230252acfa26a20d03927
Parents: 9506989
Author: Clebert Suconic <cl...@apache.org>
Authored: Wed May 2 21:04:29 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri May 4 22:43:56 2018 -0400
----------------------------------------------------------------------
.../client/IncompatibleVersionTest.java | 34 ++++++---
.../integration/client/JournalCrashTest.java | 4 +-
.../integration/client/SendAckFailTest.java | 4 +-
.../integration/clientcrash/ClientTestBase.java | 4 +-
.../integration/cluster/NodeManagerTest.java | 4 +-
.../integration/critical/CriticalCrashTest.java | 4 +-
.../integration/journal/CrashOnCompactTest.java | 4 +-
.../journal/ValidateTransactionHealthTest.java | 4 +-
.../paging/PageCountSyncOnNonTXTest.java | 4 +-
.../security/NettySecurityClientTest.java | 4 +-
.../artemis/tests/util/SpawnedTestBase.java | 26 +++++++
.../amqpJMS/JoramAMQPAggregationTest.java | 6 ++
.../artemis/jms/JoramCoreAggregationTest.java | 5 ++
.../core/util/RandomUtilDistributionTest.java | 5 ++
.../artemis/tests/util/SpawnedVMCheck.java | 29 ++++++++
.../artemis/tests/util/SpawnedVMSupport.java | 74 ++++++++++++++++++--
16 files changed, 183 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
index a2316df..20f98ec 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/IncompatibleVersionTest.java
@@ -41,7 +41,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.version.impl.VersionImpl;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.apache.activemq.artemis.utils.VersionLoader;
import org.junit.After;
@@ -51,7 +51,7 @@ import org.junit.Test;
import static org.apache.activemq.artemis.tests.util.RandomUtil.randomString;
-public class IncompatibleVersionTest extends ActiveMQTestBase {
+public class IncompatibleVersionTest extends SpawnedTestBase {
private static final String WORD_START = "&*STARTED&*";
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
@@ -91,6 +91,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
closeServerLocator(locator);
stopComponent(server);
+ SpawnedVMSupport.forceKill();
super.tearDown();
}
@@ -105,32 +106,32 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
}
@Test
- public void testCompatibleClientVersionWithRealConnection1() throws Exception {
+ public void testCompatibleClientVersionWithRealConnection1() throws Throwable {
assertTrue(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 1));
}
@Test
- public void testCompatibleClientVersionWithRealConnection2() throws Exception {
+ public void testCompatibleClientVersionWithRealConnection2() throws Throwable {
assertTrue(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 5));
}
@Test
- public void testCompatibleClientVersionWithRealConnection3() throws Exception {
+ public void testCompatibleClientVersionWithRealConnection3() throws Throwable {
assertTrue(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 10));
}
@Test
- public void testIncompatibleClientVersionWithRealConnection1() throws Exception {
+ public void testIncompatibleClientVersionWithRealConnection1() throws Throwable {
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 0));
}
@Test
- public void testIncompatibleClientVersionWithRealConnection2() throws Exception {
+ public void testIncompatibleClientVersionWithRealConnection2() throws Throwable {
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 4));
}
@Test
- public void testIncompatibleClientVersionWithRealConnection3() throws Exception {
+ public void testIncompatibleClientVersionWithRealConnection3() throws Throwable {
assertFalse(doTestClientVersionCompatibilityWithRealConnection("1-3,5,7-10", 100));
}
@@ -168,7 +169,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
}
}
- private boolean doTestClientVersionCompatibilityWithRealConnection(String verList, int ver) throws Exception {
+ private boolean doTestClientVersionCompatibilityWithRealConnection(String verList, int ver) throws Throwable {
String propFileName = "compatibility-test-activemq-version.properties";
String serverStartedString = "IncompatibleVersionTest---server---started";
@@ -180,6 +181,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
prop.store(new FileOutputStream("target/test-classes/" + propFileName), null);
Process serverProcess = null;
+ Process client = null;
boolean result = false;
try {
final CountDownLatch latch = new CountDownLatch(1);
@@ -192,7 +194,7 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
serverProcess = SpawnedVMSupport.spawnVMWithLogMacher(WORD_START, runnable, "org.apache.activemq.artemis.tests.integration.client.IncompatibleVersionTest", new String[]{"-D" + VersionLoader.VERSION_PROP_FILE_KEY + "=" + propFileName}, true, "server", serverStartedString);
Assert.assertTrue(latch.await(30, TimeUnit.SECONDS));
- Process client = SpawnedVMSupport.spawnVM("org.apache.activemq.artemis.tests.integration.client.IncompatibleVersionTest", new String[]{"-D" + VersionLoader.VERSION_PROP_FILE_KEY + "=" + propFileName}, "client");
+ client = SpawnedVMSupport.spawnVM("org.apache.activemq.artemis.tests.integration.client.IncompatibleVersionTest", new String[]{"-D" + VersionLoader.VERSION_PROP_FILE_KEY + "=" + propFileName}, "client");
if (client.waitFor() == 0) {
result = true;
@@ -205,6 +207,13 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
/* ignore */
}
}
+ if (client != null) {
+ try {
+ client.destroy();
+ } catch (Throwable t) {
+ /* ignore */
+ }
+ }
}
return result;
@@ -217,6 +226,11 @@ public class IncompatibleVersionTest extends ActiveMQTestBase {
ActiveMQServer server = ActiveMQServers.newActiveMQServer(config, false);
server.start();
+ while (!server.isStarted()) {
+ System.out.println("Still starting");
+ Thread.sleep(100);
+ }
+
System.out.println(WORD_START);
log.info("### server: " + startedString);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java
index 49453d3..944660a 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JournalCrashTest.java
@@ -34,12 +34,12 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
import org.apache.activemq.artemis.core.journal.RecordInfo;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Test;
-public class JournalCrashTest extends ActiveMQTestBase {
+public class JournalCrashTest extends SpawnedTestBase {
private static final int FIRST_RUN = 4;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java
index 68c3ea4..210a9d1 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java
@@ -78,7 +78,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.After;
@@ -86,7 +86,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class SendAckFailTest extends ActiveMQTestBase {
+public class SendAckFailTest extends SpawnedTestBase {
@Before
@After
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java
index 0be37b9..8ea6f07 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/ClientTestBase.java
@@ -18,11 +18,11 @@ package org.apache.activemq.artemis.tests.integration.clientcrash;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.junit.Assert;
import org.junit.Before;
-public abstract class ClientTestBase extends ActiveMQTestBase {
+public abstract class ClientTestBase extends SpawnedTestBase {
protected ActiveMQServer server;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java
index 450c1a9..4c6f6ca 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/NodeManagerTest.java
@@ -21,7 +21,7 @@ import java.util.List;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.junit.Test;
import static org.apache.activemq.artemis.tests.integration.cluster.NodeManagerAction.AWAIT_LIVE;
@@ -36,7 +36,7 @@ import static org.apache.activemq.artemis.tests.integration.cluster.NodeManagerA
import static org.apache.activemq.artemis.tests.integration.cluster.NodeManagerAction.START_LIVE;
import static org.apache.activemq.artemis.tests.integration.cluster.NodeManagerAction.STOP_BACKUP;
-public class NodeManagerTest extends ActiveMQTestBase {
+public class NodeManagerTest extends SpawnedTestBase {
@Test
public void testLive() throws Exception {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/CriticalCrashTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/CriticalCrashTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/CriticalCrashTest.java
index 1a441f2..df69af9 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/CriticalCrashTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/CriticalCrashTest.java
@@ -35,12 +35,12 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Test;
-public class CriticalCrashTest extends ActiveMQTestBase {
+public class CriticalCrashTest extends SpawnedTestBase {
@Test
public void testCrash() throws Exception {
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/CrashOnCompactTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/CrashOnCompactTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/CrashOnCompactTest.java
index 46ca025..3badf29 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/CrashOnCompactTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/CrashOnCompactTest.java
@@ -32,13 +32,13 @@ import org.apache.activemq.artemis.core.journal.impl.AbstractJournalUpdateTask;
import org.apache.activemq.artemis.core.journal.impl.JournalCompactor;
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class CrashOnCompactTest extends ActiveMQTestBase {
+public class CrashOnCompactTest extends SpawnedTestBase {
static int OK = 2;
static int NOT_OK = 3;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java
index 00dd131..5de80f3 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/journal/ValidateTransactionHealthTest.java
@@ -31,7 +31,7 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
import org.apache.activemq.artemis.core.journal.RecordInfo;
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
import org.apache.activemq.artemis.jlibaio.LibaioContext;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Test;
@@ -39,7 +39,7 @@ import org.junit.Test;
/**
* This test spawns a remote VM, as we want to "crash" the VM right after the journal is filled with data
*/
-public class ValidateTransactionHealthTest extends ActiveMQTestBase {
+public class ValidateTransactionHealthTest extends SpawnedTestBase {
private static final int OK = 10;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java
index 886ab5f..fd21729 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PageCountSyncOnNonTXTest.java
@@ -29,14 +29,14 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class PageCountSyncOnNonTXTest extends ActiveMQTestBase {
+public class PageCountSyncOnNonTXTest extends SpawnedTestBase {
public static final String WORD_START = "&*STARTED&*";
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java
index a908f79..15e287b 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/security/NettySecurityClientTest.java
@@ -24,13 +24,13 @@ import java.net.URLDecoder;
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.util.SpawnedTestBase;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class NettySecurityClientTest extends ActiveMQTestBase {
+public class NettySecurityClientTest extends SpawnedTestBase {
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedTestBase.java
new file mode 100644
index 0000000..d8a96c0
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedTestBase.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.util;
+
+import org.junit.Rule;
+
+public class SpawnedTestBase extends ActiveMQTestBase {
+
+ @Rule
+ public SpawnedVMCheck spawnedVMCheck = new SpawnedVMCheck();
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java
----------------------------------------------------------------------
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java
index 1c5f6a3..2d1e95b 100644
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/amqpJMS/JoramAMQPAggregationTest.java
@@ -19,9 +19,11 @@ package org.apache.activemq.artemis.amqpJMS;
import java.io.IOException;
import java.util.Properties;
+import org.apache.activemq.artemis.tests.util.SpawnedVMCheck;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -51,6 +53,10 @@ import org.objectweb.jtests.jms.framework.JMSTestCase;
@SuiteClasses({TopicConnectionTest.class, ConnectionTest.class, MessageBodyTest.class, MessageDefaultTest.class, MessageTypeTest.class, MessageHeaderTest.class, JMSXPropertyTest.class, MessagePropertyConversionTest.class, MessagePropertyTest.class, QueueBrowserTest.class, TemporaryQueueTest.class, SelectorSyntaxTest.class, SelectorTest.class, QueueSessionTest.class, SessionTest.class, TopicSessionTest.class, UnifiedSessionTest.class, TemporaryTopicTest.class,})
public class JoramAMQPAggregationTest extends Assert {
+
+ @Rule
+ public SpawnedVMCheck check = new SpawnedVMCheck();
+
/**
* Should be overridden
*
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
----------------------------------------------------------------------
diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
index 7448b9c..64690f5 100644
--- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
+++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/jms/JoramCoreAggregationTest.java
@@ -19,9 +19,11 @@ package org.apache.activemq.artemis.jms;
import java.io.IOException;
import java.util.Properties;
+import org.apache.activemq.artemis.tests.util.SpawnedVMCheck;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@@ -51,6 +53,9 @@ import org.objectweb.jtests.jms.framework.JMSTestCase;
@SuiteClasses({TopicConnectionTest.class, ConnectionTest.class, MessageBodyTest.class, MessageDefaultTest.class, MessageTypeTest.class, MessageHeaderTest.class, JMSXPropertyTest.class, MessagePropertyConversionTest.class, MessagePropertyTest.class, QueueBrowserTest.class, TemporaryQueueTest.class, SelectorSyntaxTest.class, SelectorTest.class, QueueSessionTest.class, SessionTest.class, TopicSessionTest.class, UnifiedSessionTest.class, TemporaryTopicTest.class,})
public class JoramCoreAggregationTest extends Assert {
+ @Rule
+ public SpawnedVMCheck check = new SpawnedVMCheck();
+
/**
* Should be overridden
*
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java
index 1d8146c..caa0fc9 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/util/RandomUtilDistributionTest.java
@@ -19,9 +19,11 @@ package org.apache.activemq.artemis.tests.unit.core.util;
import java.util.HashSet;
+import org.apache.activemq.artemis.tests.util.SpawnedVMCheck;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.Assert;
+import org.junit.Rule;
import org.junit.Test;
/**
@@ -29,6 +31,9 @@ import org.junit.Test;
*/
public class RandomUtilDistributionTest {
+ @Rule
+ public SpawnedVMCheck check = new SpawnedVMCheck();
+
public static void main(String[] arg) {
long start = Long.parseLong(arg[0]);
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java
new file mode 100644
index 0000000..cc1c043
--- /dev/null
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMCheck.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.util;
+
+import org.junit.rules.ExternalResource;
+
+public class SpawnedVMCheck extends ExternalResource {
+
+ @Override
+ protected void after() {
+ super.after();
+ SpawnedVMSupport.checkProcess();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/61d2cc5b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
index 209fe1e..544b04f 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/util/SpawnedVMSupport.java
@@ -21,12 +21,15 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Paths;
+import java.util.HashSet;
import java.util.List;
import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
@@ -37,6 +40,8 @@ import static java.util.concurrent.TimeUnit.SECONDS;
public final class SpawnedVMSupport {
+ static ConcurrentHashMap<Process, String> startedProcesses = new ConcurrentHashMap();
+
private static final UnitTestLogger log = UnitTestLogger.LOGGER;
public static Process spawnVM(final String className, final String... args) throws Exception {
@@ -94,7 +99,6 @@ public final class SpawnedVMSupport {
}
-
public static Process spawnVM(String classPath,
String wordMatch,
Runnable wordRunning,
@@ -106,11 +110,10 @@ public final class SpawnedVMSupport {
boolean logErrorOutput,
boolean useLogging,
String... args) throws IOException, ClassNotFoundException {
- return spawnVM(classPath, wordMatch, wordRunning, className, memoryArg1,memoryArg2, vmargs, logOutput, logErrorOutput, useLogging, -1, args);
+ return spawnVM(classPath, wordMatch, wordRunning, className, memoryArg1, memoryArg2, vmargs, logOutput, logErrorOutput, useLogging, -1, args);
}
/**
- *
* @param classPath
* @param wordMatch
* @param wordRunning
@@ -121,7 +124,7 @@ public final class SpawnedVMSupport {
* @param logOutput
* @param logErrorOutput
* @param useLogging
- * @param debugPort if <=0 it means no debug
+ * @param debugPort if <=0 it means no debug
* @param args
* @return
* @throws IOException
@@ -200,10 +203,73 @@ public final class SpawnedVMSupport {
ProcessLogger errorLogger = new ProcessLogger(logErrorOutput, process.getErrorStream(), className, wordMatch, wordRunning);
errorLogger.start();
+ startedProcesses.put(process, className);
return process;
}
/**
+ * it will return a pair of dead / alive servers
+ *
+ * @return
+ */
+ private static HashSet<Process> getAliveProcesses() {
+
+ HashSet<Process> aliveProcess = new HashSet<>();
+
+ for (;;) {
+ try {
+ aliveProcess.clear();
+ for (Process process : startedProcesses.keySet()) {
+ if (process.isAlive()) {
+ aliveProcess.add(process);
+ process.destroyForcibly();
+ }
+ }
+ break;
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ return aliveProcess;
+
+ }
+
+ public static void forceKill() {
+
+ HashSet<Process> aliveProcess = getAliveProcesses();
+
+ for (Process alive : aliveProcess) {
+ for (int i = 0; i < 5; i++) {
+ alive.destroyForcibly();
+ try {
+ alive.waitFor(5, TimeUnit.SECONDS);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ }
+
+ public static void checkProcess() {
+
+ HashSet<Process> aliveProcess = getAliveProcesses();
+
+ try {
+ if (!aliveProcess.isEmpty()) {
+ StringBuffer buffer = new StringBuffer();
+ for (Process alive : aliveProcess) {
+ alive.destroyForcibly();
+ buffer.append(startedProcesses.get(alive) + " ");
+ }
+ Assert.fail("There are " + aliveProcess.size() + " processes alive :: " + buffer.toString());
+ }
+ } finally {
+ startedProcesses.clear();
+ }
+ }
+
+ /**
* @param className
* @param process
* @throws ClassNotFoundException