You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by ro...@apache.org on 2013/10/01 01:00:17 UTC
svn commit: r1527818 [3/3] - in /oozie/trunk: ./
core/src/main/java/org/apache/oozie/service/
core/src/test/java/org/apache/oozie/
core/src/test/java/org/apache/oozie/action/hadoop/
core/src/test/java/org/apache/oozie/action/oozie/ core/src/test/java/o...
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/service/TestLiteWorkflowAppService.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestLiteWorkflowAppService.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/service/TestLiteWorkflowAppService.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/service/TestLiteWorkflowAppService.java Mon Sep 30 23:00:16 2013
@@ -34,6 +34,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.Reader;
import java.io.Writer;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -84,13 +85,13 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Configuration conf = new XConfiguration();
WorkflowAppService wps = services.get(WorkflowAppService.class);
- String wfDef = wps.readDefinition("file://" + getTestCaseDir() + File.separator + "workflow.xml",
+ String wfDef = wps.readDefinition(getTestCaseFileUri("workflow.xml"),
getTestUser(), conf);
assertNotNull(reader.toString(), wfDef);
}
@@ -111,13 +112,13 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Configuration conf = new XConfiguration();
WorkflowAppService wps = services.get(WorkflowAppService.class);
- wps.readDefinition("file://" + getTestCaseDir() + File.separator + "workflow.xml", getTestUser(),
+ wps.readDefinition(getTestCaseFileUri("workflow.xml"), getTestUser(),
conf);
fail("an exception should be thrown as the definition exceeds the given maximum");
}
@@ -151,13 +152,13 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
@@ -166,7 +167,7 @@ public class TestLiteWorkflowAppService
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-schema-invalid.xml", -1);
- writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
try {
@@ -191,13 +192,13 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
@@ -206,7 +207,7 @@ public class TestLiteWorkflowAppService
assertEquals("test-wf", app.getName());
reader = IOUtils.getResourceAsReader("wf-ext-schema-invalid.xml", -1);
- writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
try {
@@ -229,13 +230,13 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-action-name-too-long.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = services.get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
@@ -260,11 +261,11 @@ public class TestLiteWorkflowAppService
WorkflowAppService wps = services.get(WorkflowAppService.class);
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
@@ -307,36 +308,42 @@ public class TestLiteWorkflowAppService
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
- writer = new FileWriter(getTestCaseDir() + "/lib/maputil.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
- writer = new FileWriter(getTestCaseDir() + "/lib/reduceutil.so");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("scripts");
- writer = new FileWriter(getTestCaseDir() + "/scripts/myscript.sh");
+ writer = new FileWriter(new File(getTestCaseDir(), "scripts/myscript.sh"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
assertEquals(2, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
- String f1 = protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0];
- String f2 = protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1];
- String ref1 = "file://" + getTestCaseDir() + "/lib/reduceutil.so";
- String ref2 = "file://" + getTestCaseDir() + "/lib/maputil.jar";
- Assert.assertTrue(f1.equals(ref1) || f1.equals(ref2));
- Assert.assertTrue(f2.equals(ref1) || f2.equals(ref2));
- Assert.assertTrue(!f1.equals(f2));
+ List<String> found = new ArrayList<String>();
+ found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
+ found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
+ List<String> expected = new ArrayList<String>();
+ expected.add(getTestCaseFileUri("lib/reduceutil.so"));
+ expected.add(getTestCaseFileUri("lib/maputil.jar"));
+
+ Collections.sort(found);
+ Collections.sort(expected);
+ for(int i=0; i<expected.size(); i++) {
+ assert(new URI(expected.get(i)).equals(new URI(found.get(i))));
+ }
+ Assert.assertTrue(!new URI(found.get(0)).equals(new URI(found.get(1))));
}
finally {
services.destroy();
@@ -348,24 +355,24 @@ public class TestLiteWorkflowAppService
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
- writer = new FileWriter(getTestCaseDir() + "/lib/maputil.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
- writer = new FileWriter(getTestCaseDir() + "/lib/reduceutil.so");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libx");
- writer = new FileWriter(getTestCaseDir() + "/libx/maputilx.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "libx/maputilx.jar"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + "/workflow.xml");
- jobConf.set(OozieClient.LIBPATH, "file://" + getTestCaseDir() + "/libx");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
+ jobConf.set(OozieClient.LIBPATH, getTestCaseFileUri("libx"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
@@ -377,12 +384,15 @@ public class TestLiteWorkflowAppService
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
List<String> expected = new ArrayList<String>();
- expected.add("file://" + getTestCaseDir() + "/lib/reduceutil.so");
- expected.add("file://" + getTestCaseDir() + "/lib/maputil.jar");
- expected.add("file://" + getTestCaseDir() + "/libx/maputilx.jar");
+ expected.add(getTestCaseFileUri("lib/reduceutil.so"));
+ expected.add(getTestCaseFileUri("lib/maputil.jar"));
+ expected.add(getTestCaseFileUri("libx/maputilx.jar"));
Collections.sort(found);
Collections.sort(expected);
- assertEquals(expected, found);
+ assertEquals(expected.size(), found.size());
+ for(int i=0; i<expected.size(); i++) {
+ assert(new URI(expected.get(i)).equals(new URI(found.get(i))));
+ }
}
finally {
services.destroy();
@@ -394,37 +404,37 @@ public class TestLiteWorkflowAppService
try {
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
createTestCaseSubDir("lib");
- writer = new FileWriter(getTestCaseDir() + "/lib/maputil.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/maputil.jar"));
writer.write("bla bla");
writer.close();
- writer = new FileWriter(getTestCaseDir() + "/lib/reduceutil.so");
+ writer = new FileWriter(new File(getTestCaseDir(), "lib/reduceutil.so"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libx");
- writer = new FileWriter(getTestCaseDir() + "/libx/maputil_x.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "libx/maputil_x.jar"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("liby");
- writer = new FileWriter(getTestCaseDir() + "/liby/maputil_y1.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y1.jar"));
writer.write("bla bla");
writer.close();
- writer = new FileWriter(getTestCaseDir() + "/liby/maputil_y2.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "liby/maputil_y2.jar"));
writer.write("bla bla");
writer.close();
createTestCaseSubDir("libz");
- writer = new FileWriter(getTestCaseDir() + "/libz/maputil_z.jar");
+ writer = new FileWriter(new File(getTestCaseDir(), "libz/maputil_z.jar"));
writer.write("bla bla");
writer.close();
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + "/workflow.xml");
- jobConf.setStrings(OozieClient.LIBPATH, "file://" + getTestCaseDir() + "/libx",
- "file://" + getTestCaseDir() + "/liby", "file://" + getTestCaseDir() + "/libz");
+ jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
+ jobConf.setStrings(OozieClient.LIBPATH, getTestCaseFileUri("libx"),
+ getTestCaseFileUri("liby"), getTestCaseFileUri("libz"));
jobConf.set(OozieClient.USER_NAME, getTestUser());
Configuration protoConf = wps.createProtoActionConf(jobConf, true);
@@ -439,15 +449,17 @@ public class TestLiteWorkflowAppService
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[4]);
found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[5]);
List<String> expected = new ArrayList<String>();
- expected.add("file://" + getTestCaseDir() + "/lib/reduceutil.so");
- expected.add("file://" + getTestCaseDir() + "/lib/maputil.jar");
- expected.add("file://" + getTestCaseDir() + "/libx/maputil_x.jar");
- expected.add("file://" + getTestCaseDir() + "/liby/maputil_y1.jar");
- expected.add("file://" + getTestCaseDir() + "/liby/maputil_y2.jar");
- expected.add("file://" + getTestCaseDir() + "/libz/maputil_z.jar");
+ expected.add(getTestCaseFileUri("lib/reduceutil.so"));
+ expected.add(getTestCaseFileUri("lib/maputil.jar"));
+ expected.add(getTestCaseFileUri("libx/maputil_x.jar"));
+ expected.add(getTestCaseFileUri("liby/maputil_y1.jar"));
+ expected.add(getTestCaseFileUri("liby/maputil_y2.jar"));
+ expected.add(getTestCaseFileUri("libz/maputil_z.jar"));
Collections.sort(found);
- Collections.sort(expected);
- assertEquals(expected, found);
+ assertEquals(expected.size(), found.size());
+ for(int i=0; i<expected.size(); i++) {
+ assert(new URI(expected.get(i)).equals(new URI(found.get(i))));
+ }
}
finally {
services.destroy();
@@ -593,28 +605,28 @@ public class TestLiteWorkflowAppService
services.init();
Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
String childWFDir = createTestCaseSubDir("child-wf-" + unique);
- Writer writer = new FileWriter(childWFDir + File.separator + "workflow.xml");
+ File childWFFile = new File(childWFDir, "workflow.xml");
+ Writer writer = new FileWriter(childWFFile);
IOUtils.copyCharStream(reader, writer);
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration jobConf = new XConfiguration();
- jobConf.set(OozieClient.APP_PATH, "file://" + childWFDir + File.separator + "workflow.xml");
+ jobConf.set(OozieClient.APP_PATH, childWFFile.toURI().toString());
jobConf.set(OozieClient.USER_NAME, getTestUser());
if (inheritWF != null) {
jobConf.set("oozie.wf.subworkflow.classpath.inheritance", inheritWF);
}
- String childLibDir = createTestCaseSubDir("child-wf-" + unique + File.separator + "lib");
+ String childLibDir = createTestCaseSubDir("child-wf-" + unique, "lib");
for (String childLib : childLibs) {
- writer = new FileWriter(childLibDir + File.separator + childLib);
+ writer = new FileWriter(new File(childLibDir, childLib));
writer.write("bla bla");
writer.close();
}
- String parentWFDir = createTestCaseSubDir("parent-wf-" + unique);
- String parentLibDir = createTestCaseSubDir("parent-wf-" + unique + File.separator + "lib");
+ String parentLibDir = createTestCaseSubDir("parent-wf-" + unique, "lib");
String[] parentLibsFullPaths = new String[parentLibs.length];
for (int i = 0; i < parentLibs.length; i++) {
- parentLibsFullPaths[i] = parentLibDir + File.separator + parentLibs[i];
+ parentLibsFullPaths[i] = new File(parentLibDir, parentLibs[i]).toString();
writer = new FileWriter(parentLibsFullPaths[i]);
writer.write("bla bla");
writer.close();
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/service/TestPurgeService.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestPurgeService.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/service/TestPurgeService.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/service/TestPurgeService.java Mon Sep 30 23:00:16 2013
@@ -94,12 +94,12 @@ public class TestPurgeService extends XD
*/
public void testPurgeServiceForWorkflow() throws Exception {
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
IOUtils.copyCharStream(reader, writer);
final DagEngine engine = new DagEngine("u");
Configuration conf = new XConfiguration();
- conf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ conf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.setStrings(OozieClient.USER_NAME, getTestUser());
conf.setStrings(OozieClient.GROUP_NAME, getTestGroup());
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/service/TestRecoveryService.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestRecoveryService.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/service/TestRecoveryService.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/service/TestRecoveryService.java Mon Sep 30 23:00:16 2013
@@ -111,13 +111,13 @@ public class TestRecoveryService extends
*/
public void testWorkflowActionRecoveryService() throws Exception {
Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
- Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
+ Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
createTestCaseSubDir("lib");
IOUtils.copyCharStream(reader, writer);
final DagEngine engine = new DagEngine(getTestUser());
Configuration conf = new XConfiguration();
- conf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + File.separator + "workflow.xml");
+ conf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
conf.set(OozieClient.USER_NAME, getTestUser());
conf.set(OozieClient.LOG_TOKEN, "t");
@@ -262,7 +262,7 @@ public class TestRecoveryService extends
store.beginTrx();
try {
createTestCaseSubDir("no-op");
- createTestCaseSubDir("no-op/lib");
+ createTestCaseSubDir("no-op", "lib");
createTestCaseSubDir("workflows");
createTestCaseSubDir("in");
addRecordToJobTable(jobId, store, getTestCaseDir());
@@ -312,10 +312,10 @@ public class TestRecoveryService extends
CoordinatorActionBean action = addRecordToCoordActionTableForWaiting(job.getId(), 1,
CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
- createDir(getTestCaseDir() + "/2009/29/");
- createDir(getTestCaseDir() + "/2009/22/");
- createDir(getTestCaseDir() + "/2009/15/");
- createDir(getTestCaseDir() + "/2009/08/");
+ createDir(new File(getTestCaseDir(), "/2009/29/"));
+ createDir(new File(getTestCaseDir(), "/2009/22/"));
+ createDir(new File(getTestCaseDir(), "/2009/15/"));
+ createDir(new File(getTestCaseDir(), "/2009/08/"));
sleep(3000);
@@ -524,7 +524,11 @@ public class TestRecoveryService extends
CoordinatorAction.Status status, String resourceXmlName) throws Exception {
CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, 0);
String testDir = getTestCaseDir();
- String missDeps = "file://#testDir/2009/29/_SUCCESS#file://#testDir/2009/22/_SUCCESS#file://#testDir/2009/15/_SUCCESS#file://#testDir/2009/08/_SUCCESS";
+ String missDeps = getTestCaseFileUri("2009/29/_SUCCESS") + "#"
+ + getTestCaseFileUri("2009/22/_SUCCESS") + "#"
+ + getTestCaseFileUri("2009/15/_SUCCESS") + "#"
+ + getTestCaseFileUri("2009/08/_SUCCESS");
+
missDeps = missDeps.replaceAll("#testDir", testDir);
action.setMissingDependencies(missDeps);
@@ -564,8 +568,7 @@ public class TestRecoveryService extends
action.setNominalTime(new Date());
action.setLastModifiedTime(new Date());
action.setStatus(CoordinatorAction.Status.SUBMITTED);
- String appPath = baseDir + "/no-op/workflow.xml";
- String baseURI = baseDir + "/workflows";
+ String appPath = getTestCaseFileUri("no-op/workflow.xml");
String actionXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' xmlns:sla='uri:oozie:sla:0.1' name='NAME' frequency=\"1\" start='2009-02-01T01:00Z' end='2009-02-03T23:59Z' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE' instance-number=\"1\" action-nominal-time=\"2009-02-01T01:00Z\">";
actionXml += "<controls>";
actionXml += "<timeout>10</timeout>";
@@ -575,7 +578,7 @@ public class TestRecoveryService extends
actionXml += "<input-events>";
actionXml += "<data-in name='A' dataset='a'>";
actionXml += "<dataset name='a' frequency='7' initial-instance='2009-02-01T01:00Z' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
- actionXml += "<uri-template>file://" + baseURI + "/workflows/${YEAR}/${DAY}</uri-template>";
+ actionXml += "<uri-template>" + getTestCaseFileUri("workflows/workflows/${YEAR}/${DAY}") + "</uri-template>";
actionXml += "</dataset>";
actionXml += "<instance>${coord:latest(0)}</instance>";
actionXml += "</data-in>";
@@ -583,22 +586,22 @@ public class TestRecoveryService extends
actionXml += "<output-events>";
actionXml += "<data-out name='LOCAL_A' dataset='local_a'>";
actionXml += "<dataset name='local_a' frequency='7' initial-instance='2009-02-01T01:00Z' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
- actionXml += "<uri-template>file://" + baseURI + "/${YEAR}/${DAY}</uri-template>";
+ actionXml += "<uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${DAY}") + "</uri-template>";
actionXml += "</dataset>";
actionXml += "<instance>${coord:current(-1)}</instance>";
actionXml += "</data-out>";
actionXml += "</output-events>";
actionXml += "<action>";
actionXml += "<workflow>";
- actionXml += "<app-path>file://" + appPath + "</app-path>";
+ actionXml += "<app-path>" + appPath + "</app-path>";
actionXml += "<configuration>";
actionXml += "<property>";
actionXml += "<name>inputA</name>";
- actionXml += "<value>file://" + baseURI + "/US/2009/02/01</value>";
+ actionXml += "<value>" + getTestCaseFileUri("workflows/US/2009/02/") + "</value>";
actionXml += "</property>";
actionXml += "<property>";
actionXml += "<name>inputB</name>";
- actionXml += "<value>file://" + baseURI + "/US/2009/02/01</value>";
+ actionXml += "<value>" + getTestCaseFileUri("workflows/US/2009/01/") + "</value>";
actionXml += "</property>";
actionXml += "</configuration>";
actionXml += "</workflow>";
@@ -610,7 +613,7 @@ public class TestRecoveryService extends
createdConf += "<property> <name>execution_order</name> <value>LIFO</value> </property>";
createdConf += "<property> <name>user.name</name> <value>" + getTestUser() + "</value> </property>";
createdConf += "<property> <name>group.name</name> <value>other</value> </property>";
- createdConf += "<property> <name>app-path</name> " + "<value>file://" + appPath + "</value> </property>";
+ createdConf += "<property> <name>app-path</name> <value>" + appPath + "</value> </property>";
createdConf += "<property> <name>jobTracker</name> ";
createdConf += "<value>localhost:9001</value></property>";
createdConf += "<property> <name>nameNode</name> <value>hdfs://localhost:9000</value></property>";
@@ -631,8 +634,8 @@ public class TestRecoveryService extends
}
private void writeToFile(String content, String appPath) throws IOException {
- createDir(appPath);
- File wf = new File(appPath + "/workflow.xml");
+ createDir(new File(appPath));
+ File wf = new File(appPath, "workflow.xml");
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(wf));
@@ -650,18 +653,8 @@ public class TestRecoveryService extends
}
- private void createDir(String dir) {
- Process pr;
- try {
- pr = Runtime.getRuntime().exec("mkdir -p " + dir + "/_SUCCESS");
- pr.waitFor();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
+ private void createDir(File dir) {
+ new File(dir, "_SUCCESS").mkdirs();
}
private void addRecordToJobTable(String jobId, CoordinatorStore store, String baseDir) throws StoreException {
@@ -676,7 +669,6 @@ public class TestRecoveryService extends
coordJob.setGroup(getTestGroup());
coordJob.setTimeZone("UTC");
- String baseURI = baseDir + "/workflows";
String confStr = "<configuration></configuration>";
coordJob.setConf(confStr);
String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' name='NAME' frequency=\"1\" start='2009-02-01T01:00Z' end='2009-02-03T23:59Z'";
@@ -689,7 +681,7 @@ public class TestRecoveryService extends
appXml += "<input-events>";
appXml += "<data-in name='A' dataset='a'>";
appXml += "<dataset name='a' frequency='7' initial-instance='2009-02-01T01:00Z' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
- appXml += "<uri-template>file://" + baseURI + "/${YEAR}/${DAY}</uri-template>";
+ appXml += "<uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${DAY}") + "</uri-template>";
appXml += "</dataset>";
appXml += "<instance>${coord:latest(0)}</instance>";
appXml += "</data-in>";
@@ -697,14 +689,14 @@ public class TestRecoveryService extends
appXml += "<output-events>";
appXml += "<data-out name='LOCAL_A' dataset='local_a'>";
appXml += "<dataset name='local_a' frequency='7' initial-instance='2009-02-01T01:00Z' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
- appXml += "<uri-template>file://" + baseURI + "/${YEAR}/${DAY}</uri-template>";
+ appXml += "<uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${DAY}") + "</uri-template>";
appXml += "</dataset>";
appXml += "<instance>${coord:current(-1)}</instance>";
appXml += "</data-out>";
appXml += "</output-events>";
appXml += "<action>";
appXml += "<workflow>";
- appXml += "<app-path>file://" + baseURI + "</app-path>";
+ appXml += "<app-path>" + getTestCaseFileUri("workflows") + "</app-path>";
appXml += "<configuration>";
appXml += "<property>";
appXml += "<name>inputA</name>";
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestAdminServlet.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestAdminServlet.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestAdminServlet.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestAdminServlet.java Mon Sep 30 23:00:16 2013
@@ -34,6 +34,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
+import org.apache.hadoop.util.Shell;
public class TestAdminServlet extends DagServletTestCase {
@@ -71,7 +72,7 @@ public class TestAdminServlet extends Da
assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
- assertTrue(json.containsKey("USER"));
+ assertTrue(json.containsKey(Shell.WINDOWS ? "USERNAME" : "USER"));
return null;
}
});
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestHostnameFilter.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestHostnameFilter.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestHostnameFilter.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestHostnameFilter.java Mon Sep 30 23:00:16 2013
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.Atomi
import junit.framework.Assert;
import junit.framework.TestCase;
+import org.apache.hadoop.util.Shell;
import org.mockito.Mockito;
public class TestHostnameFilter extends TestCase {
@@ -45,7 +46,7 @@ public class TestHostnameFilter extends
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
throws IOException, ServletException {
- Assert.assertTrue(HostnameFilter.get().contains("localhost"));
+ Assert.assertTrue(HostnameFilter.get().contains(Shell.WINDOWS ? "127.0.0.1" : "localhost"));
invoked.set(true);
}
};
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1AdminServlet.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1AdminServlet.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1AdminServlet.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/servlet/TestV1AdminServlet.java Mon Sep 30 23:00:16 2013
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletResponse;
+import org.apache.hadoop.util.Shell;
import org.apache.oozie.BuildInfo;
import org.apache.oozie.client.OozieClient.SYSTEM_MODE;
@@ -73,7 +74,7 @@ public class TestV1AdminServlet extends
assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode());
assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE));
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream()));
- assertTrue(json.containsKey("USER"));
+ assertTrue(json.containsKey(Shell.WINDOWS ? "USERNAME" : "USER"));
return null;
}
});
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/test/TestXFsTestCase.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/TestXFsTestCase.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/TestXFsTestCase.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/TestXFsTestCase.java Mon Sep 30 23:00:16 2013
@@ -17,6 +17,8 @@
*/
package org.apache.oozie.test;
+import java.io.File;
+import java.net.URI;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -26,20 +28,25 @@ public class TestXFsTestCase extends XFs
public void testFsDir() throws Exception {
assertNotNull(getFsTestCaseDir());
assertNotNull(getFileSystem());
+ assertNotNull(getTestCaseFileUri("file"));
String testDir = getTestCaseDir();
+ String testFile = getTestCaseFileUri("file");
String nameNode = getNameNodeUri();
String user = getTestUser();
Path fsTestDir = getFsTestCaseDir();
assertTrue(fsTestDir.toString().startsWith(nameNode));
- assertTrue(fsTestDir.toString().contains(user + testDir));
+ assertTrue(fsTestDir.toString().contains(user));
+ assertEquals(fsTestDir, getFsTestCaseDir());
FileSystem fs = getFileSystem();
assertTrue(fs.getUri().toString().startsWith(getNameNodeUri()));
assertTrue(fs.exists(fsTestDir));
assertTrue(fs.listStatus(fsTestDir).length == 0);
+
+ assertTrue(new File(new URI(testFile)).createNewFile());
}
}
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java Mon Sep 30 23:00:16 2013
@@ -1267,9 +1267,9 @@ public abstract class XDataTestCase exte
assertTrue(bundleAppXml.length() > 0);
bundleAppXml = bundleAppXml
- .replaceAll("#app_path1", Matcher.quoteReplacement(coordPath1.toString() + File.separator + "coordinator.xml"));
+ .replaceAll("#app_path1", Matcher.quoteReplacement(new Path(coordPath1.toString(), "coordinator.xml").toString()));
bundleAppXml = bundleAppXml
- .replaceAll("#app_path2", Matcher.quoteReplacement(coordPath2.toString() + File.separator + "coordinator.xml"));
+ .replaceAll("#app_path2", Matcher.quoteReplacement(new Path(coordPath2.toString(), "coordinator.xml").toString()));
writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
@@ -1323,9 +1323,9 @@ public abstract class XDataTestCase exte
String bundleAppXml = getBundleXml("bundle-submit-job.xml");
bundleAppXml = bundleAppXml
- .replaceAll("#app_path1", coordPath1.toString() + File.separator + "coordinator.xml");
+ .replaceAll("#app_path1", new Path(coordPath1.toString(), "coordinator.xml").toString());
bundleAppXml = bundleAppXml
- .replaceAll("#app_path2", coordPath2.toString() + File.separator + "coordinator.xml");
+ .replaceAll("#app_path2", new Path(coordPath2.toString(), "coordinator.xml").toString());
writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
Configuration conf = new XConfiguration();
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/test/XFsTestCase.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/XFsTestCase.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/XFsTestCase.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/XFsTestCase.java Mon Sep 30 23:00:16 2013
@@ -72,7 +72,7 @@ public abstract class XFsTestCase extend
JobConf jobConf = has.createJobConf(getNameNodeUri());
XConfiguration.copy(conf, jobConf);
fileSystem = has.createFileSystem(getTestUser(), new URI(getNameNodeUri()), jobConf);
- Path path = new Path(fileSystem.getWorkingDirectory(), getTestCaseDir().substring(1));
+ Path path = new Path(fileSystem.getWorkingDirectory(), java.util.UUID.randomUUID().toString());
fsTestDir = fileSystem.makeQualified(path);
System.out.println(XLog.format("Setting FS testcase work dir[{0}]", fsTestDir));
if (fileSystem.exists(fsTestDir)) {
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/test/XHCatTestCase.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/XHCatTestCase.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/XHCatTestCase.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/XHCatTestCase.java Mon Sep 30 23:00:16 2013
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.util.Shell;
import org.apache.hcatalog.api.HCatPartition;
import org.apache.oozie.util.HCatURI;
@@ -61,7 +62,7 @@ public abstract class XHCatTestCase exte
protected void createDatabase(String db) throws Exception {
if (db.equals("default"))
return;
- hcatServer.createDatabase(db, getTestCaseDir());
+ hcatServer.createDatabase(db, getSanitizedTestCaseDir());
}
protected void createTable(String db, String table, String partitionCols) throws Exception {
@@ -79,7 +80,7 @@ public abstract class XHCatTestCase exte
}
protected String getPartitionDir(String db, String table, String partitionSpec) throws Exception {
- return hcatServer.getPartitionDir(db, table, partitionSpec, getTestCaseDir());
+ return hcatServer.getPartitionDir(db, table, partitionSpec, getSanitizedTestCaseDir()).toString();
}
/**
@@ -91,11 +92,22 @@ public abstract class XHCatTestCase exte
* @throws Exception
*/
protected String addPartition(String db, String table, String partitionSpec) throws Exception {
- String location = hcatServer.createPartitionDir(db, table, partitionSpec, getTestCaseDir());
+ String location = hcatServer.createPartitionDir(db, table, partitionSpec, getSanitizedTestCaseDir());
hcatServer.addPartition(db, table, partitionSpec, location);
return location;
}
+ protected String getSanitizedTestCaseDir() {
+ // On Windows, the working directory will have a colon from to the drive letter. Because colons
+ // are not allowed in DFS paths, we remove it. Also, prepend a backslash to simulate an absolute path.
+ if(Shell.WINDOWS) {
+ return "\\" + getTestCaseDir().replaceAll(":", "");
+ }
+ else {
+ return getTestCaseDir();
+ }
+ }
+
protected void dropPartition(String db, String table, String partitionSpec) throws Exception {
hcatServer.dropPartition(db, table, partitionSpec);
}
Modified: oozie/trunk/core/src/test/java/org/apache/oozie/test/XTestCase.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/test/XTestCase.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/core/src/test/java/org/apache/oozie/test/XTestCase.java (original)
+++ oozie/trunk/core/src/test/java/org/apache/oozie/test/XTestCase.java Mon Sep 30 23:00:16 2013
@@ -49,6 +49,7 @@ import org.apache.hadoop.hdfs.MiniDFSClu
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.MiniMRCluster;
import org.apache.hadoop.security.authorize.ProxyUsers;
+import org.apache.hadoop.util.Shell;
import org.apache.oozie.BundleActionBean;
import org.apache.oozie.BundleJobBean;
import org.apache.oozie.CoordinatorActionBean;
@@ -135,7 +136,7 @@ public abstract class XTestCase extends
OOZIE_SRC_DIR = OOZIE_SRC_DIR.getParentFile();
String testPropsFile = System.getProperty(OOZIE_TEST_PROPERTIES, "test.properties");
- File file = (testPropsFile.startsWith("/"))
+ File file = new File(testPropsFile).isAbsolute()
? new File(testPropsFile) : new File(OOZIE_SRC_DIR, testPropsFile);
if (file.exists()) {
System.out.println();
@@ -240,6 +241,21 @@ public abstract class XTestCase extends
public static final String TEST_MINICLUSTER_MONITOR_SHUTDOWN_WAIT = "oozie.test.minicluster.monitor.shutdown.wait";
/**
+ * Name of the shell command
+ */
+ protected static final String SHELL_COMMAND_NAME = (Shell.WINDOWS)? "cmd": "bash";
+
+ /**
+ * Extension for shell script files
+ */
+ protected static final String SHELL_COMMAND_SCRIPTFILE_EXTENSION = (Shell.WINDOWS)? "cmd": "sh";
+
+ /**
+ * Option for shell command to pass script files
+ */
+ protected static final String SHELL_COMMAND_SCRIPTFILE_OPTION = (Shell.WINDOWS) ? "/c" : "-c";
+
+ /**
* 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/>
*
@@ -251,7 +267,8 @@ public abstract class XTestCase extends
super.setUp();
String baseDir = System.getProperty(OOZIE_TEST_DIR, new File("target/test-data").getAbsolutePath());
String msg = null;
- if (!baseDir.startsWith("/")) {
+ File f = new File(baseDir);
+ if (!f.isAbsolute()) {
msg = XLog.format("System property [{0}]=[{1}] must be set to an absolute path", OOZIE_TEST_DIR, baseDir);
}
else {
@@ -264,7 +281,6 @@ public abstract class XTestCase extends
System.err.println(msg);
System.exit(-1);
}
- File f = new File(baseDir);
f.mkdirs();
if (!f.exists() || !f.isDirectory()) {
System.err.println();
@@ -284,8 +300,10 @@ public abstract class XTestCase extends
String defaultOozieSize =
new File(OOZIE_SRC_DIR, "core/src/test/resources/" + oozieTestDB + "-oozie-site.xml").getAbsolutePath();
String customOozieSite = System.getProperty("oozie.test.config.file", defaultOozieSize);
- File source = (customOozieSite.startsWith("/"))
- ? new File(customOozieSite) : new File(OOZIE_SRC_DIR, customOozieSite);
+ File source = new File(customOozieSite);
+ if(!source.isAbsolute()) {
+ source = new File(OOZIE_SRC_DIR, customOozieSite);
+ }
source = source.getAbsoluteFile();
InputStream oozieSiteSourceStream = null;
if (source.exists()) {
@@ -393,6 +411,24 @@ public abstract class XTestCase extends
}
/**
+ * Return the URI for a test file. The returned value is the testDir + concatenated URI.
+ *
+ * @return the test working directory path, it is always an absolute path and appends the relative path. The
+ * reason for the manual parsing instead of an actual File.toURI is because Oozie tests use tokens ${}
+ * frequently. Something like URI("c:/temp/${HOUR}").toString() will generate escaped values that will break tests
+ */
+ protected String getTestCaseFileUri(String relativeUri) {
+ String uri = new File(testCaseDir).toURI().toString();
+
+ // truncates '/' if the testCaseDir was provided with a fullpath ended with separator
+ if (uri.endsWith("/")){
+ uri = uri.substring(0, uri.length() -1);
+ }
+
+ return uri + "/" + relativeUri;
+ }
+
+ /**
* Return the Oozie configuration directory for the testcase.
*
* @return the Oozie configuration directory for the testcase.
@@ -528,12 +564,21 @@ public abstract class XTestCase extends
/**
* Create a Test case sub directory.
*
- * @param subDirName sub directory name.
+ * @param subDirNames a list of progressively deeper directory names
* @return the absolute path to the created directory.
*/
- protected String createTestCaseSubDir(String subDirName) {
- ParamChecker.notNull(subDirName, "subDirName");
- File dir = new File(testCaseDir, subDirName);
+ protected String createTestCaseSubDir(String... subDirNames) {
+ ParamChecker.notNull(subDirNames, "subDirName");
+ if (subDirNames.length == 0) {
+ throw new RuntimeException(XLog.format("Could not create testcase subdir ''; it already exists"));
+ }
+
+ File dir = new File(testCaseDir);
+ for (int i = 0; i < subDirNames.length; i++) {
+ ParamChecker.notNull(subDirNames[i], "subDirName[" + i + "]");
+ dir = new File(dir, subDirNames[i]);
+ }
+
if (!dir.mkdirs()) {
throw new RuntimeException(XLog.format("Could not create testcase subdir[{0}]", dir));
}
Modified: oozie/trunk/examples/src/main/java/org/apache/oozie/example/LocalOozieExample.java
URL: http://svn.apache.org/viewvc/oozie/trunk/examples/src/main/java/org/apache/oozie/example/LocalOozieExample.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/examples/src/main/java/org/apache/oozie/example/LocalOozieExample.java (original)
+++ oozie/trunk/examples/src/main/java/org/apache/oozie/example/LocalOozieExample.java Mon Sep 30 23:00:16 2013
@@ -26,6 +26,7 @@ import java.io.FileInputStream;
import java.io.File;
import java.util.Properties;
import java.text.MessageFormat;
+import org.apache.hadoop.fs.Path;
public class LocalOozieExample {
@@ -64,7 +65,7 @@ public class LocalOozieExample {
// create a workflow job configuration and set the workflow application path
Properties conf = wc.createConfiguration();
- conf.setProperty(OozieClient.APP_PATH, appUri + File.separator + "workflow.xml");
+ conf.setProperty(OozieClient.APP_PATH, new Path(appUri, "workflow.xml").toString());
// load additional workflow job parameters from properties file
if (propertiesFile != null) {
conf.load(new FileInputStream(propertiesFile));
Modified: oozie/trunk/minitest/src/test/java/org/apache/oozie/test/WorkflowTest.java
URL: http://svn.apache.org/viewvc/oozie/trunk/minitest/src/test/java/org/apache/oozie/test/WorkflowTest.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/minitest/src/test/java/org/apache/oozie/test/WorkflowTest.java (original)
+++ oozie/trunk/minitest/src/test/java/org/apache/oozie/test/WorkflowTest.java Mon Sep 30 23:00:16 2013
@@ -67,7 +67,7 @@ public class WorkflowTest extends MiniOo
final OozieClient wc = LocalOozie.getClient();
Properties conf = wc.createConfiguration();
- conf.setProperty(OozieClient.APP_PATH, appPath.toString() + File.separator + "workflow.xml");
+ conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
conf.setProperty(OozieClient.USER_NAME, getTestUser());
@@ -110,7 +110,7 @@ public class WorkflowTest extends MiniOo
final OozieClient wc = LocalOozie.getClient();
Properties conf = wc.createConfiguration();
- conf.setProperty(OozieClient.APP_PATH, appPath.toString() + File.separator + "workflow.xml");
+ conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
conf.setProperty(OozieClient.USER_NAME, getTestUser());
conf.setProperty("nnbase", path.toString());
conf.setProperty("base", path.toUri().getPath());
Modified: oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Mon Sep 30 23:00:16 2013
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+OOZIE-1500 Fix many OS-specific issues on Windows (dwann via rohini)
OOZIE-1556 Change Bundle SELECT query to fetch only necessary columns and consolidate JPA Executors (ryota)
OOZIE-1523 Create Windows versions of the shell scripts (dwann via rkanter)
OOZIE-1558 RAT Warning from BundleActionsGetJPAExecutor.java (rkanter)
Modified: oozie/trunk/sharelib/hive/src/main/java/org/apache/oozie/action/hadoop/HiveMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/hive/src/main/java/org/apache/oozie/action/hadoop/HiveMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/hive/src/main/java/org/apache/oozie/action/hadoop/HiveMain.java (original)
+++ oozie/trunk/sharelib/hive/src/main/java/org/apache/oozie/action/hadoop/HiveMain.java Mon Sep 30 23:00:16 2013
@@ -84,7 +84,7 @@ public class HiveMain extends LauncherMa
hiveConf.addResource(new Path("file:///", actionXml));
// Propagate delegation related props from launcher job to Hive job
- String delegationToken = System.getenv("HADOOP_TOKEN_FILE_LOCATION");
+ String delegationToken = getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION");
if (delegationToken != null) {
hiveConf.set("mapreduce.job.credentials.binary", delegationToken);
System.out.println("------------------------");
Modified: oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java (original)
+++ oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/LauncherMain.java Mon Sep 30 23:00:16 2013
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.hadoop.util.Shell;
public abstract class LauncherMain {
@@ -97,6 +98,23 @@ public abstract class LauncherMain {
System.out.flush();
}
+ /**
+ * Get file path from the given environment
+ */
+ protected static String getFilePathFromEnv(String env) {
+ String path = System.getenv(env);
+ if (path != null && Shell.WINDOWS) {
+ // In Windows, file paths are enclosed in \" so remove them here
+ // to avoid path errors
+ if(path.charAt(0)=='"') {
+ path = path.substring(1);
+ }
+ if(path.charAt(path.length()-1) == '"') {
+ path = path.substring(0, path.length()-1);
+ }
+ }
+ return path;
+ }
}
class LauncherMainException extends Exception {
Modified: oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java (original)
+++ oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/MapReduceMain.java Mon Sep 30 23:00:16 2013
@@ -81,8 +81,8 @@ public class MapReduceMain extends Launc
}
// propagate delegation related props from launcher job to MR job
- if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
- jobConf.set("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ if (getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION") != null) {
+ jobConf.set("mapreduce.job.credentials.binary", getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION"));
}
JobClient jobClient = null;
RunningJob runJob = null;
Modified: oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PipesMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PipesMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PipesMain.java (original)
+++ oozie/trunk/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PipesMain.java Mon Sep 30 23:00:16 2013
@@ -69,8 +69,8 @@ public class PipesMain extends MapReduce
addActionConf(jobConf, actionConf);
//propagate delegation related props from launcher job to MR job
- if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
- jobConf.set("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ if (getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION") != null) {
+ jobConf.set("mapreduce.job.credentials.binary", getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION"));
}
return Submitter.jobSubmit(jobConf);
Modified: oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMain.java (original)
+++ oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMain.java Mon Sep 30 23:00:16 2013
@@ -102,13 +102,14 @@ public class PigMain extends LauncherMai
}
// propagate delegation related props from launcher job to Pig job
- if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
- pigProperties.setProperty("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ String jobTokenFile = getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION");
+ if (jobTokenFile != null) {
+ pigProperties.setProperty("mapreduce.job.credentials.binary", jobTokenFile);
System.out.println("------------------------");
System.out.println("Setting env property for mapreduce.job.credentials.binary to:"
- + System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ + jobTokenFile);
System.out.println("------------------------");
- System.setProperty("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ System.setProperty("mapreduce.job.credentials.binary", jobTokenFile);
}
else {
System.out.println("Non-kerberoes execution");
Modified: oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMainWithOldAPI.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMainWithOldAPI.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMainWithOldAPI.java (original)
+++ oozie/trunk/sharelib/pig/src/main/java/org/apache/oozie/action/hadoop/PigMainWithOldAPI.java Mon Sep 30 23:00:16 2013
@@ -85,13 +85,14 @@ public class PigMainWithOldAPI extends L
}
//propagate delegation related props from launcher job to Pig job
- if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
- pigProperties.setProperty("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ String jobTokenFile = getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION");
+ if (jobTokenFile != null) {
+ pigProperties.setProperty("mapreduce.job.credentials.binary", jobTokenFile);
System.out.println("------------------------");
System.out.println("Setting env property for mapreduce.job.credentials.binary to:"
- + System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ + jobTokenFile);
System.out.println("------------------------");
- System.setProperty("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ System.setProperty("mapreduce.job.credentials.binary", jobTokenFile);
}
else {
System.out.println("Non-kerberoes execution");
Modified: oozie/trunk/sharelib/sqoop/src/main/java/org/apache/oozie/action/hadoop/SqoopMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/sqoop/src/main/java/org/apache/oozie/action/hadoop/SqoopMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/sqoop/src/main/java/org/apache/oozie/action/hadoop/SqoopMain.java (original)
+++ oozie/trunk/sharelib/sqoop/src/main/java/org/apache/oozie/action/hadoop/SqoopMain.java Mon Sep 30 23:00:16 2013
@@ -60,7 +60,7 @@ public class SqoopMain extends LauncherM
sqoopConf.addResource(new Path("file:///", actionXml));
- String delegationToken = System.getenv("HADOOP_TOKEN_FILE_LOCATION");
+ String delegationToken = getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION");
if (delegationToken != null) {
sqoopConf.set("mapreduce.job.credentials.binary", delegationToken);
System.out.println("------------------------");
Modified: oozie/trunk/sharelib/streaming/src/main/java/org/apache/oozie/action/hadoop/StreamingMain.java
URL: http://svn.apache.org/viewvc/oozie/trunk/sharelib/streaming/src/main/java/org/apache/oozie/action/hadoop/StreamingMain.java?rev=1527818&r1=1527817&r2=1527818&view=diff
==============================================================================
--- oozie/trunk/sharelib/streaming/src/main/java/org/apache/oozie/action/hadoop/StreamingMain.java (original)
+++ oozie/trunk/sharelib/streaming/src/main/java/org/apache/oozie/action/hadoop/StreamingMain.java Mon Sep 30 23:00:16 2013
@@ -75,8 +75,8 @@ public class StreamingMain extends MapRe
addActionConf(jobConf, actionConf);
// propagate delegation related props from launcher job to MR job
- if (System.getenv("HADOOP_TOKEN_FILE_LOCATION") != null) {
- jobConf.set("mapreduce.job.credentials.binary", System.getenv("HADOOP_TOKEN_FILE_LOCATION"));
+ if (getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION") != null) {
+ jobConf.set("mapreduce.job.credentials.binary", getFilePathFromEnv("HADOOP_TOKEN_FILE_LOCATION"));
}
JobClient jobClient = null;