dlg99 commented on a change in pull request #2796:
URL: https://github.com/apache/bookkeeper/pull/2796#discussion_r722496673
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
##########
@@ -1614,4 +1614,34 @@ private void testInvalidServiceMetadataURICase(String
uri) throws Exception {
// ok
}
}
+
+ @Test
+ public void testBookieIdSetting() throws Exception {
+ String customBookieId = "customId";
+ // If BookieID is set, it takes precedence over network info.
+ final ServerConfiguration conf =
newServerConfiguration().setBookieId(customBookieId);
+ BookieServer server = new MockBookieServer(conf);
+ server.start();
+ assertEquals(customBookieId, server.getBookieId().toString());
+ server.shutdown();
+ }
+
+ @Test(expected = BookieException.InvalidCookieException.class)
+ public void testBookieIdChange() throws Exception {
+ // By default, network info is set as Bookie Id and it is stored in
the Cookie.
+ final ServerConfiguration conf = newServerConfiguration();
+ BookieServer server = new MockBookieServer(conf);
+ server.start();
+ assertNotNull(server.getBookieId().toString());
+ server.shutdown();
+
+ // If BookieID is set, it takes precedence over network info. Because
of that, the new Bookie start
+ // should fail with an InvalidCookieException, as now the custom
BookieID takes precedence.
+ String customBookieId = "customId";
+ conf.setBookieId(customBookieId);
+ server = new MockBookieServer(conf);
+ server.start();
+ assertEquals(customBookieId, server.getBookieId().toString());
+ server.shutdown();
Review comment:
The test expected exception, comment says to expect exception after the
start.
Do you need assert and shutdown after the code that's supposed to throw?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]