Hadoop Common
  1. Hadoop Common
  2. HADOOP-7974

TestViewFsTrash incorrectly determines the user's home directory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.23.1
    • Fix Version/s: 0.23.1
    • Component/s: fs, test
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      HADOOP-7284 added a test called TestViewFsTrash which contains the following code to determine the user's home directory. It only works if the user's directory is one level deep, and breaks if the home directory is more than one level deep (eg user hudson, who's home dir might be /usr/lib/hudson instead of /home/hudson).

          // create a link for home directory so that trash path works
          // set up viewfs's home dir root to point to home dir root on target
          // But home dir is different on linux, mac etc.
          // Figure it out by calling home dir on target
          
         String homeDir = fsTarget.getHomeDirectory().toUri().getPath();
         int indexOf2ndSlash = homeDir.indexOf('/', 1);
         String homeDirRoot = homeDir.substring(0, indexOf2ndSlash);
         ConfigUtil.addLink(conf, homeDirRoot,
             fsTarget.makeQualified(new Path(homeDirRoot)).toUri()); 
         ConfigUtil.setHomeDirConf(conf, homeDirRoot);
         Log.info("Home dir base " + homeDirRoot);
      

      Seems like we should instead search from the end of the path for the last slash and use that as the base, ie ask the home directory for its parent.

        Issue Links

          Activity

            People

            • Assignee:
              Harsh J
              Reporter:
              Eli Collins
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development