swamirishi commented on code in PR #5174:
URL: https://github.com/apache/ozone/pull/5174#discussion_r1290945147
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFsSnapshot.java:
##########
@@ -138,6 +139,39 @@ public void testCreateSnapshotDuplicateName() throws
Exception {
Assertions.assertEquals(1, res);
}
+ @Test
+ public void testCreateSnapshotWithSubDirInput() throws Exception {
+ // Test that:
+ // $ ozone fs -createSnapshot ofs://om/vol1/buck2/dir3/ snap1
+ //
+ // should print:
+ // Created snapshot ofs://om/vol1/buck2/.snapshot/snap1
+ //
+ // rather than:
+ // Created snapshot ofs://om/vol1/buck2/dir3/.snapshot/snap1
+
+ String snapshotName = "snap-" + RandomStringUtils.randomNumeric(5);
+
+ String dirPath = BUCKET_PATH + "/dir1/";
+
+ int res = ToolRunner.run(shell, new String[] {
+ "-mkdir", "-p", dirPath});
+ Assertions.assertEquals(0, res);
+
+ try (GenericTestUtils.SystemOutCapturer capture =
+ new GenericTestUtils.SystemOutCapturer()) {
+ res = ToolRunner.run(shell, new String[] {
+ "-createSnapshot", dirPath, snapshotName});
+ // Asserts that create request succeeded
+ Assertions.assertEquals(0, res);
+
+ String expectedSnapshotPath = Paths.get(
+ BUCKET_PATH, OM_SNAPSHOT_INDICATOR, snapshotName).toString();
+ String out = capture.getOutput().trim();
+ Assertions.assertTrue(out.endsWith(expectedSnapshotPath));
+ }
+ }
+
Review Comment:
In this test we are relying on log output. Would be better to test the
function as well.
--
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]