anujmodi2021 commented on code in PR #7353:
URL: https://github.com/apache/hadoop/pull/7353#discussion_r1944464841
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -666,6 +734,127 @@ public void
testNegativeScenariosForCreateOverwriteDisabled()
validateCreateFileException(AbfsRestOperationException.class, abfsStore);
}
+ /**
+ * Tests that the exception thrown during the creation of a marker is
swallowed.
+ * This test verifies that when an exception occurs during the creation of a
marker,
+ * it does not propagate and is handled internally and file creation still
succeeds.
+ *
+ * @throws Throwable if an error occurs during the test execution
+ */
+ @Test
+ public void testCreateMarkerFailExceptionIsSwallowed()
+ throws Throwable {
+
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ Boolean.toString(true));
+
+ final AzureBlobFileSystem fs =
+ (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
+ config);
+
+ // Get mock AbfsClient with current config
+ AbfsClient mockClient = Mockito.spy(fs.getAbfsClient());
+ AzureBlobFileSystemStore spiedStore = Mockito.spy(fs.getAbfsStore());
+ spiedStore.setClient(mockClient);
+
+ Assume.assumeTrue(mockClient instanceof AbfsBlobClient);
Review Comment:
`assumeBlobEndpoint()`. Also move it up so that it gets skipped in startng
itself.
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -781,6 +980,52 @@ public void testCreateSameFile() throws Exception {
.isTrue();
}
+ /**
+ * Test the creation of a file without conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to true.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
Review Comment:
Use trycatch to auto close
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -781,6 +980,52 @@ public void testCreateSameFile() throws Exception {
.isTrue();
}
+ /**
+ * Test the creation of a file without conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to true.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
+ (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
+ config);
+ fs.mkdirs(new Path("a/b/c"));
+ intercept(IOException.class, () -> fs.create(new Path("a/b/c"), true));
+ }
+
+ /**
+ * Test the creation of a file with overwrite set to false without
conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to false.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationOverwriteFalseWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
+ (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
+ config);
+ fs.mkdirs(new Path("a/b/c"));
+ intercept(IOException.class, () -> fs.create(new Path("a/b/c"), false));
Review Comment:
Message for intercept failure
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -781,6 +980,52 @@ public void testCreateSameFile() throws Exception {
.isTrue();
}
+ /**
+ * Test the creation of a file without conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to true.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
+ (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
+ config);
+ fs.mkdirs(new Path("a/b/c"));
+ intercept(IOException.class, () -> fs.create(new Path("a/b/c"), true));
Review Comment:
intercept message
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -781,6 +980,52 @@ public void testCreateSameFile() throws Exception {
.isTrue();
}
+ /**
+ * Test the creation of a file without conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to true.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
+ (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(),
+ config);
+ fs.mkdirs(new Path("a/b/c"));
+ intercept(IOException.class, () -> fs.create(new Path("a/b/c"), true));
+ }
+
+ /**
+ * Test the creation of a file with overwrite set to false without
conditional overwrite.
+ * This test sets the configuration
`fs.azure.enable.conditional.create.overwrite` to false,
+ * creates a directory, and then attempts to create a file at the same path
with overwrite set to false.
+ * It expects an IOException to be thrown.
+ *
+ * @throws Exception if any exception occurs during the test execution
+ */
+ @Test
+ public void testCreationOverwriteFalseWithoutConditionalOverwrite()
+ throws Exception {
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ String.valueOf(false));
+
+ final AzureBlobFileSystem fs =
Review Comment:
Use try catch
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java:
##########
@@ -666,6 +734,127 @@ public void
testNegativeScenariosForCreateOverwriteDisabled()
validateCreateFileException(AbfsRestOperationException.class, abfsStore);
}
+ /**
+ * Tests that the exception thrown during the creation of a marker is
swallowed.
+ * This test verifies that when an exception occurs during the creation of a
marker,
+ * it does not propagate and is handled internally and file creation still
succeeds.
+ *
+ * @throws Throwable if an error occurs during the test execution
+ */
+ @Test
+ public void testCreateMarkerFailExceptionIsSwallowed()
+ throws Throwable {
+
+ final AzureBlobFileSystem currentFs = getFileSystem();
+ Configuration config = new Configuration(this.getRawConfiguration());
+ config.set("fs.azure.enable.conditional.create.overwrite",
+ Boolean.toString(true));
+
+ final AzureBlobFileSystem fs =
Review Comment:
use try catch so that it auto closes
--
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]