This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 626ce68 Provide a minimal test case using v2wireprotocol option
626ce68 is described below
commit 626ce687e2342b8a75005cf018540fda76ee15d8
Author: Enrico Olivelli <[email protected]>
AuthorDate: Mon Jul 24 13:08:02 2017 +0200
Provide a minimal test case using v2wireprotocol option
Add testcases on addEntry/readEntries and basic fencing
Author: Enrico Olivelli <[email protected]>
Reviewers: Sijie Guo
This closes #273 from eolivelli/issue-272-testv2
---
.../apache/bookkeeper/client/BookKeeperTest.java | 46 ++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
index ab22ef7..a0d64a4 100644
---
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
+++
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
@@ -651,4 +651,50 @@ public class BookKeeperTest extends BaseTestCase {
}
}
+
+ @Test(timeout = 60000)
+ public void testReadWriteWithV2WireProtocol() throws Exception {
+ ClientConfiguration conf = new ClientConfiguration()
+ .setZkServers(zkUtil.getZooKeeperConnectString())
+ .setUseV2WireProtocol(true);
+ int numEntries = 100;
+ byte[] data = "foobar".getBytes();
+ try (BookKeeper bkc = new BookKeeper(conf)) {
+
+ // basic read/write
+ {
+ long ledgerId;
+ try (LedgerHandle lh = bkc.createLedger(digestType,
"testPasswd".getBytes())) {
+ ledgerId = lh.getId();
+ for (int i = 0; i < numEntries; i++) {
+ lh.addEntry(data);
+ }
+ }
+ try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType,
"testPasswd".getBytes())) {
+ assertEquals(numEntries - 1, lh.readLastConfirmed());
+ for (Enumeration<LedgerEntry> readEntries =
lh.readEntries(0, numEntries - 1);
+ readEntries.hasMoreElements();) {
+ LedgerEntry entry = readEntries.nextElement();
+ assertArrayEquals(data, entry.getEntry());
+ }
+ }
+ }
+
+ // basic fencing
+ {
+ long ledgerId;
+ try (LedgerHandle lh2 = bkc.createLedger(digestType,
"testPasswd".getBytes())) {
+ ledgerId = lh2.getId();
+ lh2.addEntry(data);
+ try (LedgerHandle lh2_fence = bkc.openLedger(ledgerId,
digestType, "testPasswd".getBytes())) {
+ }
+ try {
+ lh2.addEntry(data);
+ fail("ledger should be fenced");
+ } catch (BKException.BKLedgerFencedException ex){
+ }
+ }
+ }
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].