hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject svn commit: r1357995 - in /hadoop/common/branches/branch-1.1: ./ src/core/org/apache/hadoop/security/ src/test/org/apache/hadoop/mapred/ src/test/org/apache/hadoop/security/
Date Thu, 05 Jul 2012 23:43:24 GMT
Author: szetszwo
Date: Thu Jul  5 23:43:24 2012
New Revision: 1357995

URL: http://svn.apache.org/viewvc?rev=1357995&view=rev
Log:
svn merge -c 1357994 from branch-1 for HDFS-6527. Backport HADOOP-7389: Use of TestingGroups
by tests causes subsequent tests to fail.

Modified:
    hadoop/common/branches/branch-1.1/   (props changed)
    hadoop/common/branches/branch-1.1/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/branch-1.1/src/core/org/apache/hadoop/security/UserGroupInformation.java
    hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestQueueManager.java
    hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/TestUserGroupInformation.java

Propchange: hadoop/common/branches/branch-1.1/
------------------------------------------------------------------------------
  Merged /hadoop/common/branches/branch-1:r1357994

Modified: hadoop/common/branches/branch-1.1/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/CHANGES.txt?rev=1357995&r1=1357994&r2=1357995&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.1/CHANGES.txt (original)
+++ hadoop/common/branches/branch-1.1/CHANGES.txt Thu Jul  5 23:43:24 2012
@@ -265,6 +265,9 @@ Release 1.1.0 - unreleased
     HDFS-3551. WebHDFS CREATE should use client location for HTTP redirection.
     (szetszwo)
 
+    HDFS-6527. Backport HADOOP-7389: Use of TestingGroups by tests causes
+    subsequent tests to fail.  (Ivan Mitic via szetszwo)
+
 Release 1.0.3 - 2012.05.07
 
   NEW FEATURES

Propchange: hadoop/common/branches/branch-1.1/CHANGES.txt
------------------------------------------------------------------------------
  Merged /hadoop/common/branches/branch-1/CHANGES.txt:r1357994

Modified: hadoop/common/branches/branch-1.1/src/core/org/apache/hadoop/security/UserGroupInformation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/core/org/apache/hadoop/security/UserGroupInformation.java?rev=1357995&r1=1357994&r2=1357995&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.1/src/core/org/apache/hadoop/security/UserGroupInformation.java
(original)
+++ hadoop/common/branches/branch-1.1/src/core/org/apache/hadoop/security/UserGroupInformation.java
Thu Jul  5 23:43:24 2012
@@ -895,17 +895,21 @@ public class UserGroupInformation {
   private static class TestingGroups extends Groups {
     private final Map<String, List<String>> userToGroupsMapping = 
       new HashMap<String,List<String>>();
+    private Groups underlyingImplementation;
     
-    private TestingGroups() {
+    private TestingGroups(Groups underlyingImplementation) {
       super(new org.apache.hadoop.conf.Configuration());
+      this.underlyingImplementation = underlyingImplementation;
     }
     
     @Override
-    public List<String> getGroups(String user) {
+    public List<String> getGroups(String user) throws IOException {
       List<String> result = userToGroupsMapping.get(user);
+
       if (result == null) {
-        result = new ArrayList<String>();
+        result = underlyingImplementation.getGroups(user);
       }
+
       return result;
     }
 
@@ -926,7 +930,7 @@ public class UserGroupInformation {
     UserGroupInformation ugi = createRemoteUser(user);
     // make sure that the testing object is setup
     if (!(groups instanceof TestingGroups)) {
-      groups = new TestingGroups();
+      groups = new TestingGroups(groups);
     }
     // add the user groups
     ((TestingGroups) groups).setUserGroups(ugi.getShortUserName(), userGroups);
@@ -951,7 +955,7 @@ public class UserGroupInformation {
     UserGroupInformation ugi = createProxyUser(user, realUser);
     // make sure that the testing object is setup
     if (!(groups instanceof TestingGroups)) {
-      groups = new TestingGroups();
+      groups = new TestingGroups(groups);
     }
     // add the user groups
     ((TestingGroups) groups).setUserGroups(ugi.getShortUserName(), userGroups);

Modified: hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestQueueManager.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestQueueManager.java?rev=1357995&r1=1357994&r2=1357995&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestQueueManager.java
(original)
+++ hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/mapred/TestQueueManager.java
Thu Jul  5 23:43:24 2012
@@ -48,19 +48,8 @@ public class TestQueueManager extends Te
 
   MiniDFSCluster miniDFSCluster;
   MiniMRCluster miniMRCluster = null;
-  
-  /**
-   * For some tests it is necessary to sandbox them in a doAs with a fake user
-   * due to bug HADOOP-6527, which wipes out real group mappings. It's also
-   * necessary to then add the real user running the test to the fake users
-   * so that child processes can write to the DFS.
-   */
+
   UserGroupInformation createNecessaryUsers() throws IOException {
-    // Add real user to fake groups mapping so that child processes (tasks)
-    // will have permissions on the dfs
-    String j = UserGroupInformation.getCurrentUser().getShortUserName();
-    UserGroupInformation.createUserForTesting(j, new String [] { "myGroup"});
-    
     // Create a fake user for all processes to execute within
     UserGroupInformation ugi = UserGroupInformation.createUserForTesting("Zork",
                                                  new String [] {"ZorkGroup"});
@@ -130,12 +119,10 @@ public class TestQueueManager extends Te
       verifyJobSubmissionToDefaultQueue(conf, true, userName + "," + groupName);
       verifyJobSubmissionToDefaultQueue(conf, true, user2 + "," + group2);
     
-      // Check if MROwner(user who started the mapreduce cluster) can submit job
-      UserGroupInformation mrOwner = UserGroupInformation.getCurrentUser();
-      userName = mrOwner.getShortUserName();
-      String[] groups = mrOwner.getGroupNames();
-      groupName = groups[groups.length - 1];
-      verifyJobSubmissionToDefaultQueue(conf, true, userName + "," + groupName);
+      // Check if MROwner (user who started the mapreduce cluster) can submit
+      // job. By passing null as userInfo we fallback to using the
+      // UserGroupInformation.getCurrentUser() what is the intent of the test.
+      verifyJobSubmissionToDefaultQueue(conf, true, null);
     } finally {
       tearDownCluster();
     }

Modified: hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/TestUserGroupInformation.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/TestUserGroupInformation.java?rev=1357995&r1=1357994&r2=1357995&view=diff
==============================================================================
--- hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/TestUserGroupInformation.java
(original)
+++ hadoop/common/branches/branch-1.1/src/test/org/apache/hadoop/security/TestUserGroupInformation.java
Thu Jul  5 23:43:24 2012
@@ -76,6 +76,29 @@ public class TestUserGroupInformation {
     UserGroupInformation.setConfiguration(conf);
   }
   
+  /** Test login method */
+  @Test
+  public void testLogin() throws Exception {
+    // login from unix
+    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+    assertEquals(UserGroupInformation.getCurrentUser(),
+                 UserGroupInformation.getLoginUser());
+    assertTrue(ugi.getGroupNames().length >= 1);
+
+    // ensure that doAs works correctly
+    UserGroupInformation userGroupInfo = 
+      UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES);
+    UserGroupInformation curUGI = 
+      userGroupInfo.doAs(new PrivilegedExceptionAction<UserGroupInformation>(){
+        public UserGroupInformation run() throws IOException {
+          return UserGroupInformation.getCurrentUser();
+        }});
+    // make sure in the scope of the doAs, the right user is current
+    assertEquals(curUGI, userGroupInfo);
+    // make sure it is not the same as the login user
+    assertFalse(curUGI.equals(UserGroupInformation.getLoginUser()));
+  }
+  
   /**
    * given user name - get all the groups.
    * Needs to happen before creating the test users
@@ -120,29 +143,6 @@ public class TestUserGroupInformation {
       }});
   }
 
-  /** Test login method */
-  @Test
-  public void testLogin() throws Exception {
-    // login from unix
-    UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
-    assertEquals(UserGroupInformation.getCurrentUser(),
-                 UserGroupInformation.getLoginUser());
-    assertTrue(ugi.getGroupNames().length >= 1);
-
-    // ensure that doAs works correctly
-    UserGroupInformation userGroupInfo = 
-      UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES);
-    UserGroupInformation curUGI = 
-      userGroupInfo.doAs(new PrivilegedExceptionAction<UserGroupInformation>(){
-        public UserGroupInformation run() throws IOException {
-          return UserGroupInformation.getCurrentUser();
-        }});
-    // make sure in the scope of the doAs, the right user is current
-    assertEquals(curUGI, userGroupInfo);
-    // make sure it is not the same as the login user
-    assertFalse(curUGI.equals(UserGroupInformation.getLoginUser()));
-  }
-
   /** test constructor */
   @Test
   public void testConstructor() throws Exception {



Mime
View raw message