ChenSammi commented on code in PR #8360: URL: https://github.com/apache/ozone/pull/8360#discussion_r2075031774
########## hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/replication/TestSendContainerRequestHandler.java: ########## @@ -99,4 +115,86 @@ void testReceiveDataForExistingContainer() throws Exception { .build(); sendContainerRequestHandler.onNext(request); } + + @Test + public void testSpaceReservedAndReleasedWhenRequestCompleted() throws Exception { + long containerId = 1; + HddsVolume volume = (HddsVolume) volumeSet.getVolumesList().get(0); + long initialCommittedBytes = volume.getCommittedBytes(); + + // Create request + ContainerProtos.SendContainerRequest request = ContainerProtos.SendContainerRequest.newBuilder() + .setContainerID(containerId) + .setData(ByteString.EMPTY) + .setOffset(0) + .setCompression(CopyContainerCompression.NO_COMPRESSION.toProto()) + .build(); + + // Execute request + sendContainerRequestHandler.onNext(request); + + // Verify commit space is reserved + assertEquals(volume.getCommittedBytes(), initialCommittedBytes + 2 * containerMaxSize); + + // complete the request + sendContainerRequestHandler.onCompleted(); + + // Verify commit space is released + assertEquals(volume.getCommittedBytes(), initialCommittedBytes); + } + + @Test + public void testSpaceReservedAndReleasedWhenOnNextFails() throws Exception { + long containerId = 1; + HddsVolume volume = (HddsVolume) volumeSet.getVolumesList().get(0); + long initialCommittedBytes = volume.getCommittedBytes(); + + // Create request + ContainerProtos.SendContainerRequest request = createRequest(containerId, ByteString.copyFromUtf8("test"), 0); + + // Execute request + sendContainerRequestHandler.onNext(request); + + // Verify commit space is reserved + assertEquals(volume.getCommittedBytes(), initialCommittedBytes + 2 * containerMaxSize); + + // Send a failed response with wrong offset + request = createRequest(containerId, ByteString.copyFromUtf8("test"), 0); Review Comment: This request looks the same as previous request. How to tell it will have a failed response? -- 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: issues-unsubscr...@ozone.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org