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));
}
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);
}
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());
}
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);
}
}
}
Aggregations