Repository: oozie
Updated Branches:
  refs/heads/master d9f3b84d3 -> 8463f228d


OOZIE-3009 Number of Oozie tests executed dropped after OOZIE-2854 
(andras.piros via asasvari)


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/8463f228
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/8463f228
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/8463f228

Branch: refs/heads/master
Commit: 8463f228db5444b8eb85ca5d349fd9ab928934d1
Parents: d9f3b84
Author: Attila Sasvari <asasv...@cloudera.com>
Authored: Mon Jul 31 15:25:38 2017 +0200
Committer: Attila Sasvari <asasv...@cloudera.com>
Committed: Mon Jul 31 15:30:18 2017 +0200

----------------------------------------------------------------------
 .../org/apache/oozie/service/JPAService.java    |  4 +--
 .../apache/oozie/sla/SLARegistrationBean.java   |  4 ++-
 ...ceExceptionSubclassFilterRetryPredicate.java | 36 +++++++++++++++++---
 .../jpa/TestBundleJobsDeleteJPAExecutor.java    |  4 +--
 .../jpa/TestCoordActionsDeleteJPAExecutor.java  |  4 +--
 .../jpa/TestCoordJobsDeleteJPAExecutor.java     |  4 +--
 .../jpa/TestWorkflowJobsDeleteJPAExecutor.java  |  4 +--
 .../oozie/service/TestConfigurationService.java |  2 +-
 .../oozie/sla/TestSLACalculatorMemory.java      |  8 ++---
 .../java/org/apache/oozie/test/XTestCase.java   |  2 +-
 ...ceExceptionSubclassFilterRetryPredicate.java | 18 +++++++++-
 release-log.txt                                 |  1 +
 12 files changed, 68 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/main/java/org/apache/oozie/service/JPAService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/JPAService.java 
b/core/src/main/java/org/apache/oozie/service/JPAService.java
index 93fe9da..415dc96 100644
--- a/core/src/main/java/org/apache/oozie/service/JPAService.java
+++ b/core/src/main/java/org/apache/oozie/service/JPAService.java
@@ -374,10 +374,10 @@ public class JPAService implements Service, 
Instrumentable {
         }
     }
 
-    private void checkAndCommit(final EntityTransaction tx) {
+    private void checkAndCommit(final EntityTransaction tx) throws 
JPAExecutorException {
         if (tx.isActive()) {
             if (FaultInjection.isActive(SKIP_COMMIT_FAULT_INJECTION_CLASS)) {
-                throw new RuntimeException("Skipping Commit for Failover 
Testing");
+                throw new JPAExecutorException(ErrorCode.E0603, "Skipping 
Commit for Failover Testing");
             }
 
             tx.commit();

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/main/java/org/apache/oozie/sla/SLARegistrationBean.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/sla/SLARegistrationBean.java 
b/core/src/main/java/org/apache/oozie/sla/SLARegistrationBean.java
index 1b8370f..5eac78c 100644
--- a/core/src/main/java/org/apache/oozie/sla/SLARegistrationBean.java
+++ b/core/src/main/java/org/apache/oozie/sla/SLARegistrationBean.java
@@ -59,7 +59,9 @@ import org.json.simple.JSONObject;
 
  @NamedQuery(name = "GET_SLA_EXPECTED_VALUE_CONFIG", query = "select w.jobId, 
w.slaConfig, w.expectedStartTS, w.expectedEndTS, w.expectedDuration, 
w.nominalTimeTS from SLARegistrationBean w where w.jobId = :id"),
 
- @NamedQuery(name = "GET_SLA_REG_FOR_PARENT_ID", query = "select w.jobId, 
w.slaConfig from SLARegistrationBean w where w.parentId = :parentId")
+ @NamedQuery(name = "GET_SLA_REG_FOR_PARENT_ID", query = "select w.jobId, 
w.slaConfig from SLARegistrationBean w where w.parentId = :parentId"),
+
+ @NamedQuery(name = "GET_SLA_REGISTRATIONS", query = "select OBJECT(w) from 
SLARegistrationBean w")
  })
 
 public class SLARegistrationBean implements JsonBean {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/main/java/org/apache/oozie/util/db/PersistenceExceptionSubclassFilterRetryPredicate.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/oozie/util/db/PersistenceExceptionSubclassFilterRetryPredicate.java
 
b/core/src/main/java/org/apache/oozie/util/db/PersistenceExceptionSubclassFilterRetryPredicate.java
index b742ca7..ddf38d2 100644
--- 
a/core/src/main/java/org/apache/oozie/util/db/PersistenceExceptionSubclassFilterRetryPredicate.java
+++ 
b/core/src/main/java/org/apache/oozie/util/db/PersistenceExceptionSubclassFilterRetryPredicate.java
@@ -19,6 +19,7 @@
 package org.apache.oozie.util.db;
 
 import com.google.common.collect.Sets;
+import org.apache.oozie.executor.jpa.JPAExecutorException;
 import org.apache.oozie.util.XLog;
 
 import javax.persistence.EntityExistsException;
@@ -40,7 +41,13 @@ import java.util.Set;
  */
 public class PersistenceExceptionSubclassFilterRetryPredicate extends 
DatabaseRetryPredicate {
     private static final XLog LOG = 
XLog.getLog(PersistenceExceptionSubclassFilterRetryPredicate.class);
-    private static final Set<Class<? extends PersistenceException>> BLACKLIST 
= Sets.newHashSet(
+
+    /**
+     * If the {@code Throwable} to be checked has a cause chain, these {@code 
Exception} classes are used as blacklist: if one of
+     * them appear either at the top level, or down the cause chain, no retry 
will happen.
+     */
+    @SuppressWarnings("unchecked")
+    private static final Set<Class<? extends PersistenceException>> 
BLACKLIST_WITH_CAUSE = Sets.newHashSet(
             EntityExistsException.class,
             EntityNotFoundException.class,
             LockTimeoutException.class,
@@ -52,16 +59,35 @@ public class 
PersistenceExceptionSubclassFilterRetryPredicate extends DatabaseRe
             TransactionRequiredException.class
     );
 
+    /**
+     * If the {@code Throwable} to be checked doesn't have a cause, these 
{@code Exception} classes are used as blacklist: if one of
+     * them is assignable from the one to be checked, no retry will happen.
+     * <p/>
+     * Note that this blacklist is different from {@link 
#BLACKLIST_WITH_CAUSE} because this handles the use case where
+     * {@code Exception}s are inserted by a failure injection framework or 
piece of code rather than the database layer that is
+     * failing.
+     */
+    @SuppressWarnings("unchecked")
+    private static final Set<Class<? extends Exception>> 
BLACKLIST_WITHOUT_CAUSE = Sets.newHashSet(
+            JPAExecutorException.class,
+            RuntimeException.class
+    );
+
     @Override
     public boolean apply(final Throwable throwable) {
         LOG.trace("Retry predicate investigation started. 
[throwable.class={0}]", throwable.getClass().getName());
 
         boolean applies = true;
 
-        for (final Class<?> classDownTheStackTrace : 
getAllExceptions(throwable)) {
-            for (final Class<? extends PersistenceException> blacklistElement 
: BLACKLIST) {
-                if (blacklistElement.isAssignableFrom(classDownTheStackTrace)) 
{
-                    applies = false;
+        if ((throwable.getCause() == null) && 
BLACKLIST_WITHOUT_CAUSE.contains(throwable.getClass())) {
+            applies = false;
+        }
+        else {
+            for (final Class<?> classDownTheStackTrace : 
getAllExceptions(throwable)) {
+                for (final Class<? extends PersistenceException> 
blacklistElement : BLACKLIST_WITH_CAUSE) {
+                    if 
(blacklistElement.isAssignableFrom(classDownTheStackTrace)) {
+                        applies = false;
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/executor/jpa/TestBundleJobsDeleteJPAExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestBundleJobsDeleteJPAExecutor.java
 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestBundleJobsDeleteJPAExecutor.java
index 9077970..b623624 100644
--- 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestBundleJobsDeleteJPAExecutor.java
+++ 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestBundleJobsDeleteJPAExecutor.java
@@ -178,8 +178,8 @@ public class TestBundleJobsDeleteJPAExecutor extends 
XDataTestCase {
                 jpaService.execute(new 
BundleJobsDeleteJPAExecutor(deleteList));
                 fail("Should have skipped commit for failover testing");
             }
-            catch (RuntimeException re) {
-                assertEquals("Skipping Commit for Failover Testing", 
re.getMessage());
+            catch (JPAExecutorException jee) {
+                assertTrue(jee.getMessage().contains("Skipping Commit for 
Failover Testing"));
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsDeleteJPAExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsDeleteJPAExecutor.java
 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsDeleteJPAExecutor.java
index c7e0c38..7697ba4 100644
--- 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsDeleteJPAExecutor.java
+++ 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsDeleteJPAExecutor.java
@@ -122,8 +122,8 @@ public class TestCoordActionsDeleteJPAExecutor extends 
XDataTestCase {
                 jpaService.execute(new 
CoordActionsDeleteJPAExecutor(deleteList));
                 fail("Should have skipped commit for failover testing");
             }
-            catch (RuntimeException re) {
-                assertEquals("Skipping Commit for Failover Testing", 
re.getMessage());
+            catch (final JPAExecutorException jee) {
+                assertTrue(jee.getMessage().contains("Skipping Commit for 
Failover Testing"));
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobsDeleteJPAExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobsDeleteJPAExecutor.java
 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobsDeleteJPAExecutor.java
index bff5836..4c4a6b6 100644
--- 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobsDeleteJPAExecutor.java
+++ 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobsDeleteJPAExecutor.java
@@ -207,8 +207,8 @@ public class TestCoordJobsDeleteJPAExecutor extends 
XDataTestCase {
                 jpaService.execute(new 
CoordActionsDeleteJPAExecutor(deleteActionList));
                 fail("Should have skipped commit for failover testing");
             }
-            catch (RuntimeException re) {
-                assertEquals("Skipping Commit for Failover Testing", 
re.getMessage());
+            catch (final JPAExecutorException jee) {
+                assertTrue(jee.getMessage().contains("Skipping Commit for 
Failover Testing"));
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/executor/jpa/TestWorkflowJobsDeleteJPAExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestWorkflowJobsDeleteJPAExecutor.java
 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestWorkflowJobsDeleteJPAExecutor.java
index c4ca61b..3521199 100644
--- 
a/core/src/test/java/org/apache/oozie/executor/jpa/TestWorkflowJobsDeleteJPAExecutor.java
+++ 
b/core/src/test/java/org/apache/oozie/executor/jpa/TestWorkflowJobsDeleteJPAExecutor.java
@@ -180,8 +180,8 @@ public class TestWorkflowJobsDeleteJPAExecutor extends 
XDataTestCase {
                 jpaService.execute(new 
WorkflowJobsDeleteJPAExecutor(deleteList));
                 fail("Should have skipped commit for failover testing");
             }
-            catch (RuntimeException re) {
-                assertEquals("Skipping Commit for Failover Testing", 
re.getMessage());
+            catch (final JPAExecutorException jee) {
+                assertTrue(jee.getMessage().contains("Skipping Commit for 
Failover Testing"));
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/service/TestConfigurationService.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/service/TestConfigurationService.java 
b/core/src/test/java/org/apache/oozie/service/TestConfigurationService.java
index 4cb2530..1b68090 100644
--- a/core/src/test/java/org/apache/oozie/service/TestConfigurationService.java
+++ b/core/src/test/java/org/apache/oozie/service/TestConfigurationService.java
@@ -203,7 +203,7 @@ public class TestConfigurationService extends XTestCase {
         assertEquals("sa", ConfigurationService.get(JPAService.CONF_USERNAME));
         assertEquals("", 
ConfigurationService.get(JPAService.CONF_PASSWORD).trim());
         assertEquals("10", 
ConfigurationService.get(JPAService.CONF_MAX_ACTIVE_CONN).trim());
-        assertEquals("org.apache.commons.dbcp.BasicDataSource",
+        assertEquals("org.apache.oozie.util.db.BasicDataSourceWrapper",
                 ConfigurationService.get(JPAService.CONF_CONN_DATA_SOURCE));
         assertEquals("", 
ConfigurationService.get(JPAService.CONF_CONN_PROPERTIES).trim());
         assertEquals("300000", 
ConfigurationService.get(JPAService.CONF_VALIDATE_DB_CONN_EVICTION_INTERVAL).trim());

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java 
b/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java
index 34011f6..3a7db10 100644
--- a/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java
+++ b/core/src/test/java/org/apache/oozie/sla/TestSLACalculatorMemory.java
@@ -69,26 +69,26 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class TestSLACalculatorMemory extends XDataTestCase {
-
+    private Services services;
     private JPAService jpaService;
 
     @Override
     @Before
     protected void setUp() throws Exception {
         super.setUp();
-        Services services = new Services();
+        services = new Services();
         Configuration conf = 
services.get(ConfigurationService.class).getConf();
         conf.set(Services.CONF_SERVICE_EXT_CLASSES, 
"org.apache.oozie.service.EventHandlerService,"
                 + "org.apache.oozie.sla.service.SLAService");
         conf.setInt(SLAService.CONF_SLA_CHECK_INTERVAL, 600);
         services.init();
-        jpaService = Services.get().get(JPAService.class);
+        jpaService = services.get(JPAService.class);
     }
 
     @Override
     @After
     protected void tearDown() throws Exception {
-        Services.get().destroy();
+        services.destroy();
         super.tearDown();
     }
 

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/test/XTestCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/oozie/test/XTestCase.java 
b/core/src/test/java/org/apache/oozie/test/XTestCase.java
index 0ef4a4b..50e2452 100644
--- a/core/src/test/java/org/apache/oozie/test/XTestCase.java
+++ b/core/src/test/java/org/apache/oozie/test/XTestCase.java
@@ -842,7 +842,7 @@ public abstract class XTestCase extends TestCase {
         final int bjSize = getCountAndRemoveAll(entityManager, 
"GET_BUNDLE_JOBS", BundleJobBean.class);
         final int baSize = getCountAndRemoveAll(entityManager, 
"GET_BUNDLE_ACTIONS", BundleActionBean.class);
         final int slaSize = getCountAndRemoveAll(entityManager, 
"GET_SLA_EVENTS", SLAEventBean.class);
-        final int slaRegSize = getCountAndRemoveAll(entityManager, 
"GET_ACTIONS", SLARegistrationBean.class);
+        final int slaRegSize = getCountAndRemoveAll(entityManager, 
"GET_SLA_REGISTRATIONS", SLARegistrationBean.class);
         final int ssSize = getCountAndRemoveAll(entityManager, 
"GET_SLA_SUMMARY_ALL", SLASummaryBean.class);
 
         try {

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/core/src/test/java/org/apache/oozie/util/db/TestPersistenceExceptionSubclassFilterRetryPredicate.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/util/db/TestPersistenceExceptionSubclassFilterRetryPredicate.java
 
b/core/src/test/java/org/apache/oozie/util/db/TestPersistenceExceptionSubclassFilterRetryPredicate.java
index 76d2edc..26dc13b 100644
--- 
a/core/src/test/java/org/apache/oozie/util/db/TestPersistenceExceptionSubclassFilterRetryPredicate.java
+++ 
b/core/src/test/java/org/apache/oozie/util/db/TestPersistenceExceptionSubclassFilterRetryPredicate.java
@@ -63,7 +63,7 @@ public class 
TestPersistenceExceptionSubclassFilterRetryPredicate {
 
     @Test
     public void testNonJPAExceptions() {
-        assertTrue(predicate.apply(new RuntimeException()));
+        assertTrue(predicate.apply(new IllegalStateException()));
         assertTrue(predicate.apply(new Exception()));
     }
 
@@ -92,7 +92,23 @@ public class 
TestPersistenceExceptionSubclassFilterRetryPredicate {
         assertTrue(predicate.apply(wrapCause(new Exception())));
     }
 
+    @Test
+    public void testPlainJPAExecutorExceptionWithMessage() {
+        assertFalse(predicate.apply(wrapMessage("No WorkflowJobBean found in 
database")));
+        assertFalse(predicate.apply(wrapMessage("Some other message")));
+
+        assertFalse(predicate.apply(wrapMessageRuntime("Some runtime 
problem")));
+    }
+
     private JPAExecutorException wrapCause(final Throwable cause) {
         return new JPAExecutorException(new XException(ErrorCode.E0603, new 
PersistenceException(cause)));
     }
+
+    private JPAExecutorException wrapMessage(final String message) {
+        return new JPAExecutorException(ErrorCode.E0603, message);
+    }
+
+    private RuntimeException wrapMessageRuntime(final String message) {
+        return new RuntimeException(message);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/oozie/blob/8463f228/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 7d70c2a..9d69cef 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 5.0.0 release (trunk - unreleased)
 
+OOZIE-3009 Number of Oozie tests executed dropped after OOZIE-2854 
(andras.piros via asasvari)
 OOZIE-2961 Build contains multiple warnings for is not a parameter name (Artem 
Ervits via gezapeti)
 OOZIE-3018 Use Hadoop's CredentialProvider for passwords in 
SchemaCheckerService (andras.piros via gezapeti)
 OOZIE-2958 TestLauncherAM fails in Share Lib Oozie (pbacsko)

Reply via email to