swamirishi commented on code in PR #7402:
URL: https://github.com/apache/ozone/pull/7402#discussion_r1850789106
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/ozoneimpl/TestOzoneContainer.java:
##########
@@ -158,6 +161,134 @@ public void testOzoneContainerViaDataNode() throws
Exception {
}
}
+ @Test
+ public void testOzoneContainerWithMissingContainer() throws Exception {
+ MiniOzoneCluster cluster = null;
+ try {
+ long containerID =
+ ContainerTestHelper.getTestContainerID();
+ OzoneConfiguration conf = newOzoneConfiguration();
+
+ // Start ozone container Via Datanode create.
+ cluster = MiniOzoneCluster.newBuilder(conf)
+ .setNumDatanodes(1)
+ .build();
+ cluster.waitForClusterToBeReady();
+
+ runTestOzoneContainerWithMissingContainer(cluster, containerID);
+ } finally {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
+ }
+
+ private void runTestOzoneContainerWithMissingContainer(
+ MiniOzoneCluster cluster, long testContainerID) throws Exception {
+ ContainerProtos.ContainerCommandRequestProto
+ request, writeChunkRequest, putBlockRequest,
+ updateRequest1, updateRequest2;
+ ContainerProtos.ContainerCommandResponseProto response,
+ updateResponse1, updateResponse2;
+ XceiverClientGrpc client = null;
+ try {
+ // This client talks to ozone container via datanode.
+ client = createClientForTesting(cluster);
+ client.connect();
+ Pipeline pipeline = client.getPipeline();
+ createContainerForTesting(client, testContainerID);
+ writeChunkRequest = writeChunkForContainer(client, testContainerID,
+ 1024);
+
+ DatanodeDetails datanodeDetails =
cluster.getHddsDatanodes().get(0).getDatanodeDetails();
+ File containerPath =
+ new
File(cluster.getHddsDatanode(datanodeDetails).getDatanodeStateMachine()
+ .getContainer().getContainerSet().getContainer(testContainerID)
+ .getContainerData().getContainerPath());
+ cluster.getHddsDatanode(datanodeDetails).stop();
+ FileUtils.deleteDirectory(containerPath);
+
+ // Restart & Check if the container has been marked as missing, since
the container directory has been deleted.
+ cluster.restartHddsDatanode(datanodeDetails, false);
+ GenericTestUtils.waitFor(() -> {
+ try {
+ return
cluster.getHddsDatanode(datanodeDetails).getDatanodeStateMachine()
+ .getContainer().getContainerSet()
+ .getMissingContainerSet().contains(testContainerID);
+ } catch (IOException e) {
+ return false;
+ }
+ }, 1000, 30000);
+
+ // Read Chunk
Review Comment:
I have created a follow up jira for performing this validation:
https://issues.apache.org/jira/browse/HDDS-11761
--
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]