[1/3] activemq-artemis git commit: ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/3] activemq-artemis git commit: ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value

nigrofranz
Repository: activemq-artemis
Updated Branches:
  refs/heads/2.6.x 4256b2f7d -> 496e34859


ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value

(cherry picked from commit a3001fd9bd8456f30ba0ddddc9ba767e32bad7e1)


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

Branch: refs/heads/2.6.x
Commit: 0790698ebffeb7a5d4b970b37f880c5cdfb77d10
Parents: a1f74d8
Author: feuillemorte <[hidden email]>
Authored: Thu Dec 13 15:14:05 2018 +0100
Committer: Francesco Nigro <[hidden email]>
Committed: Fri Dec 14 12:19:07 2018 +0100

----------------------------------------------------------------------
 .../artemis/core/journal/impl/JournalFilesRepository.java     | 4 ++++
 .../artemis/core/config/impl/FileConfigurationTest.java       | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0790698e/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
index eb4740f..2c6033b 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
@@ -242,6 +242,10 @@ public class JournalFilesRepository {
       return dataFiles.size();
    }
 
+   public int getJournalFileOpenTimeout() {
+      return journalFileOpenTimeout;
+   }
+
    public Collection<JournalFile> getDataFiles() {
       return dataFiles;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0790698e/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index c328acc..1317def 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
 import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
 import org.apache.activemq.artemis.utils.RandomUtil;
 import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
@@ -668,6 +669,8 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       ActiveMQServerImpl server = new ActiveMQServerImpl();
       try {
          server.start();
+         JournalImpl journal = (JournalImpl) server.getStorageManager().getBindingsJournal();
+         Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), journal.getFilesRepository().getJournalFileOpenTimeout());
          Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), server.getConfiguration().getJournalFileOpenTimeout());
       } finally {
          server.stop();
@@ -676,12 +679,14 @@ public class FileConfigurationTest extends ConfigurationImplTest {
 
    @Test
    public void testJournalFileOpenTimeoutValue() throws Exception {
-      int timeout = RandomUtil.randomInt();
+      int timeout = RandomUtil.randomPositiveInt();
       Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml");
       configuration.setJournalFileOpenTimeout(timeout);
       ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
       try {
          server.start();
+         JournalImpl journal = (JournalImpl) server.getStorageManager().getBindingsJournal();
+         Assert.assertEquals(timeout, journal.getFilesRepository().getJournalFileOpenTimeout());
          Assert.assertEquals(timeout, server.getConfiguration().getJournalFileOpenTimeout());
       } finally {
          server.stop();

Reply | Threaded
Open this post in threaded view
|

[2/3] activemq-artemis git commit: ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value

nigrofranz
ARTEMIS-2201 Added tests on DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT value

(cherry picked from commit 6dfa9a1fa4a22705ed6c3ee9a1c0f20046cbfb0a)


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

Branch: refs/heads/2.6.x
Commit: a1f74d86db7003fa64e59a4aace9b7e7de659645
Parents: 4256b2f
Author: feuillemorte <[hidden email]>
Authored: Tue Dec 11 15:05:45 2018 +0100
Committer: Francesco Nigro <[hidden email]>
Committed: Fri Dec 14 12:19:08 2018 +0100

----------------------------------------------------------------------
 .../core/config/impl/FileConfigurationTest.java | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a1f74d86/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index 4cdd11c..c328acc 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -29,6 +29,8 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
+import org.apache.activemq.artemis.utils.RandomUtil;
 import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
 import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
 import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
@@ -661,6 +663,31 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       assertTrue("check failed, " + defaultConfirmationWinSize + ":" + defaultIdCacheSize, ConfigurationImpl.checkoutDupCacheSize(defaultConfirmationWinSize, defaultIdCacheSize));
    }
 
+   @Test
+   public void testJournalFileOpenTimeoutDefaultValue() throws Exception {
+      ActiveMQServerImpl server = new ActiveMQServerImpl();
+      try {
+         server.start();
+         Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(), server.getConfiguration().getJournalFileOpenTimeout());
+      } finally {
+         server.stop();
+      }
+   }
+
+   @Test
+   public void testJournalFileOpenTimeoutValue() throws Exception {
+      int timeout = RandomUtil.randomInt();
+      Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml");
+      configuration.setJournalFileOpenTimeout(timeout);
+      ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
+      try {
+         server.start();
+         Assert.assertEquals(timeout, server.getConfiguration().getJournalFileOpenTimeout());
+      } finally {
+         server.stop();
+      }
+   }
+
    @Override
    protected Configuration createConfiguration() throws Exception {
       FileConfiguration fc = new FileConfiguration();
@@ -670,6 +697,14 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       return fc;
    }
 
+   private Configuration createConfiguration(String filename) throws Exception {
+      FileConfiguration fc = new FileConfiguration();
+      FileDeploymentManager deploymentManager = new FileDeploymentManager(filename);
+      deploymentManager.addDeployable(fc);
+      deploymentManager.readConfiguration();
+      return fc;
+   }
+
    public static class EmptyPlugin1 implements ActiveMQServerPlugin {
 
    }

Reply | Threaded
Open this post in threaded view
|

[3/3] activemq-artemis git commit: ARTEMIS-2190 core JMS client leaks temp dest names

nigrofranz
In reply to this post by nigrofranz
ARTEMIS-2190 core JMS client leaks temp dest names

(cherry picked from commit 4ab7923a84230545b1f9eada0b9e595d5c94dc11)


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

Branch: refs/heads/2.6.x
Commit: 496e348599306e60c308bf6008ebdcac2fb9750c
Parents: 0790698
Author: Justin Bertram <[hidden email]>
Authored: Tue Dec 4 11:01:30 2018 -0600
Committer: Francesco Nigro <[hidden email]>
Committed: Fri Dec 14 12:23:08 2018 +0100

----------------------------------------------------------------------
 .../artemis/jms/client/ActiveMQConnection.java  |   1 +
 .../jms/tests/TemporaryDestinationTest.java     | 168 +++++++++++++++++++
 2 files changed, 169 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/496e3485/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
index 7164a2c..9745cb1 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQConnection.java
@@ -537,6 +537,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
 
    public void removeTemporaryQueue(final SimpleString queueAddress) {
       tempQueues.remove(queueAddress);
+      knownDestinations.remove(queueAddress);
    }
 
    public void addKnownDestination(final SimpleString address) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/496e3485/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
index 8791278..6b29aea 100644
--- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
+++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
@@ -27,6 +27,9 @@ import javax.jms.TemporaryTopic;
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
 
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
 import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport;
 import org.junit.Test;
 
@@ -126,6 +129,51 @@ public class TemporaryDestinationTest extends JMSTestCase {
       }
    }
 
+   @Test
+   public void testTemporaryQueueLeak() throws Exception {
+      ActiveMQConnection conn = null;
+
+      try {
+         conn = (ActiveMQConnection) createConnection();
+
+         Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
+
+         MessageProducer producer = producerSession.createProducer(tempQueue);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         ProxyAssertSupport.assertNotNull(m2);
+
+         ProxyAssertSupport.assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         tempQueue.delete();
+
+         ProxyAssertSupport.assertFalse(conn.containsKnownDestination(SimpleString.toSimpleString(tempQueue.getQueueName())));
+
+         ProxyAssertSupport.assertFalse(conn.containsTemporaryQueue(SimpleString.toSimpleString(tempQueue.getQueueName())));
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+
    /**
     * http://jira.jboss.com/jira/browse/JBMESSAGING-93
     */
@@ -266,6 +314,126 @@ public class TemporaryDestinationTest extends JMSTestCase {
    }
 
    @Test
+   public void testTemporaryQueueDeletedAfterSessionClosed() throws Exception {
+      servers.get(0).getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
+
+      Connection conn = null;
+
+      try {
+         conn = createConnection();
+
+         Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Make sure temporary queue cannot be used after it has been deleted
+
+         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
+
+         MessageProducer producer = producerSession.createProducer(tempQueue);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         ProxyAssertSupport.assertNotNull(m2);
+
+         ProxyAssertSupport.assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         consumerSession.close();
+
+         producer.close();
+
+         producerSession.close();
+
+         tempQueue.delete();
+
+         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         try {
+            producer = producerSession.createProducer(tempQueue);
+            producer.send(m);
+            ProxyAssertSupport.fail();
+         } catch (JMSException e) {
+         }
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+
+   @Test
+   public void testTemporaryTopicDeletedAfterSessionClosed() throws Exception {
+      servers.get(0).getActiveMQServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
+
+      Connection conn = null;
+
+      try {
+         conn = createConnection();
+
+         Session producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         // Make sure temporary topic cannot be used after it has been deleted
+
+         TemporaryTopic tempTopic = producerSession.createTemporaryTopic();
+
+         MessageProducer producer = producerSession.createProducer(tempTopic);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempTopic);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         ProxyAssertSupport.assertNotNull(m2);
+
+         ProxyAssertSupport.assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         consumerSession.close();
+
+         producer.close();
+
+         producerSession.close();
+
+         tempTopic.delete();
+
+         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         try {
+            producer = producerSession.createProducer(tempTopic);
+            producer.send(m);
+            ProxyAssertSupport.fail();
+         } catch (JMSException e) {
+         }
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+
+   @Test
    public void testTemporaryTopicBasic() throws Exception {
       Connection conn = null;