Beispiel #1
0
  /**
   * Basic test
   *
   * @throws Exception
   */
  public void testBasicSubmit() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseDir();
    String appXml =
        "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
            + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <concurrency>2</concurrency> "
            + "<execution>LIFO</execution> </controls> <datasets> "
            + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
            + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
            + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
            + "timezone=\"UTC\"> <uri-template>file:///tmp/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, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set(OozieClient.GROUP_NAME, "other");
    CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");
    String jobId = sc.call();

    assertEquals(jobId.substring(jobId.length() - 2), "-C");
    CoordinatorJobBean job = checkCoordJobs(jobId);
    if (job != null) {
      assertEquals(
          job.getTimeout(),
          Services.get().getConf().getInt("oozie.service.coord.normal.default.timeout", -2));
    }
  }
Beispiel #2
0
 /**
  * test schema error. Negative test case.
  *
  * @throws Exception
  */
 public void testSchemaError() throws Exception {
   Configuration conf = new XConfiguration();
   String appPath = getTestCaseDir();
   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.1\"> <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>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
           + "<dataset name=\"local_a\" frequency=\"120\" initial-instance=\"2009-02-01T01:00Z\" "
           + "timezone=\"UTC\"> <uri-template>file:///tmp/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, appPath);
   conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
   conf.set(OozieClient.USER_NAME, getTestUser());
   conf.set(OozieClient.GROUP_NAME, "other");
   CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");
   String jobId = null;
   try {
     sc.call();
     fail("Exception expected if schema has errors!");
   } catch (CommandException e) {
     // should come here for schema errors
   }
 }
Beispiel #3
0
  /**
   * Basic test
   *
   * @throws Exception
   */
  public void testBasicSubmitWithSLA() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseDir();
    String appXml =
        "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
            + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.1' xmlns:sla='uri:oozie:sla:0.1'> <controls> <timeout>10</timeout> <concurrency>2</concurrency> "
            + "<execution>LIFO</execution> </controls> <datasets> "
            + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
            + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
            + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
            + "timezone=\"UTC\"> <uri-template>file:///tmp/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> "
            + " <sla:info>"
            + " <sla:app-name>test-app</sla:app-name>"
            + " <sla:nominal-time>${coord:nominalTime()}</sla:nominal-time>"
            + " <sla:should-start>${5 * MINUTES}</sla:should-start>"
            + " <sla:should-end>${2 * HOURS}</sla:should-end>"
            + " <sla:notification-msg>Notifying User for ${coord:nominalTime()} nominal time </sla:notification-msg>"
            + " <sla:alert-contact>[email protected]</sla:alert-contact>"
            + " <sla:dev-contact>[email protected]</sla:dev-contact>"
            + " <sla:qa-contact>[email protected]</sla:qa-contact>"
            + " <sla:se-contact>[email protected]</sla:se-contact>"
            + " <sla:alert-frequency>LAST_HOUR</sla:alert-frequency>"
            + " <sla:alert-percentage>10</sla:alert-percentage>"
            + "</sla:info>"
            + "</action> </coordinator-app>";
    // /System.out.println("MMMMM\n"+ appXml);
    writeToFile(appXml, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set(OozieClient.GROUP_NAME, "other");
    CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");
    String jobId = sc.call();

    assertEquals(jobId.substring(jobId.length() - 2), "-C");
    checkCoordJobs(jobId);
  }
Beispiel #4
0
  /**
   * Don't include controls in XML.
   *
   * @throws Exception
   */
  public void testSubmitNoControls() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseDir();
    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.1\"> "
            + "<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, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set(OozieClient.GROUP_NAME, "other");
    CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");
    String jobId = sc.call();

    assertEquals(jobId.substring(jobId.length() - 2), "-C");
    checkCoordJobs(jobId);
  }
Beispiel #5
0
  /**
   * Don't include controls in XML.
   *
   * @throws Exception
   */
  public void testSubmitReservedVars() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseDir();
    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.1\"> "
            + "<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, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set(OozieClient.GROUP_NAME, "other");
    conf.set("MINUTES", "1");
    CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");

    try {
      sc.call();
      fail("Coord job submission should fail with reserved variable definitions.");
    } catch (CommandException ce) {

    }
  }
Beispiel #6
0
 /**
  * Don't include username. Negative test case.
  *
  * @throws Exception
  */
 public void testSubmitNoUsername() throws Exception {
   Configuration conf = new XConfiguration();
   String appPath = getTestCaseDir();
   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.1\"> "
           + "<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, appPath);
   conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
   // conf.set(OozieClient.USER_NAME, getTestUser());
   conf.set(OozieClient.GROUP_NAME, "other");
   CoordSubmitCommand sc = new CoordSubmitCommand(conf, "UNIT_TESTING");
   String jobId = null;
   try {
     sc.call();
     fail("Exception expected if user.name is not set!");
   } catch (CommandException e) {
     // should come here
   }
 }