Skip to content

Commit

Permalink
Fix the failure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zymap committed Dec 12, 2023
1 parent 05ae65b commit d31f15f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public HttpServiceResponse handle(HttpServiceRequest request) throws Exception {
try {
if (HttpServer.Method.PUT == request.getMethod()) {
String requestBody = request.getBody();
if (StringUtils.isBlank(requestBody)) {
if (requestBody == null || StringUtils.isEmpty(requestBody.trim())) {
bookieServer.getBookie().getLedgerStorage().forceGC();
} else {
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1}");
resp = service.handle(request);
verify(mockLedgerStorage, times(1)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -91,7 +91,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":true}");
resp = service.handle(request);
verify(mockLedgerStorage, times(2)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(true), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -101,7 +101,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":\"true\"}");
resp = service.handle(request);
verify(mockLedgerStorage, times(3)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(2)).forceGC(eq(true), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -111,7 +111,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":false}");
resp = service.handle(request);
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(true));
verify(mockLedgerStorage, times(2)).forceGC(eq(false), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -121,7 +121,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMinor\":true}");
resp = service.handle(request);
verify(mockLedgerStorage, times(4)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(true));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand Down

0 comments on commit d31f15f

Please sign in to comment.