eolivelli commented on a change in pull request #712: Issue 544: Bootup cookie 
validation considers an empty journal to signify a new bookie
URL: https://github.com/apache/bookkeeper/pull/712#discussion_r150197544
 
 

 ##########
 File path: 
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CookieTest.java
 ##########
 @@ -543,10 +602,38 @@ public void testRestartWithHostNameAsBookieID() throws 
Exception {
         b.shutdown();
 
         conf.setUseHostNameAsBookieID(true);
-        b = new Bookie(conf);
+        try {
+            new Bookie(conf);
+            fail("Should not start a bookie with hostname if the bookie has 
been started with an ip");
+        } catch (InvalidCookieException e) {
+            // expected
+        }
+    }
+
+    /**
+     * Test restart bookie with new advertisedAddress, which had cookie 
generated with ip.
+     */
+    @Test
+    public void testRestartWithAdvertisedAddressAsBookieID() throws Exception {
+        String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
+                newDirectory() };
+        String journalDir = newDirectory();
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
+                .setZkServers(zkUtil.getZooKeeperConnectString())
+                .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
+                .setBookiePort(bookiePort);
+        conf.setUseHostNameAsBookieID(false);
+        Bookie b = new Bookie(conf); // should work fine
         b.start();
-        assertTrue("Fails to recognize bookie which was started with IPAddr as 
ID", !conf.getUseHostNameAsBookieID());
         b.shutdown();
+
+        conf.setAdvertisedAddress("test.bookkeeper.com");
 
 Review comment:
   we should not use public DNS names, it would be possible that running the 
test suite the process does invalid/suspiciuos network requests-
   please change to something like
   test.bookkeeper.com.localhost

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to