[
https://issues.apache.org/jira/browse/OOZIE-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13101810#comment-13101810
]
Hadoop QA commented on OOZIE-49:
--------------------------------
aprabhakar remarked:
Sounds good. Here is a patch that does that:
diff --git core/src/test/java/org/apache/oozie/test/XTestCase.java
core/src/test/java/org/apache/oozie/test/XTestCase.java
index 014e581..90529bd 100644
--- core/src/test/java/org/apache/oozie/test/XTestCase.java
+++ core/src/test/java/org/apache/oozie/test/XTestCase.java
@@ -93,6 +93,36 @@ public abstract class XTestCase extends TestCase {
*/
public static final String HADOOP_VERSION = "hadoop.version";
+ /**
+ * System property that specifies the user that test oozie instance
runs as.
+ * The value of this property defaults to the "${user.name} system
property.
+ */
+ public static final String TEST_OOZIE_USER_PROP =
"oozie.test.user.oozie";
+
+ /**
+ * System property that specifies the default test user name used by
+ * the tests. The defalt value of this property is <tt>test</tt>.
+ */
+ public static final String TEST_USER1_PROP = "oozie.test.user.test";
+
+ /**
+ * System property that specifies an auxilliary test user name used by
the
+ * tests. The default value of this property is <tt>test2</tt>.
+ */
+ public static final String TEST_USER2_PROP = "oozie.test.user.test2";
+
+ /**
+ * System property that specifies another auxilliary test user name
used by
+ * the tests. The default value of this property is <tt>test3</tt>.
+ */
+ public static final String TEST_USER3_PROP = "oozie.test.user.test3";
+
+ /**
+ * System property that specifies the test groiup used by the tests.
+ * The default value of this property is <tt>testg</tt>.
+ */
+ public static final String TEST_GROUP_PROP = "oozie.test.group";
+
/**
* Initialize the test working directory. <p/> If it does not exist it
creates it, if it already exists it deletes
* all its contents. <p/> The test working directory it is not deleted
after the test runs. <p/>
@@ -152,25 +182,39 @@ public abstract class XTestCase extends TestCase {
return hadoopVersion;
}
+ public static String getOozieUser() {
+ return getSystemProperty(TEST_OOZIE_USER_PROP,
+ System.getProperty("user.name"));
+ }
+
+ /**
+ * @return the user to use in testcases.
+ */
protected String getTestUser() {
- return "test";
+ return getSystemProperty(TEST_USER1_PROP, "test");
}
+ /**
+ * @return the user to use in testcases.
+ */
protected String getTestUser2() {
- return "test2";
+ return getSystemProperty(TEST_USER2_PROP, "test2");
}
+ /**
+ * @return the user to use in testcases.
+ */
protected String getTestUser3() {
- return "test3";
+ return getSystemProperty(TEST_USER3_PROP, "test3");
}
/**
- * Return the user to use in testcases.
+ * Return the user group to use in testcases.
*
- * @return the user to use in testcases.
+ * @return the user group to use in testcases.
*/
protected String getTestGroup() {
- return "testg";
+ return getSystemProperty(TEST_GROUP_PROP, "testg");
}
/**
@@ -345,6 +389,21 @@ public abstract class XTestCase extends TestCase {
return System.getProperty(OOZIE_TEST_NAME_NODE,
"hdfs://localhost:9000");
}
+ /**
+ * Returns the value of the system property specifiedy by the
+ * <tt>propertyName</tt>. If the property value is not set or its
value
+ * is equal to the string <tt>${propertyName}</tt>, the default value
+ * is returned.
+ */
+ public static String getSystemProperty(String propertyName, String
defaultValue) {
+ String value = System.getProperty(propertyName, defaultValue);
+ if ( value != null && value.equals("${" + propertyName + "}")) {
+ // Value was not substituted, use the default instead
+ return defaultValue;
+ }
+ return value;
+ }
+
public String getKeytabFile() {
String defaultFile = new File(System.getProperty("user.home"),
"oozie.keytab").getAbsolutePath();
return System.getProperty("oozie.test.kerberos.keytab.file",
defaultFile);
@@ -356,7 +415,7 @@ public abstract class XTestCase extends TestCase {
public String getOoziePrincipal() {
return System.getProperty("oozie.test.kerberos.oozie.principal",
- System.getProperty("user.name") +
"/localhost") + "@" + getRealm();
+ getOozieUser() + "/localhost") + "@" +
getRealm();
}
public String getJobTrackerPrincipal() {
@@ -500,12 +559,13 @@ public abstract class XTestCase extends TestCase {
}
int taskTrackers = 2;
int dataNodes = 2;
+ String oozieUser = getOozieUser();
JobConf conf = new JobConf();
conf.set("dfs.block.access.token.enable", "false");
conf.set("dfs.permissions", "true");
conf.set("hadoop.security.authentication", "simple");
- conf.set("hadoop.proxyuser." + System.getProperty("user.name")
+ ".hosts", "localhost");
- conf.set("hadoop.proxyuser." + System.getProperty("user.name")
+ ".groups", "users");
+ conf.set("hadoop.proxyuser." + oozieUser + ".hosts",
"localhost");
+ conf.set("hadoop.proxyuser." + oozieUser + ".groups", "users");
conf.set("mapred.tasktracker.map.tasks.maximum", "4");
conf.set("mapred.tasktracker.reduce.tasks.maximum", "4");
dfsCluster = new MiniDFSCluster(conf, dataNodes, true, null);
diff --git pom.xml pom.xml
index 75d70c8..76b9a9f 100644
--- pom.xml
+++ pom.xml
@@ -219,6 +219,26 @@
<argLine>-Xmx512m</argLine>
<systemProperties>
<property>
+ <name>oozie.test.user.oozie</name>
+ <value>${oozie.test.user.oozie}</value>
+ </property>
+ <property>
+ <name>oozie.test.user.test</name>
+ <value>${oozie.test.user.test}</value>
+ </property>
+ <property>
+ <name>oozie.test.user.test2</name>
+ <value>${oozie.test.user.test2}</value>
+ </property>
+ <property>
+ <name>oozie.test.user.test3</name>
+ <value>${oozie.test.user.test3}</value>
+ </property>
+ <property>
+ <name>oozie.test.group</name>
+ <value>${oozie.test.group}</value>
+ </property>
+ <property>
<name>oozie.test.dir</name>
<value>${oozie.test.dir}</value>
</property>
I have changed the test1 property and value to test2 an d test2 property and
value to test3 for consistency with the current implementation. They can be
changed back if necessary.
> GH-3: The XTestCase.getTestUser() method returns the hardcoded username test.
> This results in failure due to SSH authentication failure in case this user
> is not setup correctly.
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: OOZIE-49
> URL: https://issues.apache.org/jira/browse/OOZIE-49
> Project: Oozie
> Issue Type: Bug
> Reporter: Hadoop QA
>
> One workaround would be to run the tests as test user and have the
> environment setup correctly for that. The other solution would be to by
> default use the current user for test purposes, and overwrite that to another
> user where necessary.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira