This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 0eefc38d93 ARTEMIS-4250 Spawning VM to avoid thread leaking on
ShutdownOnCriticalIOErrorMoveNextTest
0eefc38d93 is described below
commit 0eefc38d9355e407be51cb397fef7c2f704ae330
Author: Clebert Suconic <[email protected]>
AuthorDate: Sat Apr 22 23:43:17 2023 -0400
ARTEMIS-4250 Spawning VM to avoid thread leaking on
ShutdownOnCriticalIOErrorMoveNextTest
---
.../ShutdownOnCriticalIOErrorMoveNextTest.java | 51 ++++++++++++++++------
1 file changed, 37 insertions(+), 14 deletions(-)
diff --git
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/ShutdownOnCriticalIOErrorMoveNextTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/ShutdownOnCriticalIOErrorMoveNextTest.java
index 26e93b9b73..4073557b9b 100644
---
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/ShutdownOnCriticalIOErrorMoveNextTest.java
+++
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/critical/ShutdownOnCriticalIOErrorMoveNextTest.java
@@ -22,6 +22,7 @@ import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import java.io.File;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.activemq.artemis.api.core.Message;
@@ -40,35 +41,57 @@ 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.Wait;
+import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.junit.Assert;
import org.junit.Test;
public class ShutdownOnCriticalIOErrorMoveNextTest extends ActiveMQTestBase {
+ private static final int OK = 3;
+
+ public static void main(String[] arg) {
+ ShutdownOnCriticalIOErrorMoveNextTest testInst = new
ShutdownOnCriticalIOErrorMoveNextTest();
+ // some methods are not static, so we need an instance
+ testInst.testSimplyDownAfterErrorSpawned();
+ }
+
@Test
public void testSimplyDownAfterError() throws Exception {
- deleteDirectory(new File("./target/server"));
- ActiveMQServer server = createServer("./target/server");
+ Process process =
SpawnedVMSupport.spawnVM(ShutdownOnCriticalIOErrorMoveNextTest.class.getName());
+ runAfter(process::destroyForcibly);
+ Assert.assertTrue(process.waitFor(10, TimeUnit.SECONDS));
+ Assert.assertEquals(OK, process.exitValue());
+ }
- server.start();
+ public void testSimplyDownAfterErrorSpawned() {
+ try {
+ deleteDirectory(new File("./target/server"));
+ ActiveMQServer server = createServer("./target/server");
- ConnectionFactory factory = new ActiveMQConnectionFactory();
- Connection connection = factory.createConnection();
+ server.start();
- Session session = connection.createSession();
+ ConnectionFactory factory = new ActiveMQConnectionFactory();
+ Connection connection = factory.createConnection();
- MessageProducer producer =
session.createProducer(session.createQueue("queue"));
+ Session session = connection.createSession();
- try {
- for (int i = 0; i < 500; i++) {
- producer.send(session.createTextMessage("text"));
+ MessageProducer producer =
session.createProducer(session.createQueue("queue"));
+
+ try {
+ for (int i = 0; i < 500; i++) {
+ producer.send(session.createTextMessage("text"));
+ }
+ } catch (JMSException expected) {
}
- } catch (JMSException expected) {
- }
- Wait.waitFor(() -> !server.isStarted());
+ Wait.waitFor(() -> !server.isStarted());
- Assert.assertFalse(server.isStarted());
+ Assert.assertFalse(server.isStarted());
+ System.exit(OK);
+ } catch (Throwable e) {
+ e.printStackTrace(System.out);
+ System.exit(-1);
+ }
}