errose28 commented on code in PR #7083:
URL: https://github.com/apache/ozone/pull/7083#discussion_r1735177461
##########
hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/checksum/TestContainerChecksumTreeManager.java:
##########
@@ -199,36 +207,101 @@ public void testTreePreservedOnDeletedBlocksWrite()
throws Exception {
public void testReadContainerMerkleTreeMetric() throws Exception {
assertEquals(metrics.getWriteContainerMerkleTreeLatencyNS().lastStat().total(),
0);
assertEquals(metrics.getReadContainerMerkleTreeLatencyNS().lastStat().total(),
0);
- ContainerMerkleTree tree = buildTestTree();
+ ContainerMerkleTree tree = buildTestTree(config);
checksumManager.writeContainerDataTree(container, tree);
assertEquals(metrics.getReadContainerMerkleTreeLatencyNS().lastStat().total(),
0);
checksumManager.writeContainerDataTree(container, tree);
assertTrue(metrics.getWriteContainerMerkleTreeLatencyNS().lastStat().total() >
0);
assertTrue(metrics.getReadContainerMerkleTreeLatencyNS().lastStat().total() >
0);
}
+ /**
+ * Updates to the container checksum file are written to a tmp file and then
swapped in to place. Test that when
+ * the write to the tmp file fails, the main file that is read from is left
intact.
+ */
+ @Test
+ public void testTmpFileWriteFailure() throws Exception {
+ File tmpFile =
ContainerChecksumTreeManager.getTmpContainerChecksumFile(container);
+ File finalFile =
ContainerChecksumTreeManager.getContainerChecksumFile(container);
+
+ assertFalse(tmpFile.exists());
+ assertFalse(finalFile.exists());
+ ContainerMerkleTree tree = buildTestTree(config);
+ checksumManager.writeContainerDataTree(container, tree);
+ assertFalse(tmpFile.exists());
+ assertTrue(finalFile.exists());
+
+ // Make the write to the tmp file fail by removing permissions on its
parent.
+ assertTrue(finalFile.getParentFile().setWritable(false));
Review Comment:
Both have the same effect since they have the same parent, but using tmpFile
would be clearer so I'll update it.
--
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]