bookkeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject bookkeeper git commit: BOOKKEEPER-984: Fix BookieClientTest.testWriteGaps
Date Sat, 17 Dec 2016 01:39:44 GMT
Repository: bookkeeper
Updated Branches:
  refs/heads/master f710e5a44 -> 6d2737ca2


BOOKKEEPER-984: Fix BookieClientTest.testWriteGaps

in commit 9359d682a1598e30364eca6021d976f911e055b2, the third field (last add confirmed) in
the message. changed the test to include the lac in the test so the test logic can work as
expected.

Author: Sijie Guo <sijie@apache.org>

Reviewers: Enrico Olivelli <eolivelli@gmail.com>

Closes #91 from sijie/sijie/BOOKKEEPER-984


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/6d2737ca
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/6d2737ca
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/6d2737ca

Branch: refs/heads/master
Commit: 6d2737ca22533aed461ed71e94d2472a6664df3c
Parents: f710e5a
Author: Sijie Guo <sijie@apache.org>
Authored: Fri Dec 16 17:39:40 2016 -0800
Committer: Sijie Guo <sijie@apache.org>
Committed: Fri Dec 16 17:39:40 2016 -0800

----------------------------------------------------------------------
 .../apache/bookkeeper/test/BookieClientTest.java    | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/6d2737ca/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
index a170cee..7760827 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
@@ -98,7 +98,7 @@ public class BookieClientTest {
     }
 
     static class ResultStruct {
-        int rc;
+        int rc = -123456;
         ByteBuffer entry;
     }
 
@@ -108,11 +108,11 @@ public class BookieClientTest {
             ResultStruct rs = (ResultStruct) ctx;
             synchronized (rs) {
                 rs.rc = rc;
-                if (bb != null) {
-                    bb.readerIndex(16);
+                if (BKException.Code.OK == rc && bb != null) {
+                    bb.readerIndex(24);
                     rs.entry = bb.toByteBuffer();
-                    rs.notifyAll();
                 }
+                rs.notifyAll();
             }
         }
 
@@ -122,6 +122,10 @@ public class BookieClientTest {
         public void writeComplete(int rc, long ledgerId, long entryId, BookieSocketAddress
addr, Object ctx) {
             if (ctx != null) {
                 synchronized (ctx) {
+                    if (ctx instanceof ResultStruct) {
+                        ResultStruct rs = (ResultStruct) ctx;
+                        rs.rc = rc;
+                    }
                     ctx.notifyAll();
                 }
             }
@@ -142,6 +146,7 @@ public class BookieClientTest {
         bc.addEntry(addr, 1, passwd, 1, bb, wrcb, arc, BookieProtocol.FLAG_NONE);
         synchronized (arc) {
             arc.wait(1000);
+            assertEquals(0, arc.rc);
             bc.readEntry(addr, 1, 1, recb, arc);
             arc.wait(1000);
             assertEquals(0, arc.rc);
@@ -225,9 +230,10 @@ public class BookieClientTest {
 
     private ChannelBuffer createByteBuffer(int i, long lid, long eid) {
         ByteBuffer bb;
-        bb = ByteBuffer.allocate(4 + 16);
+        bb = ByteBuffer.allocate(4 + 24);
         bb.putLong(lid);
         bb.putLong(eid);
+        bb.putLong(eid-1);
         bb.putInt(i);
         bb.flip();
         return ChannelBuffers.wrappedBuffer(bb);


Mime
View raw message