[ 
https://issues.apache.org/jira/browse/HADOOP-12815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15160032#comment-15160032
 ] 

Matthew Paduano commented on HADOOP-12815:
------------------------------------------

I tracked the issue to the following commit:

git show a10055cf

{code}
commit a10055cf6de058d10dec54705a6de746ecca111f
Author: Steve Loughran <[email protected]>
Date:   Mon Mar 25 13:12:27 2013 +0000

    HADOOP-9258 Add stricter tests to FileSystemContractTestBase (includes fixes
 for production code HADOOP-9261 & HADOOP-9265 and test enhancements HADOOP-9228
, HADOOP-9227 & HADOOP-9259)
{code}

This is sort of a big patch... not sure if we want to patch the entire thing to 
resolve the failing 
tests (or if patching the entire thing works or not!).  Maybe @SteveL can 
comment on why 
a10055cf wasn't pushed to branch-2.

I did track the failing tests to the following patch/diff and tested this alone.
This patch allows tests that are identified in this ticket to pass:

{code}
diff --git 
a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java
 b/had
index e5387f3..a186c14 100644
--- 
a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java
+++ 
b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/Jets3tFileSystemStore.java
@@ -138,9 +138,15 @@ public void deleteBlock(Block block) throws IOException {
 
   @Override
   public boolean inodeExists(Path path) throws IOException {
-    InputStream in = get(pathToKey(path), true);
+    String key = pathToKey(path);
+    InputStream in = get(key, true);
     if (in == null) {
-      return false;
+      if (isRoot(key)) {
+        storeINode(path, INode.DIRECTORY_INODE);
+        return true;
+      } else {
+        return false;
+      }
     }
     in.close();
     return true;
@@ -218,7 +224,13 @@ private void checkMetadata(S3Object object) throws 
S3FileSystemException,
 
   @Override
   public INode retrieveINode(Path path) throws IOException {
-    return INode.deserialize(get(pathToKey(path), true));
+    String key = pathToKey(path);
+    InputStream in = get(key, true);
+    if (in == null && isRoot(key)) {
+      storeINode(path, INode.DIRECTORY_INODE);
+      return INode.DIRECTORY_INODE;
+    }
+    return INode.deserialize(in);
   }
 
   @Override
@@ -377,6 +389,10 @@ private String blockToKey(Block block) {
     return blockToKey(block.getId());
   }
 
+  private boolean isRoot(String key) {
+    return key.isEmpty() || key.equals("/");
+  }
+
   @Override
   public void purge() throws IOException {
     try {
{code}

An alternative, lighter touch would be to submit the above as a patch to this 
ticket.

> TestS3ContractRootDir#testRmEmptyRootDirNonRecursive and 
> TestS3ContractRootDir#testRmRootRecursive fail on branch-2.
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-12815
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12815
>             Project: Hadoop Common
>          Issue Type: Bug
>            Reporter: Chris Nauroth
>
> TestS3ContractRootDir#testRmEmptyRootDirNonRecursive and 
> TestS3ContractRootDir#testRmRootRecursive fail on branch-2.  The tests pass 
> on trunk.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to