Skip to content

Commit

Permalink
BOOKKEEPER-767: Allow loopback in tests (ivank via fpj)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/zookeeper/bookkeeper/trunk@1600881 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
fpj committed Jun 6, 2014
1 parent 68deb96 commit 80c6e55
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Trunk (unreleased changes)
BOOKKEEPER-763: findbugs fails to run on jenkins (ivank)

BOOKKEEPER-766: Update notice.txt files to include 2014 (ivank via fpj)

BOOKKEEPER-767: Allow loopback in tests (ivank via fpj)

bookkeeper-server:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void testExitCodeZK_REG_FAIL() throws Exception {
tmpDir.delete();
tmpDir.mkdir();

final ServerConfiguration conf = new ServerConfiguration()
final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(null).setJournalDirName(tmpDir.getPath())
.setLedgerDirNames(new String[] { tmpDir.getPath() });

Expand Down Expand Up @@ -370,7 +370,7 @@ public void testWithDiskFull() throws Exception {
tempDir.mkdir();
long usableSpace = tempDir.getUsableSpace();
long totalSpace = tempDir.getTotalSpace();
final ServerConfiguration conf = new ServerConfiguration()
final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(zkutil.getZooKeeperConnectString())
.setZkTimeout(5000).setJournalDirName(tempDir.getPath())
.setLedgerDirNames(new String[] { tempDir.getPath() });
Expand All @@ -392,7 +392,7 @@ public void testWithDiskError() throws Exception {
parent.delete();
parent.mkdir();
File child = File.createTempFile("DiskCheck", "test", parent);
final ServerConfiguration conf = new ServerConfiguration()
final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(zkutil.getZooKeeperConnectString())
.setZkTimeout(5000).setJournalDirName(child.getPath())
.setLedgerDirNames(new String[] { child.getPath() });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.bookkeeper.client.LedgerEntry;
import org.apache.bookkeeper.client.LedgerHandle;
import org.apache.bookkeeper.client.LedgerMetadata;
import org.apache.bookkeeper.conf.TestBKConfiguration;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.meta.LedgerManager;
import org.apache.bookkeeper.meta.LedgerManagerFactory;
Expand Down Expand Up @@ -362,7 +363,7 @@ public void testCompactionSmallEntryLogs() throws Exception {
@Test(timeout=60000)
public void testCompactionSafety() throws Exception {
tearDown(); // I dont want the test infrastructure
ServerConfiguration conf = new ServerConfiguration();
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
final Set<Long> ledgers = Collections.newSetFromMap(new ConcurrentHashMap<Long, Boolean>());
LedgerManager manager = getLedgerManager(ledgers);

Expand Down Expand Up @@ -516,7 +517,7 @@ public LedgerManager.LedgerRange next() throws IOException {
@Test(timeout = 60000)
public void testWhenNoLogsToCompact() throws Exception {
tearDown(); // I dont want the test infrastructure
ServerConfiguration conf = new ServerConfiguration();
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
File tmpDir = File.createTempFile("bkTest", ".dir");
tmpDir.delete();
tmpDir.mkdir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public void testRestartWithHostNameAsBookieID() throws Exception {
String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
newDirectory() };
String journalDir = newDirectory();
ServerConfiguration conf = new ServerConfiguration()
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(zkutil.getZooKeeperConnectString())
.setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
.setBookiePort(bookiePort);
Expand All @@ -390,7 +390,7 @@ public void testRestartWithIpAddressAsBookieID() throws Exception {
String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
newDirectory() };
String journalDir = newDirectory();
ServerConfiguration conf = new ServerConfiguration()
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(zkutil.getZooKeeperConnectString())
.setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
.setBookiePort(bookiePort);
Expand All @@ -412,7 +412,7 @@ public void testRestartWithIpAddressAsBookieID() throws Exception {
*/
@Test(timeout = 60000)
public void testV2dataWithHostNameAsBookieID() throws Exception {
ServerConfiguration conf = new ServerConfiguration()
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
.setZkServers(zkutil.getZooKeeperConnectString())
.setJournalDirName(newV2JournalDirectory())
.setLedgerDirNames(new String[] { newV2LedgerDirectory() })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.bookkeeper.conf.TestBKConfiguration;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.bookie.CheckpointSource.Checkpoint;
import org.apache.bookkeeper.bookie.LedgerDirsManager.LedgerDirsListener;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void teardownExecutor() {
@Test(timeout=60000)
public void testSyncThreadLongShutdown() throws Exception {
int flushInterval = 100;
ServerConfiguration conf = new ServerConfiguration().setFlushInterval(flushInterval);
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
CheckpointSource checkpointSource = new DummyCheckpointSource();
LedgerDirsListener listener = new DummyLedgerDirsListener();

Expand Down Expand Up @@ -150,7 +151,7 @@ public Boolean call() {
@Test(timeout=60000)
public void testSyncThreadSuspension() throws Exception {
int flushInterval = 100;
ServerConfiguration conf = new ServerConfiguration().setFlushInterval(flushInterval);
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
CheckpointSource checkpointSource = new DummyCheckpointSource();
LedgerDirsListener listener = new DummyLedgerDirsListener();

Expand Down Expand Up @@ -194,7 +195,7 @@ public Checkpoint checkpoint(Checkpoint checkpoint)
@Test(timeout=60000)
public void testSyncThreadShutdownOnError() throws Exception {
int flushInterval = 100;
ServerConfiguration conf = new ServerConfiguration().setFlushInterval(flushInterval);
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
CheckpointSource checkpointSource = new DummyCheckpointSource();
final CountDownLatch fatalLatch = new CountDownLatch(1);
LedgerDirsListener listener = new DummyLedgerDirsListener() {
Expand Down Expand Up @@ -225,7 +226,7 @@ public Checkpoint checkpoint(Checkpoint checkpoint)
@Test(timeout=60000)
public void testSyncThreadDisksFull() throws Exception {
int flushInterval = 100;
ServerConfiguration conf = new ServerConfiguration().setFlushInterval(flushInterval);
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
CheckpointSource checkpointSource = new DummyCheckpointSource();
final CountDownLatch diskFullLatch = new CountDownLatch(1);
LedgerDirsListener listener = new DummyLedgerDirsListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static ServerConfiguration newServerConfiguration() {
confReturn.setJournalFlushWhenQueueEmpty(true);
// enable journal format version
confReturn.setJournalFormatVersionToWrite(5);
confReturn.setAllowLoopback(true);
return confReturn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.bookkeeper.client.LedgerHandleAdapter;
import org.apache.bookkeeper.client.LedgerMetadata;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.conf.TestBKConfiguration;
import org.apache.bookkeeper.meta.LedgerManager;
import org.apache.bookkeeper.meta.LedgerManagerFactory;
import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
Expand Down Expand Up @@ -62,16 +63,14 @@ public class AuditorPeriodicBookieCheckTest extends BookKeeperClusterTestCase {
public AuditorPeriodicBookieCheckTest() {
super(3);
baseConf.setPageLimit(1); // to make it easy to push ledger out of cache
baseConf.setAllowLoopback(true);
}

@Before
@Override
public void setUp() throws Exception {
super.setUp();

ServerConfiguration conf = new ServerConfiguration(bsConfs.get(0));
conf.setAllowLoopback(true);
ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
conf.setAuditorPeriodicBookieCheckInterval(CHECK_INTERVAL);
String addr = bs.get(0).getLocalAddress().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ protected void startBookieServer() throws Exception {
getClass().getName() + port, "test");
org.apache.bookkeeper.conf.ServerConfiguration conf = newServerConfiguration(
port, zkUtil.getZooKeeperConnectString(), tmpDir, new File[] { tmpDir });
conf.setAllowLoopback(true);
bks.add(startBookie(conf));
bkConfs.add(conf);
}
Expand All @@ -510,6 +511,7 @@ protected org.apache.bookkeeper.conf.ServerConfiguration newServerConfiguration(
int port, String zkServers, File journalDir, File[] ledgerDirs) {
org.apache.bookkeeper.conf.ServerConfiguration conf =
new org.apache.bookkeeper.conf.ServerConfiguration();
conf.setAllowLoopback(true);
conf.setBookiePort(port);
conf.setZkServers(zkServers);
conf.setJournalDirName(journalDir.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ private static ServerConfiguration newServerConfiguration() {

protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir, File[] ledgerDirs) {
ServerConfiguration conf = new ServerConfiguration(baseConf);
conf.setAllowLoopback(true);
conf.setBookiePort(port);
conf.setZkServers(zkServers);
conf.setJournalDirName(journalDir.getPath());
Expand Down

0 comments on commit 80c6e55

Please sign in to comment.