Browse Source

AMBARI-11200. Fix ignored persistence-related unit tests (dlysnichenko)

Lisnichenko Dmitro 10 years ago
parent
commit
2e64b3b9f7

+ 6 - 0
ambari-server/pom.xml

@@ -1459,6 +1459,12 @@
       <groupId>org.apache.derby</groupId>
       <groupId>org.apache.derby</groupId>
       <artifactId>derby</artifactId>
       <artifactId>derby</artifactId>
     </dependency>
     </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derbytools</artifactId>
+      <version>10.11.1.1</version>
+      <scope>test</scope>
+    </dependency>
     <dependency>
     <dependency>
       <groupId>org.springframework.security</groupId>
       <groupId>org.springframework.security</groupId>
       <artifactId>spring-security-core</artifactId>
       <artifactId>spring-security-core</artifactId>

+ 8 - 0
ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertTargetEntity.java

@@ -320,6 +320,14 @@ public class AlertTargetEntity {
     alertNotices.add(notice);
     alertNotices.add(notice);
   }
   }
 
 
+  public List<AlertNoticeEntity> getAlertNotices() {
+    return alertNotices;
+  }
+
+  public void setAlertNotices(List<AlertNoticeEntity> alertNotices) {
+    this.alertNotices = alertNotices;
+  }
+
   /**
   /**
    * Called before {@link EntityManager#remove(Object)} for this entity, removes
    * Called before {@link EntityManager#remove(Object)} for this entity, removes
    * the non-owning relationship between targets and groups.
    * the non-owning relationship between targets and groups.

+ 3 - 0
ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java

@@ -32,6 +32,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 
 
 import com.google.inject.Inject;
 import com.google.inject.Inject;
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.events.ServiceComponentInstalledEvent;
 import org.apache.ambari.server.events.ServiceComponentInstalledEvent;
@@ -101,6 +102,7 @@ public class HostVersionOutOfSyncListenerTest {
 
 
     EventBusSynchronizer.synchronizeAmbariEventPublisher(injector);
     EventBusSynchronizer.synchronizeAmbariEventPublisher(injector);
     injector.injectMembers(this);
     injector.injectMembers(this);
+    injector.getInstance(UnitOfWork.class).begin();
 
 
     StackId stackId = new StackId(this.stackId);
     StackId stackId = new StackId(this.stackId);
     clusters.addCluster("c1", stackId);
     clusters.addCluster("c1", stackId);
@@ -115,6 +117,7 @@ public class HostVersionOutOfSyncListenerTest {
 
 
   @After
   @After
   public void teardown() {
   public void teardown() {
+    injector.getInstance(UnitOfWork.class).end();
     injector.getInstance(PersistService.class).stop();
     injector.getInstance(PersistService.class).stop();
   }
   }
 
 

+ 4 - 3
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAOTest.java

@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.TimeZone;
 import java.util.TimeZone;
 import java.util.UUID;
 import java.util.UUID;
 
 
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.controller.RootServiceResponseFactory;
 import org.apache.ambari.server.controller.RootServiceResponseFactory;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -48,7 +49,6 @@ import org.apache.ambari.server.state.alert.Scope;
 import org.apache.ambari.server.state.alert.SourceType;
 import org.apache.ambari.server.state.alert.SourceType;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import com.google.inject.Guice;
 import com.google.inject.Guice;
@@ -77,6 +77,7 @@ public class AlertDefinitionDAOTest {
   public void setup() throws Exception {
   public void setup() throws Exception {
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector = Guice.createInjector(new InMemoryDefaultTestModule());
     injector.getInstance(GuiceJpaInitializer.class);
     injector.getInstance(GuiceJpaInitializer.class);
+    injector.getInstance(UnitOfWork.class).begin();
 
 
     dispatchDao = injector.getInstance(AlertDispatchDAO.class);
     dispatchDao = injector.getInstance(AlertDispatchDAO.class);
     dao = injector.getInstance(AlertDefinitionDAO.class);
     dao = injector.getInstance(AlertDefinitionDAO.class);
@@ -157,6 +158,8 @@ public class AlertDefinitionDAOTest {
 
 
   @After
   @After
   public void teardown() {
   public void teardown() {
+    injector.getInstance(UnitOfWork.class).end();
+
     injector.getInstance(PersistService.class).stop();
     injector.getInstance(PersistService.class).stop();
     injector = null;
     injector = null;
   }
   }
@@ -297,7 +300,6 @@ public class AlertDefinitionDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testCascadeDelete() throws Exception {
   public void testCascadeDelete() throws Exception {
     AlertDefinitionEntity definition = helper.createAlertDefinition(clusterId);
     AlertDefinitionEntity definition = helper.createAlertDefinition(clusterId);
 
 
@@ -369,7 +371,6 @@ public class AlertDefinitionDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testCascadeDeleteForCluster() throws Exception {
   public void testCascadeDeleteForCluster() throws Exception {
     AlertDefinitionEntity definition = helper.createAlertDefinition(clusterId);
     AlertDefinitionEntity definition = helper.createAlertDefinition(clusterId);
     definition = dao.findById(definition.getDefinitionId());
     definition = dao.findById(definition.getDefinitionId());

+ 7 - 3
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertDispatchDAOTest.java

@@ -32,7 +32,9 @@ import java.util.List;
 import java.util.Set;
 import java.util.Set;
 import java.util.UUID;
 import java.util.UUID;
 
 
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AlertNoticeRequest;
 import org.apache.ambari.server.controller.AlertNoticeRequest;
 import org.apache.ambari.server.controller.internal.AlertNoticeResourceProvider;
 import org.apache.ambari.server.controller.internal.AlertNoticeResourceProvider;
 import org.apache.ambari.server.controller.internal.PageRequestImpl;
 import org.apache.ambari.server.controller.internal.PageRequestImpl;
@@ -98,6 +100,8 @@ public class AlertDispatchDAOTest {
   public void setup() throws Exception {
   public void setup() throws Exception {
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.getInstance(GuiceJpaInitializer.class);
+    m_injector.getInstance(UnitOfWork.class).begin();
+
     m_dao = m_injector.getInstance(AlertDispatchDAO.class);
     m_dao = m_injector.getInstance(AlertDispatchDAO.class);
     m_alertsDao = m_injector.getInstance(AlertsDAO.class);
     m_alertsDao = m_injector.getInstance(AlertsDAO.class);
     m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
     m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
@@ -134,6 +138,7 @@ public class AlertDispatchDAOTest {
    */
    */
   @After
   @After
   public void teardown() throws Exception {
   public void teardown() throws Exception {
+    m_injector.getInstance(UnitOfWork.class).end();
     m_injector.getInstance(PersistService.class).stop();
     m_injector.getInstance(PersistService.class).stop();
     m_injector = null;
     m_injector = null;
   }
   }
@@ -262,7 +267,6 @@ public class AlertDispatchDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testGroupDefinitions() throws Exception {
   public void testGroupDefinitions() throws Exception {
     List<AlertDefinitionEntity> definitions = createDefinitions();
     List<AlertDefinitionEntity> definitions = createDefinitions();
 
 
@@ -301,7 +305,6 @@ public class AlertDispatchDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testCreateTarget() throws Exception {
   public void testCreateTarget() throws Exception {
     int targetCount = m_dao.findAllTargets().size();
     int targetCount = m_dao.findAllTargets().size();
 
 
@@ -480,6 +483,8 @@ public class AlertDispatchDAOTest {
     notice = m_dao.findNoticeById(notice.getNotificationId());
     notice = m_dao.findNoticeById(notice.getNotificationId());
     assertEquals(target.getTargetId(), notice.getAlertTarget().getTargetId());
     assertEquals(target.getTargetId(), notice.getAlertTarget().getTargetId());
 
 
+    //new org.apache.derby.tools.dblook(new String[]{"-d", Configuration.JDBC_IN_MEMORY_URL, "-verbose", "-o", "/tmp/1.ddl"});
+
     target = m_dao.findTargetById(target.getTargetId());
     target = m_dao.findTargetById(target.getTargetId());
     m_dao.remove(target);
     m_dao.remove(target);
     notice = m_dao.findNoticeById(notice.getNotificationId());
     notice = m_dao.findNoticeById(notice.getNotificationId());
@@ -490,7 +495,6 @@ public class AlertDispatchDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testDeleteAssociatedTarget() throws Exception {
   public void testDeleteAssociatedTarget() throws Exception {
     AlertTargetEntity target = m_helper.createAlertTarget();
     AlertTargetEntity target = m_helper.createAlertTarget();
     Set<AlertTargetEntity> targets = new HashSet<AlertTargetEntity>();
     Set<AlertTargetEntity> targets = new HashSet<AlertTargetEntity>();

+ 4 - 23
ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AlertsDAOTest.java

@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.TimeZone;
 import java.util.TimeZone;
 import java.util.UUID;
 import java.util.UUID;
 
 
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.controller.AlertCurrentRequest;
 import org.apache.ambari.server.controller.AlertCurrentRequest;
 import org.apache.ambari.server.controller.AlertHistoryRequest;
 import org.apache.ambari.server.controller.AlertHistoryRequest;
 import org.apache.ambari.server.controller.internal.AlertHistoryResourceProvider;
 import org.apache.ambari.server.controller.internal.AlertHistoryResourceProvider;
@@ -66,7 +67,6 @@ import org.apache.ambari.server.state.alert.SourceType;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import com.google.inject.Guice;
 import com.google.inject.Guice;
@@ -101,6 +101,8 @@ public class AlertsDAOTest {
   public void setup() throws Exception {
   public void setup() throws Exception {
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.getInstance(GuiceJpaInitializer.class);
+    m_injector.getInstance(UnitOfWork.class).begin();
+
     m_helper = m_injector.getInstance(OrmTestHelper.class);
     m_helper = m_injector.getInstance(OrmTestHelper.class);
     m_dao = m_injector.getInstance(AlertsDAO.class);
     m_dao = m_injector.getInstance(AlertsDAO.class);
     m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
     m_definitionDao = m_injector.getInstance(AlertDefinitionDAO.class);
@@ -195,6 +197,7 @@ public class AlertsDAOTest {
    */
    */
   @After
   @After
   public void teardown() {
   public void teardown() {
+    m_injector.getInstance(UnitOfWork.class).end();
     m_injector.getInstance(PersistService.class).stop();
     m_injector.getInstance(PersistService.class).stop();
     m_injector = null;
     m_injector = null;
   }
   }
@@ -204,7 +207,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindAll() {
   public void testFindAll() {
     List<AlertHistoryEntity> alerts = m_dao.findAll(m_cluster.getClusterId());
     List<AlertHistoryEntity> alerts = m_dao.findAll(m_cluster.getClusterId());
     assertNotNull(alerts);
     assertNotNull(alerts);
@@ -215,7 +217,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindAllCurrent() {
   public void testFindAllCurrent() {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     assertNotNull(currentAlerts);
     assertNotNull(currentAlerts);
@@ -226,7 +227,6 @@ public class AlertsDAOTest {
    * Test looking up current alerts by definition ID.
    * Test looking up current alerts by definition ID.
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindCurrentByDefinitionId() throws Exception {
   public void testFindCurrentByDefinitionId() throws Exception {
     // create a host
     // create a host
     AlertDefinitionEntity definition = new AlertDefinitionEntity();
     AlertDefinitionEntity definition = new AlertDefinitionEntity();
@@ -288,7 +288,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindCurrentByService() {
   public void testFindCurrentByService() {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     int currentAlertExpectedCount = currentAlerts.size();
     int currentAlertExpectedCount = currentAlerts.size();
@@ -315,7 +314,6 @@ public class AlertsDAOTest {
    * Test looking up current by a host name.
    * Test looking up current by a host name.
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindCurrentByHost() throws Exception {
   public void testFindCurrentByHost() throws Exception {
     // create a host
     // create a host
     AlertDefinitionEntity hostDef = new AlertDefinitionEntity();
     AlertDefinitionEntity hostDef = new AlertDefinitionEntity();
@@ -377,7 +375,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertCurrentPredicate() throws Exception {
   public void testAlertCurrentPredicate() throws Exception {
     AlertDefinitionEntity definition = m_definitionDao.findByName(
     AlertDefinitionEntity definition = m_definitionDao.findByName(
         m_cluster.getClusterId(), "Alert Definition 0");
         m_cluster.getClusterId(), "Alert Definition 0");
@@ -420,7 +417,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertCurrentUpdatesViaHistory() throws Exception {
   public void testAlertCurrentUpdatesViaHistory() throws Exception {
     AlertDefinitionEntity hostDef = new AlertDefinitionEntity();
     AlertDefinitionEntity hostDef = new AlertDefinitionEntity();
     hostDef.setDefinitionName("Host Alert Definition ");
     hostDef.setDefinitionName("Host Alert Definition ");
@@ -463,7 +459,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindByState() {
   public void testFindByState() {
     List<AlertState> allStates = new ArrayList<AlertState>();
     List<AlertState> allStates = new ArrayList<AlertState>();
     allStates.add(AlertState.OK);
     allStates.add(AlertState.OK);
@@ -495,7 +490,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindByDate() {
   public void testFindByDate() {
     calendar.clear();
     calendar.clear();
     calendar.set(2014, Calendar.JANUARY, 1);
     calendar.set(2014, Calendar.JANUARY, 1);
@@ -535,7 +529,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testFindCurrentByHostAndName() throws Exception {
   public void testFindCurrentByHostAndName() throws Exception {
     AlertCurrentEntity entity = m_dao.findCurrentByHostAndName(
     AlertCurrentEntity entity = m_dao.findCurrentByHostAndName(
         m_cluster.getClusterId(), "h2", "Alert Definition 1");
         m_cluster.getClusterId(), "h2", "Alert Definition 1");
@@ -553,7 +546,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindCurrentSummary() throws Exception {
   public void testFindCurrentSummary() throws Exception {
     AlertSummaryDTO summary = m_dao.findCurrentCounts(m_cluster.getClusterId(),
     AlertSummaryDTO summary = m_dao.findCurrentCounts(m_cluster.getClusterId(),
         null, null);
         null, null);
@@ -661,7 +653,6 @@ public class AlertsDAOTest {
    *
    *
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFindCurrentHostSummary() throws Exception {
   public void testFindCurrentHostSummary() throws Exception {
     // start out with 1 since all alerts are for a single host and are OK
     // start out with 1 since all alerts are for a single host and are OK
     AlertHostSummaryDTO summary = m_dao.findCurrentHostCounts(m_cluster.getClusterId());
     AlertHostSummaryDTO summary = m_dao.findCurrentHostCounts(m_cluster.getClusterId());
@@ -767,7 +758,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testFindAggregates() throws Exception {
   public void testFindAggregates() throws Exception {
     // definition
     // definition
     AlertDefinitionEntity definition = new AlertDefinitionEntity();
     AlertDefinitionEntity definition = new AlertDefinitionEntity();
@@ -855,7 +845,6 @@ public class AlertsDAOTest {
    * entity to be stale.
    * entity to be stale.
    */
    */
   @Test
   @Test
-  @Ignore
   public void testJPAInnerEntityStaleness() {
   public void testJPAInnerEntityStaleness() {
     List<AlertCurrentEntity> currents = m_dao.findCurrent();
     List<AlertCurrentEntity> currents = m_dao.findCurrent();
     AlertCurrentEntity current = currents.get(0);
     AlertCurrentEntity current = currents.get(0);
@@ -913,7 +902,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testMaintenanceMode() throws Exception {
   public void testMaintenanceMode() throws Exception {
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
         m_componentFactory, m_schFactory, HOSTNAME);
         m_componentFactory, m_schFactory, HOSTNAME);
@@ -1103,7 +1091,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertHistoryPredicate() throws Exception {
   public void testAlertHistoryPredicate() throws Exception {
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
         m_componentFactory, m_schFactory, HOSTNAME);
         m_componentFactory, m_schFactory, HOSTNAME);
@@ -1197,7 +1184,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertHistoryPagination() throws Exception {
   public void testAlertHistoryPagination() throws Exception {
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
         m_componentFactory, m_schFactory, HOSTNAME);
         m_componentFactory, m_schFactory, HOSTNAME);
@@ -1238,7 +1224,6 @@ public class AlertsDAOTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertHistorySorting() throws Exception {
   public void testAlertHistorySorting() throws Exception {
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
     m_helper.installHdfsService(m_cluster, m_serviceFactory,
         m_componentFactory, m_schFactory, HOSTNAME);
         m_componentFactory, m_schFactory, HOSTNAME);
@@ -1298,7 +1283,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRemoveCurrenyByService() throws Exception {
   public void testRemoveCurrenyByService() throws Exception {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     assertNotNull(currentAlerts);
     assertNotNull(currentAlerts);
@@ -1315,7 +1299,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRemoveCurrenyByHost() throws Exception {
   public void testRemoveCurrenyByHost() throws Exception {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     assertNotNull(currentAlerts);
     assertNotNull(currentAlerts);
@@ -1333,7 +1316,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRemoveCurrenyByComponentHost() throws Exception {
   public void testRemoveCurrenyByComponentHost() throws Exception {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     assertNotNull(currentAlerts);
     assertNotNull(currentAlerts);
@@ -1354,7 +1336,6 @@ public class AlertsDAOTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRemoveCurrentDisabled() throws Exception {
   public void testRemoveCurrentDisabled() throws Exception {
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     List<AlertCurrentEntity> currentAlerts = m_dao.findCurrent();
     assertNotNull(currentAlerts);
     assertNotNull(currentAlerts);

+ 3 - 3
ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java

@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.ServiceNotFoundException;
 import org.apache.ambari.server.ServiceNotFoundException;
@@ -66,7 +67,6 @@ import org.apache.ambari.server.state.State;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import com.google.gson.Gson;
 import com.google.gson.Gson;
@@ -122,10 +122,12 @@ public class UpgradeActionTest {
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.injectMembers(this);
     m_injector.injectMembers(this);
+    m_injector.getInstance(UnitOfWork.class).begin();
   }
   }
 
 
   @After
   @After
   public void teardown() throws Exception {
   public void teardown() throws Exception {
+    m_injector.getInstance(UnitOfWork.class).end();
     m_injector.getInstance(PersistService.class).stop();
     m_injector.getInstance(PersistService.class).stop();
   }
   }
 
 
@@ -376,7 +378,6 @@ public class UpgradeActionTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testFinalizeUpgradeAcrossStacks() throws Exception {
   public void testFinalizeUpgradeAcrossStacks() throws Exception {
     makeCrossStackUpgradeCluster();
     makeCrossStackUpgradeCluster();
 
 
@@ -425,7 +426,6 @@ public class UpgradeActionTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testFinalizeDowngradeAcrossStacks() throws Exception {
   public void testFinalizeDowngradeAcrossStacks() throws Exception {
     makeCrossStackUpgradeCluster();
     makeCrossStackUpgradeCluster();
 
 

+ 0 - 2
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java

@@ -38,7 +38,6 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import com.google.common.eventbus.EventBus;
 import com.google.common.eventbus.EventBus;
@@ -118,7 +117,6 @@ public class InitialAlertEventTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testInitialAlertEvent() throws Exception {
   public void testInitialAlertEvent() throws Exception {
     // ensure there are no historical items
     // ensure there are no historical items
     Assert.assertEquals(0, m_alertsDao.findAll().size());
     Assert.assertEquals(0, m_alertsDao.findAll().size());

+ 4 - 3
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/AlertDataManagerTest.java

@@ -29,6 +29,7 @@ import java.util.Set;
 import java.util.UUID;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReference;
 
 
+import com.google.inject.persist.UnitOfWork;
 import org.apache.ambari.server.events.AlertEvent;
 import org.apache.ambari.server.events.AlertEvent;
 import org.apache.ambari.server.events.AlertReceivedEvent;
 import org.apache.ambari.server.events.AlertReceivedEvent;
 import org.apache.ambari.server.events.AlertStateChangeEvent;
 import org.apache.ambari.server.events.AlertStateChangeEvent;
@@ -68,7 +69,6 @@ import org.apache.ambari.server.state.alert.SourceType;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.apache.ambari.server.utils.EventBusSynchronizer;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 
 
 import com.google.common.eventbus.Subscribe;
 import com.google.common.eventbus.Subscribe;
@@ -106,6 +106,8 @@ public class AlertDataManagerTest {
   public void setup() throws Exception {
   public void setup() throws Exception {
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector = Guice.createInjector(new InMemoryDefaultTestModule());
     m_injector.getInstance(GuiceJpaInitializer.class);
     m_injector.getInstance(GuiceJpaInitializer.class);
+    m_injector.getInstance(UnitOfWork.class).begin();
+
     m_helper = m_injector.getInstance(OrmTestHelper.class);
     m_helper = m_injector.getInstance(OrmTestHelper.class);
     m_dao = m_injector.getInstance(AlertsDAO.class);
     m_dao = m_injector.getInstance(AlertsDAO.class);
     m_dispatchDao = m_injector.getInstance(AlertDispatchDAO.class);
     m_dispatchDao = m_injector.getInstance(AlertDispatchDAO.class);
@@ -141,12 +143,12 @@ public class AlertDataManagerTest {
 
 
   @After
   @After
   public void teardown() {
   public void teardown() {
+    m_injector.getInstance(UnitOfWork.class).end();
     m_injector.getInstance(PersistService.class).stop();
     m_injector.getInstance(PersistService.class).stop();
     m_injector = null;
     m_injector = null;
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testAlertRecords() {
   public void testAlertRecords() {
     Alert alert1 = new Alert(ALERT_DEFINITION, null, SERVICE, COMPONENT, HOST1,
     Alert alert1 = new Alert(ALERT_DEFINITION, null, SERVICE, COMPONENT, HOST1,
         AlertState.OK);
         AlertState.OK);
@@ -265,7 +267,6 @@ public class AlertDataManagerTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testAlertNotices() throws Exception {
   public void testAlertNotices() throws Exception {
     List<AlertNoticeEntity> notices = m_dispatchDao.findAllNotices();
     List<AlertNoticeEntity> notices = m_dispatchDao.findAllNotices();
     assertEquals( 0, notices.size() );
     assertEquals( 0, notices.size() );

+ 3 - 23
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java

@@ -43,6 +43,7 @@ import javax.persistence.EntityManager;
 import javax.persistence.RollbackException;
 import javax.persistence.RollbackException;
 
 
 import com.google.gson.Gson;
 import com.google.gson.Gson;
+import com.google.inject.persist.UnitOfWork;
 import junit.framework.Assert;
 import junit.framework.Assert;
 
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
@@ -104,7 +105,6 @@ import org.apache.ambari.server.state.host.HostHealthyHeartbeatEvent;
 import org.apache.ambari.server.state.host.HostRegistrationRequestEvent;
 import org.apache.ambari.server.state.host.HostRegistrationRequestEvent;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.ArgumentCaptor;
 
 
@@ -194,10 +194,12 @@ public class ClusterTest {
     hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
     hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
     repositoryVersionDAO = injector.getInstance(RepositoryVersionDAO.class);
     repositoryVersionDAO = injector.getInstance(RepositoryVersionDAO.class);
     gson = injector.getInstance(Gson.class);
     gson = injector.getInstance(Gson.class);
+    injector.getInstance(UnitOfWork.class).begin();
   }
   }
 
 
   @After
   @After
   public void teardown() {
   public void teardown() {
+    injector.getInstance(UnitOfWork.class).end();
     injector.getInstance(PersistService.class).stop();
     injector.getInstance(PersistService.class).stop();
   }
   }
 
 
@@ -538,7 +540,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testAddHost() throws Exception {
   public void testAddHost() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
     clusters.addHost("h3");
     clusters.addHost("h3");
@@ -553,7 +554,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testGetHostState() throws Exception {
   public void testGetHostState() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -561,7 +561,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testSetHostState() throws Exception {
   public void testSetHostState() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -571,7 +570,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testHostEvent() throws Exception,
   public void testHostEvent() throws Exception,
       InvalidStateTransitionException {
       InvalidStateTransitionException {
     createDefaultCluster();
     createDefaultCluster();
@@ -622,7 +620,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testBasicClusterSetup() throws Exception {
   public void testBasicClusterSetup() throws Exception {
     StackId stackVersion = new StackId("HDP-1.2.0");
     StackId stackVersion = new StackId("HDP-1.2.0");
 
 
@@ -652,7 +649,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testAddAndGetServices() throws Exception {
   public void testAddAndGetServices() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -698,7 +694,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testGetServiceComponentHosts() throws Exception {
   public void testGetServiceComponentHosts() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -744,7 +739,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testGetAndSetConfigs() throws Exception {
   public void testGetAndSetConfigs() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -785,7 +779,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testDesiredConfigs() throws Exception {
   public void testDesiredConfigs() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -859,7 +852,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testConvertToResponse() throws Exception {
   public void testConvertToResponse() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -914,7 +906,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testDeleteService() throws Exception {
   public void testDeleteService() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -938,7 +929,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testGetHostsDesiredConfigs() throws Exception {
   public void testGetHostsDesiredConfigs() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -970,7 +960,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testProvisioningState() throws Exception {
   public void testProvisioningState() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -984,7 +973,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testServiceConfigVersions() throws Exception {
   public void testServiceConfigVersions() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1048,7 +1036,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testSingleServiceVersionForMultipleConfigs() throws Exception {
   public void testSingleServiceVersionForMultipleConfigs() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1084,7 +1071,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testServiceConfigVersionsForGroups() throws Exception {
   public void testServiceConfigVersionsForGroups() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1182,7 +1168,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testTransitionClusterVersion() throws Exception {
   public void testTransitionClusterVersion() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1330,7 +1315,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testTransitionClusterVersionTransactionFail() throws Exception {
   public void testTransitionClusterVersionTransactionFail() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1359,7 +1343,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testInferHostVersions() throws Exception {
   public void testInferHostVersions() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1420,7 +1403,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRecalculateClusterVersionState() throws Exception {
   public void testRecalculateClusterVersionState() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1529,7 +1511,6 @@ public class ClusterTest {
   }
   }
 
 
   @Test
   @Test
-  @Ignore
   public void testRecalculateAllClusterVersionStates() throws Exception {
   public void testRecalculateAllClusterVersionStates() throws Exception {
     createDefaultCluster();
     createDefaultCluster();
 
 
@@ -1589,7 +1570,6 @@ public class ClusterTest {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  @Ignore
   public void testTransitionHostVersionAdvanced() throws Exception {
   public void testTransitionHostVersionAdvanced() throws Exception {
     String clusterName = "c1";
     String clusterName = "c1";
     String v1 = "2.2.0-123";
     String v1 = "2.2.0-123";