Search in sources :

Example 1 with EngineBackupLog

use of org.ovirt.engine.core.common.businessentities.EngineBackupLog in project ovirt-engine by oVirt.

the class EngineBackupLogDaoTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getEngineBackupLogDao();
    existingEngineBackupLog = dao.getLastSuccessfulEngineBackup(SCOPE);
    newEntity = new EngineBackupLog();
    newEntity.setScope(RandomUtils.instance().nextString(20));
    newEntity.setDoneAt(new Date());
    newEntity.setPassed(true);
    newEntity.setOutputMessage(RandomUtils.instance().nextString(20));
    newEntity.setFqdn(RandomUtils.instance().nextString(20));
    newEntity.setLogPath(RandomUtils.instance().nextString(20));
}
Also used : EngineBackupLog(org.ovirt.engine.core.common.businessentities.EngineBackupLog) Date(java.util.Date) Before(org.junit.Before)

Example 2 with EngineBackupLog

use of org.ovirt.engine.core.common.businessentities.EngineBackupLog in project ovirt-engine by oVirt.

the class EngineBackupLogDaoTest method testAddingNewUnsuccessfulBackupEvent.

@Test
public void testAddingNewUnsuccessfulBackupEvent() {
    EngineBackupLog engineBackupLog = new EngineBackupLog();
    engineBackupLog.setScope(SCOPE);
    engineBackupLog.setDoneAt(Calendar.getInstance().getTime());
    engineBackupLog.setPassed(false);
    engineBackupLog.setOutputMessage("backup failed");
    engineBackupLog.setFqdn(RandomUtils.instance().nextString(20));
    engineBackupLog.setLogPath(RandomUtils.instance().nextString(20));
    dao.save(engineBackupLog);
    EngineBackupLog entry = dao.getLastSuccessfulEngineBackup(SCOPE);
    assertNotNull(entry);
    assertEquals(entry, existingEngineBackupLog);
}
Also used : EngineBackupLog(org.ovirt.engine.core.common.businessentities.EngineBackupLog) Test(org.junit.Test)

Example 3 with EngineBackupLog

use of org.ovirt.engine.core.common.businessentities.EngineBackupLog in project ovirt-engine by oVirt.

the class EngineBackupLogDaoTest method testAddingNewSuccessfulBackupEvent.

@Test
public void testAddingNewSuccessfulBackupEvent() {
    EngineBackupLog engineBackupLog = new EngineBackupLog();
    engineBackupLog.setScope(SCOPE);
    engineBackupLog.setDoneAt(Calendar.getInstance().getTime());
    engineBackupLog.setPassed(true);
    engineBackupLog.setOutputMessage("backup completed successfully");
    engineBackupLog.setFqdn(RandomUtils.instance().nextString(20));
    engineBackupLog.setLogPath(RandomUtils.instance().nextString(20));
    dao.save(engineBackupLog);
    EngineBackupLog entry = dao.getLastSuccessfulEngineBackup(SCOPE);
    assertNotNull(entry);
    assertNotEquals(entry.getDoneAt(), existingEngineBackupLog.getDoneAt());
    assertTrue(entry.isPassed());
}
Also used : EngineBackupLog(org.ovirt.engine.core.common.businessentities.EngineBackupLog) Test(org.junit.Test)

Example 4 with EngineBackupLog

use of org.ovirt.engine.core.common.businessentities.EngineBackupLog in project ovirt-engine by oVirt.

the class EngineBackupAwarenessManager method doBackupCheck.

private void doBackupCheck() {
    AuditLogable alert = new AuditLogableImpl();
    // try to get last backup record
    EngineBackupLog lastDbBackup = getLastBackupByScope(BackupScope.DB);
    EngineBackupLog lastFilesBackup = getLastBackupByScope(BackupScope.FILES);
    if (lastDbBackup == null || lastFilesBackup == null) {
        auditLogDirector.log(alert, AuditLogType.ENGINE_NO_FULL_BACKUP);
    } else {
        // check time elapsed from last full (db and files) backup
        Integer backupAlertPeriodInDays = Config.<Integer>getValue(ConfigValues.BackupAlertPeriodInDays);
        Date lastDbBackupDate = lastDbBackup.getDoneAt();
        Date lastFilesBackupDate = lastFilesBackup.getDoneAt();
        Date lastFullBackupDate = lastDbBackupDate.compareTo(lastFilesBackupDate) < 0 ? lastDbBackupDate : lastFilesBackupDate;
        long diffInDays = (Calendar.getInstance().getTimeInMillis() - lastFullBackupDate.getTime()) / TimeUnit.DAYS.toMillis(1);
        if (diffInDays > backupAlertPeriodInDays) {
            alert.addCustomValue("Date", lastFullBackupDate.toString());
            auditLogDirector.log(alert, AuditLogType.ENGINE_NO_WARM_BACKUP);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) EngineBackupLog(org.ovirt.engine.core.common.businessentities.EngineBackupLog) Date(java.util.Date)

Aggregations

EngineBackupLog (org.ovirt.engine.core.common.businessentities.EngineBackupLog)4 Date (java.util.Date)2 Test (org.junit.Test)2 Before (org.junit.Before)1 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)1 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)1