Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
manika137 committed Jan 22, 2025
1 parent 2b8b130 commit 00b426f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ public AbfsClientRenameResult renamePath(

if(op.getResult().getStorageErrorCode()
.equals(UNAUTHORIZED_BLOB_OVERWRITE.getErrorCode())){
throw new FileAlreadyExistsException("File already exists." );
throw new FileAlreadyExistsException("File already exists or request not authorized for blob overwrites.");
}

// ref: HADOOP-18242. Rename failure occurring due to a rare case of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileAlreadyExistsException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -213,6 +214,23 @@ public void testReadAndWrite() throws Exception {
}
}

@Test
public void checkExceptionForRenameOverwrites() throws Exception {
final AzureBlobFileSystem fs = getFileSystem();

Path src = new Path("a/b/f1.txt");
Path dest = new Path("a/b/f2.txt");
touch(src);
touch(dest);

try {
fs.rename(src, dest);
} catch (FileAlreadyExistsException e) {
Assertions.assertThat(e)
.isInstanceOf(FileAlreadyExistsException.class);
}
}

@Test
// Test rename file and rename folder
public void testRename() throws Exception {
Expand Down

0 comments on commit 00b426f

Please sign in to comment.