mirror of
https://github.com/apache/activemq.git
synced 2025-02-10 03:56:21 +00:00
make manual test a little easier to run
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1057179 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e40b914de
commit
dce325b144
@ -36,19 +36,28 @@ import org.junit.Test;
|
|||||||
public class NoSpaceIOTest {
|
public class NoSpaceIOTest {
|
||||||
private static final Log LOG = LogFactory.getLog(NoSpaceIOTest.class);
|
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
|
// 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
|
// 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 {
|
public void testRunOutOfSpace() throws Exception {
|
||||||
BrokerService broker = new BrokerService();
|
BrokerService broker = new BrokerService();
|
||||||
File dataDir = new File("/Volumes/NO NAME/");
|
File dataDir = new File("/Volumes/NO NAME/");
|
||||||
File useUpSpace = new File(dataDir, "bigFile");
|
File useUpSpace = new File(dataDir, "bigFile");
|
||||||
if (!useUpSpace.exists()) {
|
if (!useUpSpace.exists()) {
|
||||||
|
LOG.info("using up some space...");
|
||||||
RandomAccessFile filler = new RandomAccessFile(useUpSpace, "rw");
|
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");
|
File toDelete = new File(dataDir, "toDelete");
|
||||||
filler = new RandomAccessFile(toDelete, "rw");
|
filler = new RandomAccessFile(toDelete, "rw");
|
||||||
filler.setLength(1024*1024*32*10); // 10 data files
|
filler.setLength(1024*1024*32*10); // 10 data files
|
||||||
|
filler.close();
|
||||||
}
|
}
|
||||||
broker.setDataDirectoryFile(dataDir);
|
broker.setDataDirectoryFile(dataDir);
|
||||||
broker.start();
|
broker.start();
|
||||||
@ -60,7 +69,18 @@ public class NoSpaceIOTest {
|
|||||||
|
|
||||||
AtomicLong sent = new AtomicLong(0);
|
AtomicLong sent = new AtomicLong(0);
|
||||||
try {
|
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) {
|
} catch (Exception expected) {
|
||||||
LOG.info("got ex, sent: " + sent);
|
LOG.info("got ex, sent: " + sent);
|
||||||
}
|
}
|
||||||
@ -69,24 +89,32 @@ public class NoSpaceIOTest {
|
|||||||
|
|
||||||
private void consume(AtomicLong consumed) throws JMSException {
|
private void consume(AtomicLong consumed) throws JMSException {
|
||||||
Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
|
Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
|
||||||
c.start();
|
try {
|
||||||
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
c.start();
|
||||||
MessageConsumer consumer = s.createConsumer(new ActiveMQQueue("t"));
|
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
while (consumer.receive(2000) != null) {
|
MessageConsumer consumer = s.createConsumer(new ActiveMQQueue("t"));
|
||||||
consumed.incrementAndGet();
|
while (consumer.receive(2000) != null) {
|
||||||
|
consumed.incrementAndGet();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void produce(AtomicLong sent, long toSend) throws JMSException {
|
private void produce(AtomicLong sent, long toSend) throws JMSException {
|
||||||
Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
|
Connection c = new ActiveMQConnectionFactory("vm://localhost").createConnection();
|
||||||
c.start();
|
try {
|
||||||
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
c.start();
|
||||||
MessageProducer producer = s.createProducer(new ActiveMQQueue("t"));
|
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||||
TextMessage m = s.createTextMessage();
|
MessageProducer producer = s.createProducer(new ActiveMQQueue("t"));
|
||||||
m.setText(String.valueOf(new char[1024*1024]));
|
TextMessage m = s.createTextMessage();
|
||||||
for (int i=0; i<toSend; i++) {
|
m.setText(String.valueOf(new char[1024*1024]));
|
||||||
producer.send(m);
|
for (int i=0; i<toSend; i++) {
|
||||||
sent.incrementAndGet();
|
producer.send(m);
|
||||||
|
sent.incrementAndGet();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
c.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user