sijie commented on a change in pull request #1389: Add smoke tests for 
LedgerHandleAdv and TailingReads
URL: https://github.com/apache/bookkeeper/pull/1389#discussion_r186032112
 
 

 ##########
 File path: 
tests/integration/smoke/src/test/java/org/apache/bookkeeper/tests/integration/TestSmoke.java
 ##########
 @@ -48,42 +55,143 @@
     private String currentVersion = System.getProperty("currentVersion");
 
     @Before
-    public void before() throws Exception {
+    public void setup() throws Exception {
         // First test to run, formats metadata and bookies
         if (BookKeeperClusterUtils.metadataFormatIfNeeded(docker, 
currentVersion)) {
             BookKeeperClusterUtils.formatAllBookies(docker, currentVersion);
         }
+        
Assert.assertTrue(BookKeeperClusterUtils.startAllBookiesWithVersion(docker, 
currentVersion));
     }
 
-    @Test
-    public void testBootWriteReadShutdown() throws Exception {
-        
Assert.assertTrue(BookKeeperClusterUtils.startAllBookiesWithVersion(docker, 
currentVersion));
+    @After
+    public void teardown() throws Exception {
+        Assert.assertTrue(BookKeeperClusterUtils.stopAllBookies(docker));
+    }
 
+    @Test
+    public void testReadWrite() throws Exception {
         String zookeeper = 
BookKeeperClusterUtils.zookeeperConnectString(docker);
-        BookKeeper bk = new BookKeeper(zookeeper);
-        long ledgerId;
-        try (LedgerHandle writelh = 
bk.createLedger(BookKeeper.DigestType.CRC32, PASSWD)) {
-            ledgerId = writelh.getId();
-            for (int i = 0; i < 100; i++) {
-                writelh.addEntry(("entry-" + i).getBytes());
+        try (BookKeeper bk = new BookKeeper(zookeeper)) {
+            long ledgerId;
+            try (LedgerHandle writelh = 
bk.createLedger(BookKeeper.DigestType.CRC32C, PASSWD)) {
+                ledgerId = writelh.getId();
+                for (int i = 0; i < 100; i++) {
+                    writelh.addEntry(("entry-" + i).getBytes());
+                }
+            }
+
+            try (LedgerHandle readlh = bk.openLedger(ledgerId, 
BookKeeper.DigestType.CRC32C, PASSWD)) {
+                long lac = readlh.getLastAddConfirmed();
+                int i = 0;
+                Enumeration<LedgerEntry> entries = readlh.readEntries(0, lac);
+                while (entries.hasMoreElements()) {
+                    LedgerEntry e = entries.nextElement();
+                    String readBack = new String(e.getEntry());
+                    assertEquals(readBack, "entry-" + i++);
+                }
+                assertEquals(i, 100);
             }
         }
+    }
 
-        try (LedgerHandle readlh = bk.openLedger(ledgerId, 
BookKeeper.DigestType.CRC32, PASSWD)) {
-            long lac = readlh.getLastAddConfirmed();
-            int i = 0;
-            Enumeration<LedgerEntry> entries = readlh.readEntries(0, lac);
-            while (entries.hasMoreElements()) {
-                LedgerEntry e = entries.nextElement();
-                String readBack = new String(e.getEntry());
-                Assert.assertEquals(readBack, "entry-" + i++);
+    @Test
+    public void testReadWriteAdv() throws Exception {
+        String zookeeper = 
BookKeeperClusterUtils.zookeeperConnectString(docker);
+        try (BookKeeper bk = new BookKeeper(zookeeper)) {
+            long ledgerId;
+            try (LedgerHandle writelh = bk.createLedgerAdv(3, 3, 2, 
BookKeeper.DigestType.CRC32C, PASSWD)) {
+                ledgerId = writelh.getId();
+                for (int i = 0; i < 100; i++) {
+                    writelh.addEntry(i, ("entry-" + i).getBytes());
+                }
+            }
+
+            try (LedgerHandle readlh = bk.openLedger(ledgerId, 
BookKeeper.DigestType.CRC32C, PASSWD)) {
+                long lac = readlh.getLastAddConfirmed();
+                int i = 0;
+                Enumeration<LedgerEntry> entries = readlh.readEntries(0, lac);
+                while (entries.hasMoreElements()) {
+                    LedgerEntry e = entries.nextElement();
+                    String readBack = new String(e.getEntry());
+                    assertEquals(readBack, "entry-" + i++);
+                }
+                assertEquals(i, 100);
             }
-            Assert.assertEquals(i, 100);
         }
+    }
 
-        bk.close();
+    @Test
+    public void testTailingReads() throws Exception {
+        String zookeeper = 
BookKeeperClusterUtils.zookeeperConnectString(docker);
+        @Cleanup BookKeeper bk = new BookKeeper(zookeeper);
+        @Cleanup LedgerHandle writeLh = bk.createLedger(DigestType.CRC32C, 
PASSWD);
+        @Cleanup("shutdown") ExecutorService writeExecutor = 
Executors.newSingleThreadExecutor(
 
 Review comment:
   it is much clear to have two seperated thread pools with different names for 
debugging purpose.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to