This is an automated email from the ASF dual-hosted git repository.
brusdev 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 1b07c32 NO-JIRA Fix activemq5-unit-tests with byteman
1b07c32 is described below
commit 1b07c3222a331e1cc18617240509a386ed00b373
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Mon Jan 17 16:50:19 2022 +0100
NO-JIRA Fix activemq5-unit-tests with byteman
---
pom.xml | 1 +
tests/activemq5-unit-tests/pom.xml | 2 -
.../FailoverConsumerOutstandingCommitTest.java | 126 ---------------------
.../failover/FailoverTransactionTest.java | 1 -
tests/extra-tests/pom.xml | 1 -
tests/pom.xml | 1 +
6 files changed, 2 insertions(+), 130 deletions(-)
diff --git a/pom.xml b/pom.xml
index f8d44d5..bccd724 100644
--- a/pom.xml
+++ b/pom.xml
@@ -210,6 +210,7 @@
-Dlogging.configuration="file:${activemq.basedir}/tests/config/${logging.config}"
-Djava.library.path="${activemq.basedir}/target/bin/lib/linux-x86_64:${activemq.basedir}/target/bin/lib/linux-i686"
-Djgroups.bind_addr=localhost
-Djava.net.preferIPv4Stack=true -Dbasedir=${basedir}
+ -Djdk.attach.allowAttachSelf=true
</activemq-surefire-argline>
<activemq.basedir>${project.basedir}</activemq.basedir>
<skipOWASP>true</skipOWASP>
diff --git a/tests/activemq5-unit-tests/pom.xml
b/tests/activemq5-unit-tests/pom.xml
index dfd8ec9..b1029bf 100644
--- a/tests/activemq5-unit-tests/pom.xml
+++ b/tests/activemq5-unit-tests/pom.xml
@@ -41,8 +41,6 @@
<jasypt-version>1.9.3</jasypt-version>
<directory-version>2.0.0-M6</directory-version>
<activeio-core-version>3.1.4</activeio-core-version>
- <byteman.version>2.2.1</byteman.version>
-
</properties>
<dependencies>
diff --git
a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
index ed397dd..be53d6f 100644
---
a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
+++
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverConsumerOutstandingCommitTest.java
@@ -24,7 +24,6 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
-import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -43,7 +42,6 @@ import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -162,130 +160,6 @@ public class FailoverConsumerOutstandingCommitTest
extends OpenwireArtemisBaseTe
}
@Test
- @BMRules(
- rules = {@BMRule(
- name = "set no return response",
- targetClass =
"org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
- targetMethod = "processCommitTransactionOnePhase",
- targetLocation = "ENTRY",
- binding = "owconn:OpenWireConnection = $0; context =
owconn.getContext()",
- action =
"org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"),
-
- @BMRule(
- name = "stop broker before commit",
- targetClass =
"org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
- targetMethod = "processCommitTransactionOnePhase",
- targetLocation = "ENTRY",
- action =
"org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction();return
null")})
- public void TestFailoverConsumerOutstandingSendTxIncomplete() throws
Exception {
- doTestFailoverConsumerOutstandingSendTx(false);
- }
-
- @Test
- @BMRules(
- rules = {@BMRule(
- name = "set no return response",
- targetClass =
"org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
- targetMethod = "processCommitTransactionOnePhase",
- targetLocation = "ENTRY",
- action =
"org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.holdResponse($0)"),
@BMRule(
- name = "stop broker after commit",
- targetClass =
"org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
- targetMethod = "processCommitTransactionOnePhase",
- targetLocation = "AT EXIT",
- action =
"org.apache.activemq.transport.failover.FailoverConsumerOutstandingCommitTest.stopServerInTransaction()")})
- public void TestFailoverConsumerOutstandingSendTxComplete() throws
Exception {
- doTestFailoverConsumerOutstandingSendTx(true);
- }
-
- public void doTestFailoverConsumerOutstandingSendTx(final boolean
doActualBrokerCommit) throws Exception {
- final boolean watchTopicAdvisories = true;
- server = createBroker();
- server.start();
- brokerStopLatch = new CountDownLatch(1);
-
- ActiveMQConnectionFactory cf = new
ActiveMQConnectionFactory("failover:(" + url + ")");
- cf.setWatchTopicAdvisories(watchTopicAdvisories);
- cf.setDispatchAsync(false);
-
- final ActiveMQConnection connection = (ActiveMQConnection)
cf.createConnection();
- connection.start();
-
- final Session producerSession = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
- final Queue destination = producerSession.createQueue(QUEUE_NAME +
"?consumer.prefetchSize=" + prefetch);
-
- final Queue signalDestination = producerSession.createQueue(QUEUE_NAME +
".signal" + "?consumer.prefetchSize=" + prefetch);
-
- final Session consumerSession = connection.createSession(true,
Session.SESSION_TRANSACTED);
-
- final CountDownLatch commitDoneLatch = new CountDownLatch(1);
- final CountDownLatch messagesReceived = new CountDownLatch(3);
- final AtomicBoolean gotCommitException = new AtomicBoolean(false);
- final ArrayList<TextMessage> receivedMessages = new ArrayList<>();
- final MessageConsumer testConsumer =
consumerSession.createConsumer(destination);
- doByteman.set(true);
- testConsumer.setMessageListener(new MessageListener() {
-
- @Override
- public void onMessage(Message message) {
- LOG.info("consume one: " + message);
- assertNotNull("got message", message);
- receivedMessages.add((TextMessage) message);
- try {
- LOG.info("send one");
- produceMessage(consumerSession, signalDestination, 1);
- LOG.info("commit session");
- consumerSession.commit();
- } catch (JMSException e) {
- LOG.info("commit exception", e);
- gotCommitException.set(true);
- }
- commitDoneLatch.countDown();
- messagesReceived.countDown();
- LOG.info("done commit");
- }
- });
-
- // may block if broker shutdown happens quickly
- new Thread() {
- @Override
- public void run() {
- LOG.info("producer started");
- try {
- produceMessage(producerSession, destination, prefetch * 2);
- } catch (javax.jms.IllegalStateException
SessionClosedExpectedOnShutdown) {
- } catch (JMSException e) {
- e.printStackTrace();
- fail("unexpceted ex on producer: " + e);
- }
- LOG.info("producer done");
- }
- }.start();
-
- // will be stopped by the plugin
- brokerStopLatch.await();
- doByteman.set(false);
- server.stop();
- server = createBroker();
- server.start();
-
- assertTrue("commit done through failover", commitDoneLatch.await(20,
TimeUnit.SECONDS));
- assertTrue("commit failed", gotCommitException.get());
- assertTrue("another message was received after failover",
messagesReceived.await(20, TimeUnit.SECONDS));
- int receivedIndex = 0;
- assertEquals("get message 0 first", MESSAGE_TEXT + "0",
receivedMessages.get(receivedIndex++).getText());
- if (!doActualBrokerCommit) {
- // it will be redelivered and not tracked as a duplicate
- assertEquals("get message 0 second", MESSAGE_TEXT + "0",
receivedMessages.get(receivedIndex++).getText());
- }
- assertTrue("another message was received", messagesReceived.await(20,
TimeUnit.SECONDS));
- assertEquals("get message 1 eventually", MESSAGE_TEXT + "1",
receivedMessages.get(receivedIndex++).getText());
-
- connection.close();
- server.stop();
- }
-
- @Test
public void testRollbackFailoverConsumerTx() throws Exception {
server = createBroker();
server.start();
diff --git
a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
index d1f91d0..218e20c 100644
---
a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
+++
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverTransactionTest.java
@@ -232,7 +232,6 @@ public class FailoverTransactionTest extends
OpenwireArtemisBaseTest {
targetClass =
"org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor",
targetMethod = "processMessage",
targetLocation = "EXIT",
- binding = "owconn:OpenWireConnection = $0; context =
owconn.getContext()",
action =
"org.apache.activemq.transport.failover.FailoverTransactionTest.holdResponseAndStopBroker($0)")})
public void testFailoverSendReplyLost() throws Exception {
LOG.info(this + " running test testFailoverSendReplyLost");
diff --git a/tests/extra-tests/pom.xml b/tests/extra-tests/pom.xml
index 14febed..70eac22 100644
--- a/tests/extra-tests/pom.xml
+++ b/tests/extra-tests/pom.xml
@@ -32,7 +32,6 @@
<name>ActiveMQ Artemis Extra Tests</name>
<properties>
- <byteman.version>4.0.11</byteman.version>
<activemq.basedir>${project.basedir}/../..</activemq.basedir>
<jboss-jts.version>4.17.13.Final</jboss-jts.version>
<hornetq.version>2.4.7.Final</hornetq.version>
diff --git a/tests/pom.xml b/tests/pom.xml
index a01df13..8713c1c 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -29,6 +29,7 @@
<properties>
<activemq.basedir>${project.basedir}/..</activemq.basedir>
+ <byteman.version>4.0.18</byteman.version>
</properties>
<dependencyManagement>