more levedb test cleaning and turning on debug logging to try to figure CI failures

This commit is contained in:
Dejan Bosanac 2014-12-25 14:08:54 +01:00
parent 5315389080
commit 9752e1dc93
6 changed files with 66 additions and 13 deletions

View File

@ -22,6 +22,8 @@ import org.apache.activemq.leveldb.CountDownFuture;
import org.apache.activemq.leveldb.LevelDBStore;
import org.apache.activemq.leveldb.replicated.ElectingLevelDBStore;
import org.apache.activemq.store.MessageStore;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -38,11 +40,16 @@ import static org.junit.Assert.*;
public class ElectingLevelDBStoreTest extends ZooKeeperTestSupport {
protected static final Logger LOG = LoggerFactory.getLogger(ElectingLevelDBStoreTest.class);
ArrayList<ElectingLevelDBStore> stores = new ArrayList<ElectingLevelDBStore>();
ElectingLevelDBStore master = null;
@Test(timeout = 1000*60*10)
public void testElection() throws Exception {
deleteDirectory("leveldb-node1");
deleteDirectory("leveldb-node2");
deleteDirectory("leveldb-node3");
ArrayList<ElectingLevelDBStore> stores = new ArrayList<ElectingLevelDBStore>();
ArrayList<CountDownFuture> pending_starts = new ArrayList<CountDownFuture>();
for(String dir: new String[]{"leveldb-node1", "leveldb-node2", "leveldb-node3"}) {
@ -65,7 +72,6 @@ public class ElectingLevelDBStoreTest extends ZooKeeperTestSupport {
}
// Make sure only of the stores is reporting to be the master.
ElectingLevelDBStore master = null;
for(ElectingLevelDBStore store: stores) {
if( store.isMaster() ) {
assertNull(master);
@ -124,11 +130,6 @@ public class ElectingLevelDBStoreTest extends ZooKeeperTestSupport {
LOG.info("Checking master state");
assertEquals(expected_list, getMessages(ms));
master.stop();
for(ElectingLevelDBStore store: stores) {
store.stop();
}
}
@Test(timeout = 1000 * 60 * 10)
@ -168,10 +169,19 @@ public class ElectingLevelDBStoreTest extends ZooKeeperTestSupport {
}
}
});
}
for (ElectingLevelDBStore store : stores) {
store.stop();
@After
public void stop() throws Exception {
if (master != null) {
master.stop();
FileUtils.deleteDirectory(master.directory());
}
for(ElectingLevelDBStore store: stores) {
store.stop();
FileUtils.deleteDirectory(store.directory());
}
stores.clear();
}
private CountDownFuture asyncStart(final Service service) {

View File

@ -17,6 +17,8 @@
package org.apache.activemq.leveldb.test;
import org.apache.activemq.leveldb.replicated.MasterLevelDBStore;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Test;
import java.net.BindException;
@ -34,9 +36,11 @@ import static org.junit.Assert.*;
*/
public class MasterLevelDBStoreTest {
MasterLevelDBStore store;
@Test(timeout = 1000*60*10)
public void testStoppingStoreStopsTransport() throws Exception {
final MasterLevelDBStore store = new MasterLevelDBStore();
store = new MasterLevelDBStore();
store.setReplicas(0);
ExecutorService threads = Executors.newFixedThreadPool(1);
@ -86,4 +90,12 @@ public class MasterLevelDBStoreTest {
}
}
@After
public void stop() throws Exception {
if (store.isStarted()) {
store.stop();
}
FileUtils.deleteDirectory(store.directory());
}
}

View File

@ -20,11 +20,14 @@ import org.apache.activemq.Service;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.leveldb.CountDownFuture;
import org.apache.activemq.leveldb.LevelDBStore;
import org.apache.activemq.leveldb.replicated.ElectingLevelDBStore;
import org.apache.activemq.leveldb.replicated.MasterLevelDBStore;
import org.apache.activemq.leveldb.replicated.SlaveLevelDBStore;
import org.apache.activemq.leveldb.util.FileSupport;
import org.apache.activemq.store.MessageStore;
import org.apache.commons.io.FileUtils;
import org.fusesource.hawtdispatch.transport.TcpTransport;
import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -44,6 +47,8 @@ import static org.junit.Assert.*;
public class ReplicatedLevelDBStoreTest {
protected static final Logger LOG = LoggerFactory.getLogger(ReplicatedLevelDBStoreTest.class);
ArrayList<LevelDBStore> stores = new ArrayList<LevelDBStore>();
@Test(timeout = 1000*60*10)
public void testMinReplicaEnforced() throws Exception {
@ -55,6 +60,7 @@ public class ReplicatedLevelDBStoreTest {
final MasterLevelDBStore master = createMaster(masterDir);
master.setReplicas(2);
CountDownFuture masterStartLatch = asyncStart(master);
stores.add(master);
// Start the store should not complete since we don't have enough
// replicas.
@ -63,6 +69,7 @@ public class ReplicatedLevelDBStoreTest {
// Adding a slave should allow the master startup to complete.
SlaveLevelDBStore slave = createSlave(master, slaveDir);
slave.start();
stores.add(slave);
assertTrue(masterStartLatch.await(2, TimeUnit.SECONDS));
@ -142,6 +149,12 @@ public class ReplicatedLevelDBStoreTest {
asyncStart(slave2);
masterStart.await();
if (j == 0) {
stores.add(master);
stores.add(slave1);
stores.add(slave2);
}
MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST"));
LOG.info("Checking: "+master.getDirectory());
@ -205,6 +218,7 @@ public class ReplicatedLevelDBStoreTest {
ArrayList<String> expected_list = new ArrayList<String>();
MasterLevelDBStore node1 = createMaster(node1Dir);
stores.add(node1);
CountDownFuture masterStart = asyncStart(node1);
// Lets create a 1 slow slave...
@ -221,8 +235,10 @@ public class ReplicatedLevelDBStoreTest {
return transport;
}
};
stores.add(node2);
configureSlave(node2, node1, node2Dir);
SlaveLevelDBStore node3 = createSlave(node1, node3Dir);
stores.add(node3);
asyncStart(node2);
asyncStart(node3);
@ -253,6 +269,17 @@ public class ReplicatedLevelDBStoreTest {
node2.stop();
}
@After
public void stop() throws Exception {
for(LevelDBStore store: stores) {
if (store.isStarted()) {
store.stop();
}
FileUtils.deleteDirectory(store.directory());
}
stores.clear();
}
private SlaveLevelDBStore createSlave(MasterLevelDBStore master, File directory) {
SlaveLevelDBStore slave = new SlaveLevelDBStore();

View File

@ -18,15 +18,15 @@
#
# The logging properties used during tests..
#
log4j.rootLogger=WARN, console, file
log4j.rootLogger=INFO, console, file
log4j.logger.org.apache.activemq=INFO
log4j.logger.org.apache.activemq.leveldb=INFO
log4j.logger.org.apache.activemq.leveldb=DEBUG
# Console will only display warnnings
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p | %t | %m%n
log4j.appender.console.threshold=WARN
log4j.appender.console.threshold=DEBUG
# File appender will contain all info messages
log4j.appender.file=org.apache.log4j.FileAppender

View File

@ -188,6 +188,8 @@ class LevelDBFastEnqueueTest extends TestCase {
connectionFactory = new ActiveMQConnectionFactory(broker.getTransportConnectors.get(0).getConnectUri + options)
}
protected def createStore: LevelDBStore = {
var store: LevelDBStore = new LevelDBStore
store.setDirectory(new File("target/activemq-data/leveldb"))

View File

@ -23,6 +23,7 @@ import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.leveldb.LevelDBStore;
import org.apache.activemq.store.PersistenceAdapter;
import org.apache.tools.ant.util.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -61,6 +62,7 @@ public class PListTest {
if (brokerService != null && brokerService.isStopped()) {
brokerService.stop();
}
FileUtils.delete(new File("target/activemq-data/haleveldb"));
}
@Test