ChenSammi commented on code in PR #8360:
URL: https://github.com/apache/ozone/pull/8360#discussion_r2075041289
##########
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:
Oh, I see. Could you use the same way as
testSpaceReservedAndReleasedWhenOnCompletedFails to mock some failure instead?
This current logic is confusing.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]