|
@@ -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);
|