You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2012/08/27 08:27:22 UTC
svn commit: r1377577 - in /incubator/oozie/trunk:
core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
release-log.txt
Author: virag
Date: Mon Aug 27 06:27:21 2012
New Revision: 1377577
URL: http://svn.apache.org/viewvc?rev=1377577&view=rev
Log:
OOZIE-960 TestStatusTransitService failing intermittently (virag)
Modified:
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
incubator/oozie/trunk/release-log.txt
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java?rev=1377577&r1=1377576&r2=1377577&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/service/TestStatusTransitService.java Mon Aug 27 06:27:21 2012
@@ -38,9 +38,11 @@ import org.apache.oozie.command.coord.Co
import org.apache.oozie.command.coord.CoordSuspendXCommand;
import org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor;
import org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor;
+import org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor;
import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
import org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
+import org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobUpdateJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor;
@@ -61,6 +63,7 @@ public class TestStatusTransitService ex
protected void setUp() throws Exception {
super.setUp();
services = new Services();
+ setClassesToBeExcluded(services.getConf());
services.init();
cleanUpDBTables();
}
@@ -71,6 +74,22 @@ public class TestStatusTransitService ex
super.tearDown();
}
+ // Exclude some of the services classes from loading so they dont interfere while the test case is running
+ private void setClassesToBeExcluded(Configuration conf) {
+ String classes = conf.get(Services.CONF_SERVICE_CLASSES);
+ StringBuilder builder = new StringBuilder(classes);
+ String[] excludedService = { "org.apache.oozie.service.StatusTransitService",
+ "org.apache.oozie.service.PauseTransitService",
+ "org.apache.oozie.service.CoordMaterializeTriggerService", "org.apache.oozie.service.RecoveryService" };
+ for (String s : excludedService) {
+ int index = builder.indexOf(s);
+ if (index != -1) {
+ builder.replace(index, index + s.length() + 1, "");
+ }
+ }
+ conf.set(Services.CONF_SERVICE_CLASSES, new String(builder));
+ }
+
/**
* Tests functionality of the StatusTransitService Runnable command. </p> Insert a coordinator job with RUNNING and
* pending true and coordinator actions with pending false. Then, runs the StatusTransitService runnable and ensures
@@ -135,7 +154,9 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServiceNoDoneWithErrorForBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_COORD_STATUS, "true");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
@@ -302,8 +323,8 @@ public class TestStatusTransitService ex
Runnable runnable = new StatusTransitRunnable();
runnable.run();
- // Keeping wait time to 10s to ensure status is updated
- waitFor(10 * 1000, new Predicate() {
+ // Keeping wait time to 20s to ensure status is updated
+ waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.getStatus() == CoordinatorJob.Status.SUSPENDED;
@@ -324,14 +345,16 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServiceSuspendedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 4);
- addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
- addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
final String jobId = job.getId();
@@ -340,8 +363,8 @@ public class TestStatusTransitService ex
Runnable runnable = new StatusTransitRunnable();
runnable.run();
- // Keeping wait time to 10s to ensure status is updated
- waitFor(15 * 1000, new Predicate() {
+ // Keeping wait time to 20s to ensure status is updated
+ waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
return coordJob.getStatus() == CoordinatorJob.Status.SUSPENDEDWITHERROR;
@@ -394,7 +417,7 @@ public class TestStatusTransitService ex
Runnable runnable = new StatusTransitRunnable();
runnable.run();
- waitFor(10 * 1000, new Predicate() {
+ waitFor(20 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId));
return job.getStatus().equals(Job.Status.SUCCEEDED);
@@ -483,7 +506,9 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServiceBackwardSupport() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "true");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, false, 3);
@@ -520,7 +545,9 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServiceRunning3() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, false, 3);
@@ -557,17 +584,23 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServicePaused() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
- CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSED, start, end, true, false, 3);
- addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
- addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
- addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
-
- final String jobId = job.getId();
+ CoordinatorJobBean coordJob = createCoordJob(CoordinatorJob.Status.PAUSED, start, end, true, false, 3);
+ // set some pause time explicity to make sure the job is not unpaused
+ coordJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
- assertNotNull(jpaService);
+ CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
+ jpaService.execute(coordInsertCmd);
+
+ addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+
+ final String jobId = coordJob.getId();
Runnable runnable = new StatusTransitRunnable();
runnable.run();
@@ -578,10 +611,10 @@ public class TestStatusTransitService ex
}
});
- CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
- job = jpaService.execute(coordGetCmd);
- assertFalse(job.isPending());
- assertEquals(job.getStatus(), Job.Status.PAUSEDWITHERROR);
+ CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
+ coordJob = jpaService.execute(coordGetCmd);
+ assertFalse(coordJob.isPending());
+ assertEquals(CoordinatorJob.Status.PAUSEDWITHERROR, coordJob.getStatus());
}
/**
@@ -592,16 +625,24 @@ public class TestStatusTransitService ex
public void testCoordStatusTransitServicePausedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
- CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, start, end, true, false, 3);
+
+ CoordinatorJobBean job = createCoordJob(CoordinatorJob.Status.PAUSEDWITHERROR, start, end, true, false, 3);
+ // set the pause time explicity to make sure the job is not unpaused
+ job.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
+ final JPAService jpaService = Services.get().get(JPAService.class);
+ CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(job);
+ jpaService.execute(coordInsertCmd);
+
addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final String jobId = job.getId();
- final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Runnable runnable = new StatusTransitRunnable();
@@ -616,7 +657,7 @@ public class TestStatusTransitService ex
CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
job = jpaService.execute(coordGetCmd);
assertFalse(job.isPending());
- assertEquals(job.getStatus(), Job.Status.PAUSED);
+ assertEquals(CoordinatorJob.Status.PAUSED, job.getStatus());
}
/**
* Tests functionality of the StatusTransitService Runnable command. </p> Insert a coordinator job with RUNNING and
@@ -647,7 +688,6 @@ public class TestStatusTransitService ex
protected CoordinatorActionBean addRecordToCoordActionTable(String jobId, int actionNum,
CoordinatorAction.Status status, String resourceXmlName, int pending) throws Exception {
CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, pending);
- action.decrementAndGetPending();
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
@@ -718,7 +758,7 @@ public class TestStatusTransitService ex
Runnable runnable = new StatusTransitRunnable();
runnable.run();
- waitFor(5 * 1000, new Predicate() {
+ waitFor(15 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
return bundle.getStatus().equals(Job.Status.SUCCEEDED);
@@ -742,15 +782,15 @@ public class TestStatusTransitService ex
final String bundleId = job.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.RUNNING);
- addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.SUCCEEDED);
+ addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.RUNNING);
addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.RUNNING, true, true, 2);
- addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.SUCCEEDED, true, true, 2);
+ addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, true, true, 2);
- addRecordToCoordActionTable("action1", 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
- addRecordToCoordActionTable("action1", 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable("action1", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable("action1", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
- addRecordToCoordActionTable("action2", 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
+ addRecordToCoordActionTable("action2", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
addRecordToCoordActionTable("action2", 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
new BundleJobSuspendXCommand(bundleId).call();
@@ -765,22 +805,7 @@ public class TestStatusTransitService ex
new BundleJobResumeXCommand(bundleId).call();
job = jpaService.execute(bundleJobGetCmd);
- assertTrue(job.getStatus() == Job.Status.SUCCEEDED || job.getStatus() == Job.Status.RUNNING);
-
- sleep(3000);
-
- Runnable runnable = new StatusTransitRunnable();
- runnable.run();
-
- waitFor(5 * 1000, new Predicate() {
- public boolean evaluate() throws Exception {
- BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
- return bundle.getStatus().equals(Job.Status.SUCCEEDED);
- }
- });
-
- job = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
- assertEquals(Job.Status.SUCCEEDED, job.getStatus());
+ assertEquals(Job.Status.RUNNING, job.getStatus());
}
/**
@@ -872,7 +897,9 @@ public class TestStatusTransitService ex
public void testBundleStatusTransitServiceRunningWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
@@ -882,7 +909,7 @@ public class TestStatusTransitService ex
addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.RUNNING);
addRecordToCoordJobTableWithBundle(bundleId, "action1", CoordinatorJob.Status.RUNNING, false, true, 2);
- addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, false, false, 2);
+ addRecordToCoordJobTableWithBundle(bundleId, "action2", CoordinatorJob.Status.RUNNING, true, false, 2);
final CoordinatorActionBean coordAction1_1 = addRecordToCoordActionTable("action1", 1,
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
@@ -890,9 +917,9 @@ public class TestStatusTransitService ex
CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
final CoordinatorActionBean coordAction1_3 = addRecordToCoordActionTable("action2", 1,
- CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+ CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 1);
final CoordinatorActionBean coordAction1_4 = addRecordToCoordActionTable("action2", 2,
- CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
+ CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 1);
this.addRecordToWfJobTable(coordAction1_1.getExternalId(), WorkflowJob.Status.RUNNING,
WorkflowInstance.Status.RUNNING);
@@ -908,7 +935,7 @@ public class TestStatusTransitService ex
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowJobBean wfJob = jpaService
- .execute(new WorkflowJobGetJPAExecutor(coordAction1_4.getExternalId()));
+ .execute(new WorkflowJobGetJPAExecutor(coordAction1_1.getExternalId()));
return wfJob.getStatus().equals(Job.Status.KILLED);
}
});
@@ -1033,7 +1060,9 @@ public class TestStatusTransitService ex
public void testBundleStatusTransitServiceSuspendedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
@@ -1065,10 +1094,14 @@ public class TestStatusTransitService ex
public void testBundleStatusTransitServicePausedWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
- BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.PAUSED, true);
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
+ BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSED, true);
+ bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
- assertNotNull(jpaService);
+ BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
+ jpaService.execute(bundleInsertjpa);
final String bundleId = bundleJob.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
@@ -1097,10 +1130,14 @@ public class TestStatusTransitService ex
public void testBundleStatusTransitServicePaused() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
- new Services().init();
- BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.PAUSEDWITHERROR, true);
+ Services services = new Services();
+ setClassesToBeExcluded(services.getConf());
+ services.init();
+ BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSEDWITHERROR, true);
+ bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
final JPAService jpaService = Services.get().get(JPAService.class);
- assertNotNull(jpaService);
+ BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
+ jpaService.execute(bundleInsertjpa);
final String bundleId = bundleJob.getId();
addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1377577&r1=1377576&r2=1377577&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Mon Aug 27 06:27:21 2012
@@ -1,5 +1,6 @@
-- Oozie 3.3.0 release (trunk - unreleased)
+OOZIE-960 TestStatusTransitService failing intermittently (virag)
OOZIE-968 source oozie environment from conf in oozie db setup script (svenkat via virag)
OOZIE-944 Implement Workflow Generator UI Tool (egashira via virag)
OOZIE-961 Load Hbase credentials in Oozie (virag)