use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestCoordinatorEngine method _testSubsetActions.
private void _testSubsetActions(final String jobId) throws Exception {
CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
// Check for WAITING filter
CoordinatorJob job = ce.getCoordJob(jobId, "status=WAITING", 1, 2, false);
// As both actions are waiting, expected result size is 2
assertEquals(job.getActions().size(), 2);
job = ce.getCoordJob(jobId, "status=WAITING", 1, 0, false);
// Since length is 0, number of actions returned should be 0.
assertEquals(job.getActions().size(), 0);
job = ce.getCoordJob(jobId, "status=RUNNING", 1, 2, false);
assertEquals(job.getActions().size(), 0);
// Check for actions WAITING OR RUNNING
job = ce.getCoordJob(jobId, "status=RUNNING;status=WAITING", 1, 2, false);
assertEquals(job.getActions().size(), 2);
// Check without filters
job = ce.getCoordJob(jobId, null, 1, 2, false);
assertEquals(job.getActions().size(), 2);
// Check for empty filter list
job = ce.getCoordJob(jobId, "", 1, 2, false);
assertEquals(job.getActions().size(), 2);
// Check for negative filter
job = ce.getCoordJob(jobId, "status!=RUNNING", 1, 2, false);
assertEquals(job.getActions().size(), 2);
// Check for multiple negative filter
job = ce.getCoordJob(jobId, "status!=RUNNING;status!=WAITING", 1, 2, false);
assertEquals(job.getActions().size(), 0);
// Check for combination of positive and negative filter
try {
job = ce.getCoordJob(jobId, "status=WAITING;status!=WAITING", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [status=WAITING;status!=WAITING], the status [WAITING] " + "specified in both positive and negative filters", ex.getMessage());
}
// Check for missing "="
try {
job = ce.getCoordJob(jobId, "statusRUNNING", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [statusRUNNING], " + "filter should be of format <key><comparator><value> pairs", ex.getMessage());
}
// Check for missing value after "="
try {
job = ce.getCoordJob(jobId, "status=", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [status=], invalid status value []. Valid status values are: [" + StringUtils.join(CoordinatorAction.Status.values(), ", ") + "]", ex.getMessage());
}
// Check for invalid status value
try {
job = ce.getCoordJob(jobId, "status=blahblah", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [status=blahblah], invalid status value [blahblah]." + " Valid status values are: [" + StringUtils.join(CoordinatorAction.Status.values(), ", ") + "]", ex.getMessage());
}
// Check for empty status value
try {
job = ce.getCoordJob(jobId, "status=\"\"", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [status=\"\"], invalid status value [\"\"]." + " Valid status values are: [" + StringUtils.join(CoordinatorAction.Status.values(), ", ") + "]", ex.getMessage());
}
// Check for invalid filter option
try {
job = ce.getCoordJob(jobId, "blahblah=blahblah", 1, 2, false);
} catch (CoordinatorEngineException ex) {
assertEquals(ErrorCode.E0421, ex.getErrorCode());
assertEquals("E0421: Invalid job filter [blahblah=blahblah], invalid filter [blahblah]. " + "Valid filters [" + StringUtils.join(CoordinatorEngine.VALID_JOB_FILTERS, ", ") + "]", ex.getMessage());
}
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestCoordinatorEngine method _testGetJob.
private void _testGetJob(String jobId, String appPath) throws Exception {
CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
CoordinatorJob job = ce.getCoordJob(jobId);
assertEquals(jobId, job.getId());
assertEquals(job.getAppPath(), appPath);
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestLocalOozieClientCoord method testJobMethods.
public void testJobMethods() throws Exception {
final OozieClient client = LocalOozie.getCoordClient();
// Just in case, check that there are no Coord job records left by previous tests:
List<CoordinatorJob> list0 = client.getCoordJobsInfo("", 1, 100);
assertEquals(0, list0.size());
Properties conf = client.createConfiguration();
String appPath = getTestCaseFileUri("coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:minutes(20)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>1</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:minutes(20)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> </dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:minutes(20)}\" 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, appPath);
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, appPath);
String jobId0 = client.submit(conf);
client.kill(jobId0);
String jobId = client.run(conf);
client.suspend(jobId);
client.resume(jobId);
client.kill(jobId);
CoordinatorJob job = client.getCoordJobInfo(jobId);
String appName = job.getAppName();
assertEquals("NAME", appName);
List<CoordinatorJob> list = client.getCoordJobsInfo("", 1, 5);
assertEquals(2, list.size());
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestLocalOozieClientCoord method testJobsOperations.
public void testJobsOperations() throws Exception {
final OozieClient client = LocalOozie.getCoordClient();
// Just in case, check that there are no Coord job records left by previous tests:
List<CoordinatorJob> list0 = client.getCoordJobsInfo("", 1, 100);
assertEquals(0, list0.size());
Properties conf = client.createConfiguration();
String appPath = storedCoordAppPath();
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, appPath);
final String jobId0 = client.run(conf);
final String jobId1 = client.run(conf);
final String jobId2 = client.run(conf);
waitFor(client, jobId0);
waitFor(client, jobId1);
waitFor(client, jobId2);
list0 = client.getCoordJobsInfo("name=NAME", 1, 10);
assertEquals(3, list0.size());
JSONObject jsonObject = client.suspendJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.SUSPENDED, client.getCoordJobInfo(jobId2).getStatus());
jsonObject = client.resumeJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.RUNNING, client.getCoordJobInfo(jobId2).getStatus());
jsonObject = client.killJobs("name=NAME", "coord", 1, 3);
assertEquals(3, jsonObject.get("total"));
assertEquals(3, ((JSONArray) jsonObject.get("coordinatorjobs")).size());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId0).getStatus());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId1).getStatus());
assertEquals(Job.Status.KILLED, client.getCoordJobInfo(jobId2).getStatus());
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestBundleEngineSimple method testGetCoordJob1.
public void testGetCoordJob1() {
BundleEngine be = new BundleEngine();
try {
CoordinatorJob cj = be.getCoordJob("foo");
fail("Expected BundleEngineException was not thrown.");
} catch (BundleEngineException bee) {
assertEquals(ErrorCode.E0301, bee.getErrorCode());
}
}
Aggregations