Repository: bookkeeper
Updated Branches:
refs/heads/master 596966007 -> 189d7e80b
ISSUE #203: TestFencing is failing due to LAC piggyback changes
Descriptions of the changes in this PR:
Problem:
TestFencing is failing after merging LAC piggyback changes. Because LAC
piggyback will advance last add confirmed when reading entries.
Solution:
Move the addEntry verification to after reading entries.
At the same time, add more logging to #testManyOpen
---
Be sure to do all of the following to help us incorporate your contribution
quickly and easily:
- [x] Make sure the PR title is formatted like:
`<Issue #>: Description of pull request`
`e.g. Issue 123: Description ...`
- [x] Make sure tests pass via `mvn clean apache-rat:check install
findbugs:check`.
- [x] Replace `<Issue #>` in the title with the actual Issue number, if there
is one.
---
Author: Sijie Guo <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>
This closes #204 from sijie/fix_test_fencing, closes #203
Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/189d7e80
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/189d7e80
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/189d7e80
Branch: refs/heads/master
Commit: 189d7e80b4b0096d580bafa66323fa5f099df65d
Parents: 5969660
Author: Sijie Guo <[email protected]>
Authored: Thu Jun 22 16:21:00 2017 +0200
Committer: Enrico Olivelli <[email protected]>
Committed: Thu Jun 22 16:21:00 2017 +0200
----------------------------------------------------------------------
.../apache/bookkeeper/client/TestFencing.java | 25 +++++++++++---------
1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/189d7e80/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
----------------------------------------------------------------------
diff --git
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
index ba51175..13f2f1d 100644
---
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
+++
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestFencing.java
@@ -27,7 +27,7 @@ import java.util.concurrent.CyclicBarrier;
import org.apache.bookkeeper.client.BookKeeper.DigestType;
import org.apache.bookkeeper.conf.ClientConfiguration;
import org.apache.bookkeeper.net.BookieSocketAddress;
-import org.apache.bookkeeper.test.BaseTestCase;
+import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,14 +38,14 @@ import static org.junit.Assert.*;
* This unit test tests ledger fencing;
*
*/
-public class TestFencing extends BaseTestCase {
+public class TestFencing extends BookKeeperClusterTestCase {
private final static Logger LOG =
LoggerFactory.getLogger(TestFencing.class);
- DigestType digestType;
+ private final DigestType digestType;
- public TestFencing(DigestType digestType) {
+ public TestFencing() {
super(10);
- this.digestType = digestType;
+ this.digestType = DigestType.CRC32;
}
/**
@@ -94,12 +94,14 @@ public class TestFencing extends BaseTestCase {
private long lastConfirmedEntry = 0;
+ private final int tid;
private final DigestType digestType;
private final CyclicBarrier barrier;
- LedgerOpenThread (DigestType digestType, long ledgerId, CyclicBarrier
barrier)
+ LedgerOpenThread (int tid, DigestType digestType, long ledgerId,
CyclicBarrier barrier)
throws Exception {
super("TestFencing-LedgerOpenThread-" + threadCount++);
+ this.tid = tid;
this.ledgerId = ledgerId;
this.digestType = digestType;
this.barrier = barrier;
@@ -107,6 +109,7 @@ public class TestFencing extends BaseTestCase {
@Override
public void run() {
+ LOG.info("Thread {} started.", tid);
LedgerHandle lh = null;
BookKeeper bk = null;
try {
@@ -138,7 +141,7 @@ public class TestFencing extends BaseTestCase {
// just exit, test should spot bad last add confirmed
LOG.error("Exception occurred ", e);
}
- LOG.info("Thread exiting, lastConfirmedEntry = " +
lastConfirmedEntry);
+ LOG.info("Thread {} exiting, lastConfirmedEntry = {}", tid,
lastConfirmedEntry);
}
long getLastConfirmedEntry() {
@@ -180,7 +183,7 @@ public class TestFencing extends BaseTestCase {
CyclicBarrier barrier = new CyclicBarrier(numRecovery+1);
LedgerOpenThread threads[] = new LedgerOpenThread[numRecovery];
for (int i = 0; i < numRecovery; i++) {
- threads[i] = new LedgerOpenThread(digestType, writelh.getId(),
barrier);
+ threads[i] = new LedgerOpenThread(i, digestType, writelh.getId(),
barrier);
threads[i].start();
}
latch.await();
@@ -219,12 +222,12 @@ public class TestFencing extends BaseTestCase {
*/
LedgerHandle readlh = bkc.openLedgerNoRecovery(writelh.getId(),
digestType,
"".getBytes());
- // should not have triggered recovery and fencing
-
- writelh.addEntry(tmp.getBytes());
long numReadable = readlh.getLastAddConfirmed();
LOG.error("numRead " + numReadable);
readlh.readEntries(1, numReadable);
+
+ // should not have triggered recovery and fencing
+ writelh.addEntry(tmp.getBytes());
try {
readlh.readEntries(numReadable+1, numReadable+1);
fail("Shouldn't have been able to read this far");