@Test public void noBackups() throws Exception { MockBackupVerification.shouldThrow(false); MockBackupVerification.setResults(); backupVerificationService.execute(); Truth.assertThat(badVerifications.count()).isEqualTo(1); new Verifications() { { backupNotificationMgr.notify((BackupVerificationResult) any); maxTimes = 0; } }; }
@Override public void execute() throws Exception { if (backupRestoreConfig.getSnapshotMetaServiceCronExpression().equals("-1")) { logger.info("Skipping backup verification. V2 backups are not enabled."); return; } if (instanceState.getRestoreStatus() != null && instanceState.getRestoreStatus().getStatus() != null && instanceState.getRestoreStatus().getStatus() == Status.STARTED) { logger.info("Skipping backup verification. Priam is in restore mode."); return; } Instant now = DateUtil.getInstant(); Instant slo = now.minus(backupRestoreConfig.getBackupVerificationSLOInHours(), ChronoUnit.HOURS); DateRange dateRange = new DateRange(slo, now); List<BackupVerificationResult> verificationResults = backupVerification.verifyAllBackups(BackupVersion.SNAPSHOT_META_SERVICE, dateRange); verificationResults.forEach( result -> { logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, result.snapshotInstant); backupNotificationMgr.notify(result); }); if (!backupVerification .verifyBackup(BackupVersion.SNAPSHOT_META_SERVICE, false , dateRange) .isPresent()) { logger.error( "Not able to find any snapshot which is valid in our SLO window: {} hours", backupRestoreConfig.getBackupVerificationSLOInHours()); backupMetrics.incrementBackupVerificationFailure(); } }
BackupVerificationTask extends Task { @Override public void execute() throws Exception { if (backupRestoreConfig.getSnapshotMetaServiceCronExpression().equals("-1")) { logger.info("Skipping backup verification. V2 backups are not enabled."); return; } if (instanceState.getRestoreStatus() != null && instanceState.getRestoreStatus().getStatus() != null && instanceState.getRestoreStatus().getStatus() == Status.STARTED) { logger.info("Skipping backup verification. Priam is in restore mode."); return; } Instant now = DateUtil.getInstant(); Instant slo = now.minus(backupRestoreConfig.getBackupVerificationSLOInHours(), ChronoUnit.HOURS); DateRange dateRange = new DateRange(slo, now); List<BackupVerificationResult> verificationResults = backupVerification.verifyAllBackups(BackupVersion.SNAPSHOT_META_SERVICE, dateRange); verificationResults.forEach( result -> { logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, result.snapshotInstant); backupNotificationMgr.notify(result); }); if (!backupVerification .verifyBackup(BackupVersion.SNAPSHOT_META_SERVICE, false , dateRange) .isPresent()) { logger.error( "Not able to find any snapshot which is valid in our SLO window: {} hours", backupRestoreConfig.getBackupVerificationSLOInHours()); backupMetrics.incrementBackupVerificationFailure(); } } }
BackupVerificationTask extends Task { @Override public void execute() throws Exception { if (backupRestoreConfig.getSnapshotMetaServiceCronExpression().equals("-1")) { logger.info("Skipping backup verification. V2 backups are not enabled."); return; } if (instanceState.getRestoreStatus() != null && instanceState.getRestoreStatus().getStatus() != null && instanceState.getRestoreStatus().getStatus() == Status.STARTED) { logger.info("Skipping backup verification. Priam is in restore mode."); return; } Instant now = DateUtil.getInstant(); Instant slo = now.minus(backupRestoreConfig.getBackupVerificationSLOInHours(), ChronoUnit.HOURS); DateRange dateRange = new DateRange(slo, now); List<BackupVerificationResult> verificationResults = backupVerification.verifyAllBackups(BackupVersion.SNAPSHOT_META_SERVICE, dateRange); verificationResults.forEach( result -> { logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, result.snapshotInstant); backupNotificationMgr.notify(result); }); if (!backupVerification .verifyBackup(BackupVersion.SNAPSHOT_META_SERVICE, false , dateRange) .isPresent()) { logger.error( "Not able to find any snapshot which is valid in our SLO window: {} hours", backupRestoreConfig.getBackupVerificationSLOInHours()); backupMetrics.incrementBackupVerificationFailure(); } } @Inject  BackupVerificationTask(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            BackupVerification backupVerification,
            BackupMetrics backupMetrics,
            InstanceState instanceState,
            BackupNotificationMgr backupNotificationMgr); }
BackupVerificationTask extends Task { @Override public void execute() throws Exception { if (backupRestoreConfig.getSnapshotMetaServiceCronExpression().equals("-1")) { logger.info("Skipping backup verification. V2 backups are not enabled."); return; } if (instanceState.getRestoreStatus() != null && instanceState.getRestoreStatus().getStatus() != null && instanceState.getRestoreStatus().getStatus() == Status.STARTED) { logger.info("Skipping backup verification. Priam is in restore mode."); return; } Instant now = DateUtil.getInstant(); Instant slo = now.minus(backupRestoreConfig.getBackupVerificationSLOInHours(), ChronoUnit.HOURS); DateRange dateRange = new DateRange(slo, now); List<BackupVerificationResult> verificationResults = backupVerification.verifyAllBackups(BackupVersion.SNAPSHOT_META_SERVICE, dateRange); verificationResults.forEach( result -> { logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, result.snapshotInstant); backupNotificationMgr.notify(result); }); if (!backupVerification .verifyBackup(BackupVersion.SNAPSHOT_META_SERVICE, false , dateRange) .isPresent()) { logger.error( "Not able to find any snapshot which is valid in our SLO window: {} hours", backupRestoreConfig.getBackupVerificationSLOInHours()); backupMetrics.incrementBackupVerificationFailure(); } } @Inject  BackupVerificationTask(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            BackupVerification backupVerification,
            BackupMetrics backupMetrics,
            InstanceState instanceState,
            BackupNotificationMgr backupNotificationMgr); @Override void execute(); static TaskTimer getTimer(IBackupRestoreConfig backupRestoreConfig); @Override String getName(); }
BackupVerificationTask extends Task { @Override public void execute() throws Exception { if (backupRestoreConfig.getSnapshotMetaServiceCronExpression().equals("-1")) { logger.info("Skipping backup verification. V2 backups are not enabled."); return; } if (instanceState.getRestoreStatus() != null && instanceState.getRestoreStatus().getStatus() != null && instanceState.getRestoreStatus().getStatus() == Status.STARTED) { logger.info("Skipping backup verification. Priam is in restore mode."); return; } Instant now = DateUtil.getInstant(); Instant slo = now.minus(backupRestoreConfig.getBackupVerificationSLOInHours(), ChronoUnit.HOURS); DateRange dateRange = new DateRange(slo, now); List<BackupVerificationResult> verificationResults = backupVerification.verifyAllBackups(BackupVersion.SNAPSHOT_META_SERVICE, dateRange); verificationResults.forEach( result -> { logger.info( "Sending {} message for backup: {}", AbstractBackupPath.BackupFileType.SNAPSHOT_VERIFIED, result.snapshotInstant); backupNotificationMgr.notify(result); }); if (!backupVerification .verifyBackup(BackupVersion.SNAPSHOT_META_SERVICE, false , dateRange) .isPresent()) { logger.error( "Not able to find any snapshot which is valid in our SLO window: {} hours", backupRestoreConfig.getBackupVerificationSLOInHours()); backupMetrics.incrementBackupVerificationFailure(); } } @Inject  BackupVerificationTask(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            BackupVerification backupVerification,
            BackupMetrics backupMetrics,
            InstanceState instanceState,
            BackupNotificationMgr backupNotificationMgr); @Override void execute(); static TaskTimer getTimer(IBackupRestoreConfig backupRestoreConfig); @Override String getName(); static final String JOBNAME; }