priyeshkaratha commented on code in PR #11886:
URL: https://github.com/apache/ozone/pull/11886#discussion_r4475970697
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/ContainerTestUtils.java:
##########
@@ -505,4 +509,101 @@ public static ReplicateContainerCommand
getReplicateContainerCommand(
return ReplicateContainerCommand.toTarget(
containerID, target, HDDSVersion.SOFTWARE_VERSION);
}
+
+ public static ContainerProtos.ContainerCommandResponseProto
createContainerForTesting(XceiverClientSpi client,
+ long containerID) throws Exception {
+ // Create container
+ ContainerProtos.ContainerCommandRequestProto request =
+ ContainerTestHelper.getCreateContainerRequest(
+ containerID, client.getPipeline());
+ ContainerProtos.ContainerCommandResponseProto response =
+ client.sendCommand(request);
+ assertNotNull(response);
+ return response;
+ }
+
+ public static ContainerProtos.ContainerCommandRequestProto
+ writeChunkForContainer(XceiverClientSpi client,
+ long containerID, int dataLen) throws Exception {
+ // Write Chunk
+ BlockID blockID = ContainerTestHelper.getTestBlockID(containerID);
+ ContainerProtos.ContainerCommandRequestProto writeChunkRequest =
+ ContainerTestHelper.getWriteChunkRequest(client.getPipeline(),
+ blockID, dataLen);
+ ContainerProtos.ContainerCommandResponseProto response =
+ client.sendCommand(writeChunkRequest);
+ assertNotNull(response);
+ assertEquals(ContainerProtos.Result.SUCCESS, response.getResult());
+ return writeChunkRequest;
+ }
+
+ public static void runTestOzoneContainerViaDataNode(
+ long testContainerID, XceiverClientSpi client) throws Exception {
+ ContainerProtos.ContainerCommandRequestProto
+ request, writeChunkRequest, putBlockRequest,
+ updateRequest1, updateRequest2;
+ ContainerProtos.ContainerCommandResponseProto response,
+ updateResponse1, updateResponse2;
+ try {
+ client.connect();
+
+ Pipeline pipeline = client.getPipeline();
+ createContainerForTesting(client, testContainerID);
+ writeChunkRequest = writeChunkForContainer(client, testContainerID,
+ 1024);
+
+ // Read Chunk
+ request = ContainerTestHelper.getReadChunkRequest(
+ pipeline, writeChunkRequest.getWriteChunk());
+
+ response = client.sendCommand(request);
+ assertNotNull(response);
+ assertEquals(ContainerProtos.Result.SUCCESS, response.getResult());
+
+ // Put Block
+ putBlockRequest = ContainerTestHelper.getPutBlockRequest(
+ pipeline, writeChunkRequest.getWriteChunk());
+
+
+ response = client.sendCommand(putBlockRequest);
+ assertNotNull(response);
+ assertEquals(ContainerProtos.Result.SUCCESS, response.getResult());
+
+ // Get Block
+ request = ContainerTestHelper.
+ getBlockRequest(pipeline, putBlockRequest.getPutBlock());
+ response = client.sendCommand(request);
+ int chunksCount = putBlockRequest.getPutBlock().getBlockData().
+ getChunksCount();
+ ContainerTestHelper.verifyGetBlock(response, chunksCount);
+
+ // Delete Block and Delete Chunk are handled by BlockDeletingService
+ // ContainerCommandRequestProto DeleteBlock and DeleteChunk requests
+ // are deprecated
+
+ //Update an existing container
+ Map<String, String> containerUpdate = new HashMap<String, String>();
+ containerUpdate.put("container_updated_key", "container_updated_value");
+ updateRequest1 = ContainerTestHelper.getUpdateContainerRequest(
+ testContainerID, containerUpdate);
+ updateResponse1 = client.sendCommand(updateRequest1);
+ assertNotNull(updateResponse1);
+ assertEquals(ContainerProtos.Result.SUCCESS,
Review Comment:
it checks response.getResult() instead of updateResponse1.getResult(), so
the update result is never checked.
--
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]