activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1057179 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
Date Mon, 10 Jan 2011 13:04:52 GMT
Author: gtully
Date: Mon Jan 10 13:04:52 2011
New Revision: 1057179

URL: http://svn.apache.org/viewvc?rev=1057179&view=rev
Log:
make manual test a little easier to run

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java?rev=1057179&r1=1057178&r2=1057179&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/kahadb/NoSpaceIOTest.java
Mon Jan 10 13:04:52 2011
@@ -36,19 +36,28 @@ import org.junit.Test;
 public class NoSpaceIOTest {
     private static final Log LOG = LogFactory.getLog(NoSpaceIOTest.class);
 
+    // need an app to input to console in intellij idea
+    public static void main(String[] args) throws Exception {
+       new NoSpaceIOTest().testRunOutOfSpace();
+    }
+
     // handy way to validate some out of space related errors with a usb key
     // allow it to run out of space, delete toDelete and see it recover
-    @Ignore("needs small volume, like usb key") @Test
+    @Ignore("needs small volume, like usb key")
+    @Test
     public void testRunOutOfSpace() throws Exception {
         BrokerService broker = new BrokerService();
         File dataDir = new File("/Volumes/NO NAME/");
         File useUpSpace = new File(dataDir, "bigFile");
         if (!useUpSpace.exists()) {
+            LOG.info("using up some space...");
             RandomAccessFile filler = new RandomAccessFile(useUpSpace, "rw");
-            filler.setLength(1024*1024*1412); // use ~1.5G of 2G (usb) volume
+            filler.setLength(1024*1024*1212); // use ~1.xG of 2G (usb) volume
+            filler.close();
             File toDelete = new File(dataDir, "toDelete");
             filler = new RandomAccessFile(toDelete, "rw");
             filler.setLength(1024*1024*32*10); // 10 data files
+            filler.close();
         }
         broker.setDataDirectoryFile(dataDir);
         broker.start();
@@ -60,7 +69,18 @@ public class NoSpaceIOTest {
 
         AtomicLong sent = new AtomicLong(0);
         try {
-            produce(sent, 100);
+            produce(sent, 200);
+        } catch (Exception expected) {
+            LOG.info("got ex, sent: " + sent);
+        }
+        LOG.info("sent: " + sent);
+        System.out.println("Remove toDelete file and press any key to continue");
+        int read = System.in.read();
+        System.err.println("read:" + read);
+
+        LOG.info("Trying to send again: " + sent);
+        try {
+            produce(sent, 200);
         } catch (Exception expected) {
             LOG.info("got ex, sent: " + sent);
         }
@@ -69,24 +89,32 @@ public class NoSpaceIOTest {
 
     private void consume(AtomicLong consumed) throws JMSException {
         Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
-        c.start();
-        Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        MessageConsumer consumer = s.createConsumer(new ActiveMQQueue("t"));
-        while (consumer.receive(2000) != null) {
-            consumed.incrementAndGet();
+        try {
+            c.start();
+            Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = s.createConsumer(new ActiveMQQueue("t"));
+            while (consumer.receive(2000) != null) {
+                consumed.incrementAndGet();
+            }
+        } finally {
+            c.close();
         }
     }
 
     private void produce(AtomicLong sent, long toSend) throws JMSException {
         Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
-        c.start();
-        Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        MessageProducer producer = s.createProducer(new ActiveMQQueue("t"));
-        TextMessage m = s.createTextMessage();
-        m.setText(String.valueOf(new char[1024*1024]));
-        for (int i=0; i<toSend; i++) {
-            producer.send(m);
-            sent.incrementAndGet();
+        try {
+            c.start();
+            Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = s.createProducer(new ActiveMQQueue("t"));
+            TextMessage m = s.createTextMessage();
+            m.setText(String.valueOf(new char[1024*1024]));
+            for (int i=0; i<toSend; i++) {
+                producer.send(m);
+                sent.incrementAndGet();
+            }
+        } finally {
+            c.close();
         }
     }
 }



Mime
View raw message