Search in sources :

Example 46 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestCoordSubmitXCommand method testBasicSubmitWithMultipleStartInstancesInputEvent.

/**
 * Testing for when user tries to submit a coordinator application having data-in events
 * that erroneously specify multiple input data instances inside a single <start-instance> tag.
 * Job gives submission error and indicates appropriate correction
 * Testing both negative(error) and well as positive(success) cases
 */
public void testBasicSubmitWithMultipleStartInstancesInputEvent() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    // CASE 1: Failure case i.e. multiple data-in start-instances
    Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-start-instance1.xml", -1);
    Writer writer = new FileWriter(new File(getTestCaseDir(), "coordinator.xml"));
    IOUtils.copyCharStream(reader, writer);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    try {
        sc.call();
        fail("Expected to catch errors due to incorrectly specified input data set start-instances");
    } catch (CommandException e) {
        assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
        assertEquals(e.getErrorCode(), ErrorCode.E1021);
        assertTrue(e.getMessage().contains(sc.COORD_INPUT_EVENTS) && e.getMessage().contains("Coordinator app definition should not have multiple start-instances"));
    }
    // CASE 2: Success case i.e. Single start instances for input and single start instance for output, but both with ","
    reader = IOUtils.getResourceAsReader("coord-multiple-input-start-instance2.xml", -1);
    writer = new FileWriter(appPathFile);
    IOUtils.copyCharStream(reader, writer);
    sc = new CoordSubmitXCommand(conf);
    try {
        sc.call();
    } catch (CommandException e) {
        fail("Unexpected failure: " + e);
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) Reader(java.io.Reader) CommandException(org.apache.oozie.command.CommandException) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 47 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestCoordSubmitXCommand method testSubmitReservedVars.

/**
 * Don't include controls in XML.
 *
 * @throws Exception
 */
public void testSubmitReservedVars() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>blah</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set("MINUTES", "1");
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    try {
        sc.call();
        fail("Coord job submission should fail with reserved variable definitions.");
    } catch (CommandException ce) {
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CommandException(org.apache.oozie.command.CommandException) File(java.io.File)

Example 48 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestCoordSubmitXCommand method testSchemaError.

/**
 * test schema error. Negative test case.
 *
 * @throws Exception
 */
public void testSchemaError() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequencyERROR=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"60\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>" + "  </dataset> " + "<dataset name=\"local_a\" frequency=\"120\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>" + "  </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in>  " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow>" + " <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    try {
        sc.call();
        fail("Exception expected if schema has errors!");
    } catch (CommandException e) {
    // should come here for schema errors
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CommandException(org.apache.oozie.command.CommandException) File(java.io.File)

Example 49 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestCoordSubmitXCommand method testSubmitNoDatasets.

/**
 * Don't include datasets, input-events, or output-events in XML.
 *
 * @throws Exception
 */
public void testSubmitNoDatasets() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"10\" start=\"2009-02-01T01:00Z\"" + " end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> " + "<controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>blah</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    String jobId = sc.call();
    assertEquals(jobId.substring(jobId.length() - 2), "-C");
    checkCoordJobs(jobId);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) File(java.io.File)

Example 50 with XConfiguration

use of org.apache.oozie.util.XConfiguration in project oozie by apache.

the class TestCoordSubmitXCommand method testBasicSubmitWithUnMaterializableFrequency.

public void testBasicSubmitWithUnMaterializableFrequency() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"0/10 3 * * *\" start=\"2010-02-01T01:00Z\" " + "end=\"2010-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2010-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>  </dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2010-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template>  </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in>  " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow> " + "<app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    try {
        sc.call();
        fail("Expected to catch errors due to bad combination of frequency and start and end time");
    } catch (CommandException e) {
        assertEquals(sc.getJob().getStatus(), Job.Status.FAILED);
        assertEquals(e.getErrorCode(), ErrorCode.E1003);
        assertTrue(e.getMessage().contains("materializes no actions between start and end time."));
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CommandException(org.apache.oozie.command.CommandException) File(java.io.File)

Aggregations

XConfiguration (org.apache.oozie.util.XConfiguration)373 Configuration (org.apache.hadoop.conf.Configuration)241 Path (org.apache.hadoop.fs.Path)106 StringReader (java.io.StringReader)97 File (java.io.File)92 IOException (java.io.IOException)78 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)75 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)70 CommandException (org.apache.oozie.command.CommandException)68 Element (org.jdom.Element)66 Writer (java.io.Writer)58 Date (java.util.Date)50 FileSystem (org.apache.hadoop.fs.FileSystem)48 FileWriter (java.io.FileWriter)45 Reader (java.io.Reader)43 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)37 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)36 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)28 OutputStream (java.io.OutputStream)27 FileOutputStream (java.io.FileOutputStream)25