Skip to content

Commit 3217291

Browse files
fix tests
1 parent f77af93 commit 3217291

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsBlobClient.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,19 @@ public AbfsRestOperation conditionalCreateOverwriteFile(String relativePath,
587587
boolean isAppendBlob,
588588
ContextEncryptionAdapter contextEncryptionAdapter,
589589
TracingContext tracingContext) throws IOException {
590-
// Check for non-empty directory at the path. The only pending validation is the check for an explicitly empty directory,
591-
// which is performed later to optimize TPS by delaying the lookup only if create with overwrite=false fails.
592-
if (isNonEmptyDirectory(relativePath, tracingContext)) {
593-
throw new AbfsRestOperationException(HTTP_CONFLICT,
594-
AzureServiceErrorCode.PATH_CONFLICT.getErrorCode(),
595-
PATH_EXISTS,
596-
null);
590+
if (!getIsNamespaceEnabled()) {
591+
// Check for non-empty directory at the path. The only pending validation is the check for an explicitly empty directory,
592+
// which is performed later to optimize TPS by delaying the lookup only if create with overwrite=false fails.
593+
if (isNonEmptyDirectory(relativePath, tracingContext)) {
594+
throw new AbfsRestOperationException(HTTP_CONFLICT,
595+
AzureServiceErrorCode.PATH_CONFLICT.getErrorCode(),
596+
PATH_EXISTS,
597+
null);
598+
}
599+
// Create markers for the parent hierarchy.
600+
tryMarkerCreation(relativePath, isAppendBlob, null,
601+
contextEncryptionAdapter, tracingContext);
597602
}
598-
// Create markers for the parent hierarchy.
599-
tryMarkerCreation(relativePath, isAppendBlob, null, contextEncryptionAdapter, tracingContext);
600603
AbfsRestOperation op;
601604
try {
602605
// Trigger a creation with overwrite=false first so that eTag fetch can be

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ public class ITestAzureBlobFileSystemCreate extends
104104
private static final Path TEST_FILE_PATH = new Path("testfile");
105105
private static final String TEST_FOLDER_PATH = "testFolder";
106106
private static final String TEST_CHILD_FILE = "childFile";
107-
private static final String PATH_CONFLICT
108-
= "The specified path, or an element of the path, exists and its resource type is invalid for this operation.";
109-
private static final String BLOB_EXIST = "already exists";
110107

111108
public ITestAzureBlobFileSystemCreate() throws Exception {
112109
super();
@@ -1008,7 +1005,6 @@ public void testCreationWithoutConditionalOverwrite()
10081005
config)) {
10091006
fs.mkdirs(new Path("a/b/c"));
10101007
intercept(IOException.class,
1011-
PATH_CONFLICT,
10121008
() -> fs.create(new Path("a/b/c"), true));
10131009
}
10141010
}
@@ -1026,11 +1022,13 @@ public void testCreationWithoutConditionalOverwrite()
10261022
public void testCreationOverwriteFalseWithoutConditionalOverwrite() throws Exception {
10271023
try (AzureBlobFileSystem currentFs = getFileSystem()) {
10281024
Configuration config = new Configuration(this.getRawConfiguration());
1029-
config.set("fs.azure.enable.conditional.create.overwrite", String.valueOf(false));
1025+
config.set("fs.azure.enable.conditional.create.overwrite",
1026+
String.valueOf(false));
10301027

1031-
try (AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance(currentFs.getUri(), config)) {
1028+
try (AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance(
1029+
currentFs.getUri(), config)) {
10321030
fs.mkdirs(new Path("a/b/c"));
1033-
intercept(IOException.class, BLOB_EXIST,
1031+
intercept(IOException.class,
10341032
() -> fs.create(new Path("a/b/c"), false));
10351033
}
10361034
}
@@ -1047,7 +1045,7 @@ public void testCreateSameFileWithOverwriteFalse() throws Exception {
10471045
Assertions.assertThat(fs.exists(new Path("a/b/c")))
10481046
.describedAs("Path does not exist")
10491047
.isTrue();
1050-
intercept(IOException.class, BLOB_EXIST,
1048+
intercept(IOException.class,
10511049
() -> fs.create(new Path("a/b/c"), false));
10521050
}
10531051
}
@@ -1064,7 +1062,6 @@ public void testCreateSubPath() throws Exception {
10641062
.describedAs("Path does not exist")
10651063
.isTrue();
10661064
intercept(IOException.class,
1067-
PATH_CONFLICT,
10681065
() -> fs.create(new Path("a/b")));
10691066
}
10701067
}
@@ -1222,9 +1219,9 @@ public void testParentExplicitPathImplicit() throws Exception {
12221219
Path sourcePath = new Path(sourcePathName);
12231220
createAzCopyFolder(sourcePath);
12241221

1225-
intercept(IOException.class, PATH_CONFLICT, () ->
1222+
intercept(IOException.class, () ->
12261223
fs.create(sourcePath, true));
1227-
intercept(IOException.class, PATH_CONFLICT, () ->
1224+
intercept(IOException.class, () ->
12281225
fs.create(sourcePath, false));
12291226

12301227
Assertions.assertThat(
@@ -1374,7 +1371,7 @@ public void testCreateFileParentFile() throws Exception {
13741371

13751372
String childName = "/testParentFile/testChildFile";
13761373
Path child = new Path(childName);
1377-
IOException e = intercept(IOException.class, PATH_CONFLICT, () ->
1374+
IOException e = intercept(IOException.class, () ->
13781375
fs.create(child, false));
13791376

13801377
// asserting that parent stays explicit
@@ -1396,8 +1393,7 @@ public void testCreateMkdirs() throws Exception {
13961393
try (AzureBlobFileSystem fs = getFileSystem()) {
13971394
fs.create(new Path("a/b/c"));
13981395
intercept(IOException.class,
1399-
"The specified path, or an element of the path, exists and its resource type is invalid for this operation.",
1400-
() -> fs.mkdirs(new Path("a/b/c/d")));
1396+
() -> fs.mkdirs(new Path("a/b/c/d")));
14011397
}
14021398
}
14031399

@@ -1554,7 +1550,7 @@ public void testFileCreateMkdirsRoot() throws Exception {
15541550
fs.setWorkingDirectory(new Path("/"));
15551551
final Path p1 = new Path("dir1");
15561552
fs.create(p1);
1557-
intercept(IOException.class, PATH_CONFLICT,
1553+
intercept(IOException.class,
15581554
() -> fs.mkdirs(new Path("dir1/dir2")));
15591555
}
15601556
}
@@ -1568,7 +1564,7 @@ public void testFileCreateMkdirsNonRoot() throws Exception {
15681564
try (AzureBlobFileSystem fs = getFileSystem()) {
15691565
final Path p1 = new Path("dir1");
15701566
fs.create(p1);
1571-
intercept(IOException.class, PATH_CONFLICT, () -> fs.mkdirs(new Path("dir1/dir2")));
1567+
intercept(IOException.class, () -> fs.mkdirs(new Path("dir1/dir2")));
15721568
}
15731569
}
15741570

@@ -1753,7 +1749,8 @@ public void testCreateDirectoryAndFileRecreation() throws Exception {
17531749
Assertions.assertThat(fs.exists(new Path("a/b/c/d")))
17541750
.describedAs("File a/b/c/d does not exist")
17551751
.isTrue();
1756-
intercept(IOException.class, PATH_CONFLICT, () -> fs.mkdirs(new Path("a/b/c/d")));
1752+
intercept(IOException.class,
1753+
() -> fs.mkdirs(new Path("a/b/c/d")));
17571754
}
17581755
}
17591756

0 commit comments

Comments
 (0)