Permalink
Browse files

Closes GH-54 Implement better way of managing test users in unit tests

According to the Hadoop development team, UserGroupInformation.createUserForTesting
is a proper way of setting up test users for the purposes of unit testing.
  • Loading branch information...
1 parent ffa6610 commit 83e29a303e66feedd1f81996c0473cf8be531f45 @rvs committed with Mohammad Kamrul Islam Oct 4, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 core/src/test/java/org/apache/oozie/test/XTestCase.java
@@ -33,6 +33,7 @@
import junit.framework.TestCase;
import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -577,6 +578,13 @@ private static void setUpEmbeddedHadoop() throws Exception {
conf.set("hadoop.proxyuser." + oozieUser + ".groups", getTestGroup());
conf.set("mapred.tasktracker.map.tasks.maximum", "4");
conf.set("mapred.tasktracker.reduce.tasks.maximum", "4");
+
+ String [] userGroups = new String[] { getTestGroup() };
+ UserGroupInformation.createUserForTesting(oozieUser, userGroups);
+ UserGroupInformation.createUserForTesting(getTestUser(), userGroups);
+ UserGroupInformation.createUserForTesting(getTestUser2(), userGroups);
+ UserGroupInformation.createUserForTesting(getTestUser3(), new String[] { "users" } );
+
dfsCluster = new MiniDFSCluster(conf, dataNodes, true, null);
FileSystem fileSystem = dfsCluster.getFileSystem();
fileSystem.mkdirs(new Path("/tmp"));

0 comments on commit 83e29a3

Please sign in to comment.