Search in sources :

Example 1 with MinionDao

use of org.opennms.netmgt.dao.api.MinionDao in project opennms by OpenNMS.

the class MinionHeartBeatIT method minionHeartBeatTestForLastUpdated.

@Test
public void minionHeartBeatTestForLastUpdated() {
    Date startOfTest = new Date();
    InetSocketAddress pgsql = m_testEnvironment.getServiceAddress(ContainerAlias.POSTGRES, 5432);
    HibernateDaoFactory daoFactory = new HibernateDaoFactory(pgsql);
    MinionDao minionDao = daoFactory.getDao(MinionDaoHibernate.class);
    NodeDao nodeDao = daoFactory.getDao(NodeDaoHibernate.class);
    // The heartbeat runs every minute so if we miss the first one, poll long enough
    // to catch the next one
    await().atMost(90, SECONDS).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(minionDao, new CriteriaBuilder(OnmsMinion.class).ge("lastUpdated", startOfTest).toCriteria()), greaterThan(0));
    await().atMost(180, SECONDS).pollInterval(5, SECONDS).until(DaoUtils.countMatchingCallable(nodeDao, new CriteriaBuilder(OnmsNode.class).eq("foreignSource", "Minions").eq("foreignId", "00000000-0000-0000-0000-000000ddba11").toCriteria()), equalTo(1));
    Assert.assertEquals("MINION", nodeDao.get("Minions:00000000-0000-0000-0000-000000ddba11").getLocation().getLocationName());
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) HibernateDaoFactory(org.opennms.smoketest.utils.HibernateDaoFactory) OnmsNode(org.opennms.netmgt.model.OnmsNode) InetSocketAddress(java.net.InetSocketAddress) MinionDao(org.opennms.netmgt.dao.api.MinionDao) Date(java.util.Date) Test(org.junit.Test)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 Date (java.util.Date)1 Test (org.junit.Test)1 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)1 MinionDao (org.opennms.netmgt.dao.api.MinionDao)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 HibernateDaoFactory (org.opennms.smoketest.utils.HibernateDaoFactory)1