zymap commented on code in PR #4592:
URL: https://github.com/apache/bookkeeper/pull/4592#discussion_r2324571802
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/TestHttpService.java:
##########
@@ -765,15 +770,59 @@ public void testDecommissionService() throws Exception {
assertEquals(HttpServer.StatusCode.NOT_FOUND.getValue(),
response2.getStatusCode());
//3, PUT, with body, should success.
- String putBody3 = "{\"bookie_src\": \"" + getBookie(1).toString() +
"\"}";
+ BookieId bookieId = getBookie(1);
+ String putBody3 = "{\"bookie_src\": \"" + bookieId.toString() + "\"}";
HttpServiceRequest request3 = new HttpServiceRequest(putBody3,
HttpServer.Method.PUT, null);
// after bookie kill, request should success
killBookie(1);
HttpServiceResponse response3 = decommissionService.handle(request3);
assertEquals(HttpServer.StatusCode.OK.getValue(),
response3.getStatusCode());
+ // wait decommission finish
+ Thread.sleep(60 * 1000);
+ runFunctionWithRegistrationManager(baseConf, registrationManager -> {
+ Versioned<Cookie> cookieFromZk = null;
+ try {
+ cookieFromZk =
Cookie.readFromRegistrationManager(registrationManager,
+ bookieId);
+ } catch (BookieException e) {
+ } finally {
+ assertTrue(cookieFromZk != null);
+ }
+ return true;
+ });
stopAuditorElector();
}
+ @Test
+ public void testDecommissionServiceWithDeleteCookie() throws Exception {
+ baseConf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
+ startReplicationService();
+
+ HttpEndpointService decommissionService = bkHttpServiceProvider
+ .provideHttpEndpointService(HttpServer.ApiType.DECOMMISSION);
+ BookieId bookieId = getBookie(1);
+ String putBody1 = "{\"bookie_src\": \"" + bookieId.toString() + "\",
\"delete_cookie\": \"true\"}";
+ HttpServiceRequest request1 = new HttpServiceRequest(putBody1,
HttpServer.Method.PUT, null);
+ // after bookie kill, request should success
+ killBookie(1);
+ HttpServiceResponse response1 = decommissionService.handle(request1);
+ assertEquals(HttpServer.StatusCode.OK.getValue(),
response1.getStatusCode());
+ // wait decommission finish
+ Thread.sleep(60 * 1000);
Review Comment:
Same above.
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/TestHttpService.java:
##########
@@ -765,15 +770,59 @@ public void testDecommissionService() throws Exception {
assertEquals(HttpServer.StatusCode.NOT_FOUND.getValue(),
response2.getStatusCode());
//3, PUT, with body, should success.
- String putBody3 = "{\"bookie_src\": \"" + getBookie(1).toString() +
"\"}";
+ BookieId bookieId = getBookie(1);
+ String putBody3 = "{\"bookie_src\": \"" + bookieId.toString() + "\"}";
HttpServiceRequest request3 = new HttpServiceRequest(putBody3,
HttpServer.Method.PUT, null);
// after bookie kill, request should success
killBookie(1);
HttpServiceResponse response3 = decommissionService.handle(request3);
assertEquals(HttpServer.StatusCode.OK.getValue(),
response3.getStatusCode());
+ // wait decommission finish
+ Thread.sleep(60 * 1000);
+ runFunctionWithRegistrationManager(baseConf, registrationManager -> {
+ Versioned<Cookie> cookieFromZk = null;
+ try {
+ cookieFromZk =
Cookie.readFromRegistrationManager(registrationManager,
+ bookieId);
+ } catch (BookieException e) {
+ } finally {
+ assertTrue(cookieFromZk != null);
+ }
+ return true;
+ });
Review Comment:
You can use Awaitility to verify the condition periodically instead of
sleeping.
```
Awaitility.await().untilAsserted(() -> {
assertTrue("Bookie should be running and converted to readonly
mode",
bookie.isRunning() && bookie.isReadOnly());
});
```
--
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]